Commit Graph

17573 Commits

Author SHA1 Message Date
Yuta Saito
49a20d110a Concurrency: Guard TG state with a mutex even with cooperative executor
`SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY` just means that the global
executor is cooperative, but it doesn't mean that the target platform is
always single-threaded. For example, on wasm32-unknown-wasip1-threads,
the global executor is cooperative, but users can still set up their own
TaskExecutor with multiple threads.

This patch guards the `TaskGroup` state with a mutex even with a
cooperative executor by respecting threading package instead. This
change effectively affects only wasm32-unknown-wasip1-threads.
2024-07-06 08:14:07 +00:00
Guillaume Lessard
8733ecd012 Merge pull request #75000 from glessard/rdar99047401-err-nosendable
[concurrency/stdlib] declare `POSIXErrorCode` as `Sendable`
2024-07-05 16:58:51 -07:00
Guillaume Lessard
ab117c997d [concurrency] declare POSIXErrorCode as Sendable 2024-07-05 13:34:26 -07:00
Egor Zhdan
b0a3bb10f0 [cxx-interop] Build Cxx and CxxStdlib modules for macCatalyst
This enables building the C++ stdlib overlays (`Cxx.swiftmodule` and `CxxStdlib.swiftmodule`) for the Mac Catalyst target.

