Tweaked diagnostic to use a string instead of a type. Renamed the
feature in `FeatureAvailability.def` (and added the `TaskExecutor`
feature to 6.2). Also fixed the `swift_getActiveExecutor()`
function to return the main executor only when on the main thread.
rdar://141348916
The newer clang properly identifies UB on invalid pointer casts. This
was previously being silenced by suppressing the warnings. Adjust the
code to use `std::bit_cast` (or the shim implementation) to avoid the
UB in this code.
Fixes the bug in `swift::introduceUnsafeInheritExecutorReplacements()` that
prevented the hack from working with `Clock.measure()`. It isn't sufficient to
just check whether the nominal for the type base of a qualified lookup belongs
to the Concurrency module because that type may reference multiple types.
Instead, check all of the directly referenced types to match the behavior of
qualified lookup.
Resolves rdar://132581483.
`typeCheck{Expression, Target}` has a pre-check phase which would
replace some invalid AST nodes (i.e. name references that are not
available in the given declaration context) with `ErrorExpr`s and
emit a diagnostic. Such diagnostics were then dropped by `abort()`
call to a diagnostic transaction. This results in invalid code being
accepted by Sema and forwarded to SILGen.
Resolves: https://github.com/swiftlang/swift/issues/73986
Resolves: rdar://131732245
WASI with Embedded Swift provides WASI-libc and libc++ headers necessary to build the `_Concurrency` module for Wasm. We now add `wasm32-unknown-wasip1-wasm` triple to `EMBEDDED_STDLIB_TARGET_TRIPLES` when `SWIFT_WASI_SYSROOT_PATH` is set, which builds the necessary stdlib slice.
---------
Co-authored-by: Yuta Saito <kateinoigakukun@gmail.com>
Reload oldPriority each time through the compare_exchange loop. Without this, we might race with another escalating thread and end up trying to set a priority that's lower or equal to the priority set by the other thread. This results in an assertion failure when asserts are enabled, or attempt to lower the priority of the task when asserts are not enabled.
rdar://147888768
Move to a recursive lock inline in the Task. This avoids the need to allocate a lock record and simplifies the code somewhat.
Change Task's OpaquePrivateStorage to compute its size at build time based on the sizes of its components, rather than having it be a fixed size. It appears that the fixed size was intended to be part of the ABI, but that didn't happen and we're free to change this size. We need to expand it slightly when using pthread_mutex as the recursive lock, as pthread_mutex is pretty big. Other recursive locks allow it to shrink slightly.
We don't have a recursive mutex in our Threading support code, so add a RecursiveMutex type.
rdar://113898653
rdar://147907609
When starting tasks synchronously on task groups, the task create flags for isSynchronousStart and isDiscardingTask were always set to `false`. With this change the former will always be `true` and the latter conditionally `true` for discarding task groups.
We have a few constructor functions that aren't wrapped in SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN/SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END and which have started to produce warnings in a new clang version. Explicitly allow these constructors by adding those.
rdar://147703947
Android should use the dispatch based, Linux platform executor. However,
Android reports as `os(Android)` rather than `os(Linux)`. This adjusts
the condition to ensure that we have a platform executor factory for
Android.
* [Concurrency] Fix templated code in Task+startSynchronously.swift
rdar://147348183
The gyb code always dropped the `throws` modifier, no matter which case was being processed.
* Update Task+startSynchronously.swift.gyb
* Fix abi tests
Change task ids to be formatted using decimal instead of hex.
An example of previous signposts:
```
task=e resumefn=0x2807722bc jobPriority=0 isChildTask=0, isFuture=1 isGroupChildTask=0 isAsyncLetTask=0 parent=0 group=0x0 asyncLet=0x0
```
this will now show `task=14` instead of `task=e`
_swift_taskGroup_cancelAllChildren relies on there being no concurrent modification when called from the owning task, but this is not guaranteed.
Rearrange things to always take the owning task's status record lock when walking the group's children. Split _swift_taskGroup_cancelAllChildren into two functions, one which assumes/requires the lock is already held, and one which acquires the lock. We don't have the owning task in this case, but we can either get it from the current task, or by looking at the parent of the child task we're working on.
rdar://147172991
`CooperativeExecutor` should fall back to heap allocations if the task
allocator isn't available when it's enqueuing delayed jobs.
Also, remove the reference to `DispatchGlobalExecutor` from the
custom executor test.
rdar://141348916
Fix a typo that caused us to not include the correct code for platforms
that use "singlethreaded" concurrency.
Also use `var` not `let` for the computed property in `PlatformExecutorFactory`.
rdar://141348916
* [Concurrency] Detect non-default impls of isIsolatingCurrentContext
* [Concurrency] No need for trailing info about isIsolating... in conformance
* Apply changes from review
* [Concurrency] Adjust task escalation APIs to SE accepted shapes
* adjust test a little bit
* Fix closure lifetime in withTaskPriorityEscalationHandler
* avoid bringing workaround func into abi by marking AEIC
Otherwise in certain cases, we will run into:
1588 | extension GlobalActor {
| | `- error: 'GlobalActor' is only available in macOS 10.15 or newer
| `- note: add @available attribute to enclosing extension
1589 | @available(SwiftStdlib 6.2, *)
1590 | @_silgen_name("_swift_task_isCurrentGlobalActor")
rdar://146848568
EventableExecutor is being removed, for now, but hopefully will
return in some form in the future.
The `asSchedulable` implementation needs to change for reasons of
ABI stability.
rdar://141348916
Remove `supportsScheduling` in favour of a type-based approach.
Update the storage for `ClockTraits` to `UInt32`.
Adjust ordering of executors for `currentExecutor`.
rdar://141348916