rdar://126938813
2024-07-05 19:35:29 +01:00
Alastair Houghton
fc012fd258 Merge pull request #74891 from al45tair/eng/PR-130954606
[Runtime] Use dyld to find the image path when possible.
2024-07-04 15:10:06 +01:00
Mike Ash
7a976c6497 Merge pull request #74951 from mikeash/fix-libprespecialized-missing-return
[Runtime] Fix missing return in getMetadataFromPointerKeyedMap.
2024-07-04 10:00:29 -04:00
David Smith
3589044213 A new way to bridge constant NSStrings (#74881) 2024-07-03 20:38:33 -07:00
Mike Ash
9bbcef3bc5 [Runtime] Fix missing return in getMetadataFromPointerKeyedMap.
When DYLD_FIND_POINTER_HASH_TABLE_ENTRY_DEFINED is set but the function is not found at runtime, we're missing a return statement.
2024-07-03 15:26:11 -04:00
Alejandro Alonso
9cbf410220 Adopt inout sending for Mutex 2024-07-03 10:54:20 -07:00
Allan Shortlidge
fb6ab05746 Concurrency: Restore -enable-experimental-feature IsolatedAny.
Supported older compilers don't enable this feature by default, so it can't be
omitted from the `_Concurrency` module's flags (regression from
https://github.com/swiftlang/swift/pull/74543).

Additionally, remove `@_allowFeatureSuppression(IsolatedAny)` from all
declarations. We no longer need to support compilers that don't have the
`IsolatedAny` feature, so the suppression is superfluous and the alternative
branches didn't actually build anyways. _Additionally_, the suppressible
feature logic could not handle suppressing `IsolatedAny` simultaneously with
`SendingArgsAndResults`, resulting in a broken interface because `sending` was
used outside `#if $SendingArgsAndResults` guards.
2024-07-03 10:36:47 -07:00
Konrad `ktoso` Malawski
70ed18044d Allow using older API if $BuiltinCreateAsyncTaskOwnedTaskExecutor is not available 2024-07-03 10:36:47 -07:00
Konrad `ktoso` Malawski
9ee719dbcd Prevent potential for condfail with owned task executor parameter
While the new parameter is added in a compatible way where code which
does not refer to it will get a defaulted nil value; since we refer to a
new parameter name in source, we need to guard it with a language
feature -- as old compilers will not have this new name available.

This should prevent a potential condfail issue.
2024-07-03 10:36:47 -07:00
Allan Shortlidge
b47b5ccba0 Concurrency: Remove superfluous $BuiltinBuildMainExecutor guards. 2024-07-02 22:59:28 -07:00
Allan Shortlidge
b9c12aa314 Concurrency: Remove superfluous $BuiltinExecutor guards. 2024-07-02 22:59:28 -07:00
Allan Shortlidge
346bbcaa05 Concurrency: Remove superfluous $BuiltinCreateAsyncTaskInGroup guards. 2024-07-02 22:26:55 -07:00
Allan Shortlidge
3aca6b6ceb Concurrency: Remove superfluous $BuiltinCreateTaskGroupWithFlags guards. 2024-07-02 22:26:55 -07:00
Allan Shortlidge
ee8a1152b2 Concurrency: Promote BuiltinCreateTask feature to baseline. 2024-07-02 22:26:55 -07:00
Allan Shortlidge
7e181d17e5 Concurrency: Promote BuiltinCreateAsyncDiscardingTaskInGroupWithExecutor feature to baseline. 2024-07-02 22:26:55 -07:00
Allan Shortlidge
e5744f04d6 Concurrency: Promote BuiltinCreateAsyncDiscardingTaskInGroup feature to baseline. 2024-07-02 22:26:55 -07:00
Allan Shortlidge
a4d58671ba Concurrency: Promote BuiltinCreateAsyncTaskInGroupWithExecutor feature to baseline. 2024-07-02 22:26:54 -07:00
Allan Shortlidge
f2519650ae Concurrency: Promote BuiltinBuildComplexEqualityExecutor feature to baseline. 2024-07-02 22:26:54 -07:00
Allan Shortlidge
ba630c0da5 Concurrency: Promote BuiltinBuildTaskExecutorRef feature to baseline. 2024-07-02 22:26:54 -07:00
Michael Gottesman
34195ff213 Merge pull request #74610 from gottesmm/pr-324fd70c13e87a329334341aae4667f2d1be152c
[sending] Remove transferring.
2024-07-02 14:02:18 -07:00
Alejandro Alonso
906d6e43c0 Merge pull request #74739 from Azoy/commandline-argc-ignore
[stdlib] Ignore argc when setting up CommandLine.arguments
2024-07-02 13:41:28 -07:00
Alastair Houghton
d846689695 [Runtime] Use dyld to find the image path when possible.
For performance reasons, we want to avoid `dladdr()` when possible.

rdar://130954606
2024-07-02 14:11:10 +01:00
Saleem Abdulrasool
f011de6ce8 Merge pull request #74829 from compnerd/android-notes
ClangImporter: add support for Android API Notes
2024-07-01 11:34:46 -07:00
Susana Monteiro
686d1b4c30 Merge pull request #74783 from susmonteiro/susmonteiro/cxx-span-from-ubpointer
[cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
2024-07-01 19:02:05 +01:00
susmonteiro
e86099c26d [cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
Tests: init span from UnsafeBufferPointer, for loop, map, filter, init Array from span, span of strings
2024-07-01 16:07:28 +01:00
Konrad `ktoso` Malawski
deb81bcf07 Discard changes to stdlib/public/Concurrency/Executor.swift (#74859) 2024-07-01 06:57:43 -07:00
Konrad `ktoso` Malawski
b9369bf0b7 [Concurrency] Fix default actor isolation issue in face of TaskExecutor preference (#74658)
* [Concurrency] Fix task excutor handling of default actor isolation

The task executor API did not properly account for taking the default
actor locking into account when running code on it, we just took the job
and ran it without checking with the serial executor at all, which
resulted in potential concurrent executions inside the actor --
violating actor isolation.

Here we change the TaskExecutor enqueue API to accept the "target"
serial executor, which in practice will be either generic or a specific
default actor, and coordinate with it when we perform a
runSynchronously.

The SE proposal needs to be amended to showcase this new API, however
without this change we are introducing races so we must do this before
the API is stable.

* Remove _swift_task_enqueueOnTaskExecutor as we don't use it anymore

* no need for the new protocol requirement

* remove the enqueue(_ job: UnownedJob, isolatedTo unownedSerialExecutor: UnownedSerialExecutor)

Thankfully we dont need it after all

* Don't add swift_defaultActor_enqueue_withTaskExecutor and centralize the task executor getting to enqueue()

* move around extern definitions
2024-07-01 16:42:27 +09:00
Saleem Abdulrasool
3f3b0b3e85 Merge pull request #74742 from compnerd/extended 2024-06-29 05:58:09 -07:00
Saleem Abdulrasool
47f9d78990 ClangImporter: add support for Android API Notes
Introduce the first APINotes injection for the Android platform. This
follows the VCRuntime pattern of permitting the SDK to provide API Notes
that augment the system SDK. This adds a workaround for incorrect
nullability on the `fts_open` function in bionic. The system library
itself is fixed at:
https://android-review.googlesource.com/c/platform/bionic/+/3151616
2024-06-28 13:24:04 -07:00
Ben Barham
d8f381e660 Merge pull request #74804 from bnbarham/rename-equals
Update `StringRef::equals` references to `operator==`
2024-06-28 11:22:20 -07:00
Ben Barham
d72f5b12c4 Update StringRef::equals references to operator==
`equals` has been deprecated upstream, use `operator==` instead.
2024-06-27 19:14:06 -07:00
Alejandro Alonso
1e2192e018 Update CommandLine.swift 2024-06-27 10:41:59 -07:00
Alejandro Alonso
b8c308d4f1 Merge pull request #74775 from benrimmington/int128-docs
[stdlib] Update documentation of {U}Int128 types
2024-06-27 10:39:54 -07:00
Rokhini Prabhu
1f466c2312 Merge pull request #70603 from swiftlang/rokhinip/clear-scheduler-private-fields-executor
Clear out the SchedulerPrivate fields before enqueueing the task
2024-06-27 09:52:31 -07:00
Ben Rimmington
7d3b2ef7d1 [stdlib] Update documentation of {U}Int128 types 2024-06-27 14:19:13 +01:00
Konrad `ktoso` Malawski
1c1b6f7aaa Merge pull request #74606 from ktoso/wip-whenLocal-adjust
[Distributed] Adjust whenLocal impl to avoid potential ABI issues
2024-06-27 19:01:55 +09:00
Konrad `ktoso` Malawski
0c65fe8f42 Remove TaskGroup backDeployed annotation typo that included * (#74756)
Fix typo on a single task group backDeployed annotation.
2024-06-26 18:17:43 -07:00
Guillaume Lessard
8897ba3bf5 Merge pull request #74710 from glessard/rdar128709914-again
[stdlib] remove more deprecations added by SE-0426
2024-06-26 16:08:11 -07:00
Saleem Abdulrasool
22817ccf1a Platform: add sys_xattr module for Android
This module was left out from the modulariation pass. The declarations
here are required for building swift-foundation for Android.
2024-06-26 12:33:36 -07:00
Alejandro Alonso
3285f56dad Ignore argc 2024-06-26 10:54:57 -07:00
Konrad `ktoso` Malawski
8bc53736e4 Merge pull request #73568 from ktoso/wip-fix-last-_unsafeInheritExecutor-usage
[Concurrency] Remove last usages of @_unsafeInheritExecutor
2024-06-26 22:01:28 +09:00
Guillaume Lessard
a707b6849c [stdlib] remove more deprecations added by SE-0426 2024-06-25 14:43:19 -07:00
Kuba (Brecka) Mracek
9caf750e7f Merge pull request #74536 from kubamracek/embedded-windows1
[embedded] Start building embedded stdlib on Windows
2024-06-24 12:22:24 -07:00
Kuba (Brecka) Mracek
fb0a1b96ae Merge pull request #73870 from kubamracek/embedded-libraries-cmake
[embedded] Add a embedded-libraries CMake target to simplify the test dependencies
2024-06-24 08:39:50 -07:00
Konrad `ktoso` Malawski
0160fc367a [Concurrency] adopt #isolation in last remaining APIs 2024-06-24 11:44:44 +09:00
Konrad `ktoso` Malawski
58c5a76836 [Concurrency] TaskGroup.with... APIs using #isolation
move tests to existing actor_withCancellationHandler.swift file
2024-06-24 11:44:44 +09:00
Konrad `ktoso` Malawski
2546f63cb5 [Concurrency] Fix _unsafeInheritExecutor usage in withTaskCancellationHandler 2024-06-24 11:44:43 +09:00