Commit Graph

21502 Commits

Author SHA1 Message Date
Allan Shortlidge
322daab362 Distributed: Add unsafe keyword to uses of pthreads. 2025-03-28 12:33:40 -07:00
Allan Shortlidge
aef0d2105b Runtime: Fix unused declaration warnings in Backtrace.cpp. 2025-03-28 12:33:39 -07:00
Allan Shortlidge
82cd87187f AST: Introduce the AllowRuntimeSymbolDeclarations experimental feature.
This feature only exists as a mechanism to suppress the warning introduced in
https://github.com/swiftlang/swift/pull/75378. The RegexParser module, which is
effectively part of the standard library, declares a Swift runtime symbol and
as a result every build of the compiler and stdlib produces warnings which
there are no plans to address. Warnings that are not going to be addressed need
some way of being suppressed, and an experimental features seems like a
reasonable mechanism for this one.
2025-03-28 12:32:47 -07:00
Doug Gregor
fd24d29055 Merge pull request #80357 from DougGregor/strict-safety-improvements
Strict safety improvements
2025-03-28 11:58:44 -07:00
Alastair Houghton
6e28716319 [Concurrency] Address some review comments.
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
2025-03-28 10:15:14 +00:00
Alastair Houghton
a418ce4931 [Concurrency] Fix some comments and a typo.
There were a couple of comments that needed updating, and a typo
in a function name.

rdar://141348916
2025-03-28 10:15:14 +00:00
Alastair Houghton
0c96a257f6 [Concurrency] Fix task-to-thread model linking.
We need to provide some of the additional functions, as stubs, for
task-to-thread model.

rdar://141348916
2025-03-28 10:15:14 +00:00
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Doug Gregor
b2f0ce44cc Remove a use of @safe @unsafe from the standard library 2025-03-27 22:05:21 -07:00
Karoy Lorentey
5583e6916c Merge pull request #73258 from lorentey/you-cannot-escape-optionals
[stdlib] Generalize some constructs for non-escapable types
2025-03-27 20:02:00 -07:00
Nate Chandler
2af30b2f04 [NFC] CoroutineAccessors: Remove old runtime files
The functions are open-coded now.
2025-03-27 19:23:09 -07:00
Nate Chandler
c141586838 [CoroutineAccessors] Open code dealloc fn. 2025-03-27 19:23:09 -07:00
Nate Chandler
dd238343bb [CoroutineAccessors] Open code alloc fn.
Replace the runtime function with an open-coded version.
2025-03-27 19:23:09 -07:00
nate-chandler
b878155a5a Merge pull request #80335 from nate-chandler/general-coro/20250326/2
[CoroutineAccessors] Move functions and add dealloc bit.
2025-03-27 19:19:25 -07:00
Guillaume Lessard
abf29e7433 [stdlib] adjust MutableSpan’s element constraint 2025-03-27 17:19:15 -07:00
Guillaume Lessard
6a7dbb02f3 [stdlib] update lifetime annotations for Mutable[Raw]Span 2025-03-27 16:55:06 -07:00
Guillaume Lessard
7a160a2dfc [stdlib] de-underscore the extracting() methods 2025-03-27 16:55:05 -07:00
Guillaume Lessard
107b38f9e0 [stdlib] add mutableSpan to array types 2025-03-27 16:55:05 -07:00
Alex Martini
7ee720bfc4 Use verb fragment, per API reference style 2025-03-27 16:51:25 -07:00
Alex Martini
84a4a849e2 Fix indentation - move prose out of code listing
Fixes: rdar://145075268
2025-03-27 16:49:48 -07:00
Guillaume Lessard
ecebaa591e [stdlib] move span properties of array types
…to a more logical spot in each of their files
2025-03-27 14:52:08 -07:00
Doug Gregor
a61c40054d Merge pull request #80337 from DougGregor/cast-prohibits-isolated-conformances
[SE-0470] Prohibit isolated conformances in dynamic casts that can't safely use them
2025-03-27 14:17:45 -07:00
Guillaume Lessard
90684a87a3 [stdlib] add missing unsafe annotations 2025-03-27 13:34:34 -07:00
Guillaume Lessard
5a087d1190 [stdlib] annotate unsafe initializers 2025-03-27 13:34:34 -07:00
Guillaume Lessard
9553982253 [stdlib] use the internal unsafe-unwrap 2025-03-27 13:34:34 -07:00
Guillaume Lessard
4a78667db8 [stdlib] tweaks to MutableRawSpan 2025-03-27 13:34:33 -07:00
Guillaume Lessard
b39ee18f31 [stdlib] tweaks to MutableSpan 2025-03-27 13:34:33 -07:00
Guillaume Lessard
cbbe5df00b [stdlib] add unsafe annotations 2025-03-27 13:34:33 -07:00
Guillaume Lessard
484905b42d [stdlib] add extracting() to MutableSpan and MutableRawSpan 2025-03-27 13:34:32 -07:00
Guillaume Lessard
f214ef29d0 [stdlib] small spelling fixes 2025-03-27 13:34:32 -07:00
Guillaume Lessard
2fa2391c28 [stdlib] remove 2 symbols 2025-03-27 13:34:32 -07:00
Guillaume Lessard
30a3eaec4f [stdlib] add MutableSpan and MutableRawSpan 2025-03-27 13:30:13 -07:00
Guillaume Lessard
98fc0a9d36 Merge pull request #80326 from benrimmington/span
[stdlib] Update element constraints of `Span`
2025-03-27 12:43:06 -07:00
Nate Chandler
dbcd038959 [CoroutineAccessors] Add wrapper for dealloc.
Make the fast path faster by avoiding a dyld stub.
2025-03-27 11:37:26 -07:00
Nate Chandler
f30d8a603c [CoroutineAccessors] Rehome runtime functions.
Put them where they're meant to be, in swiftCore.
2025-03-27 11:37:26 -07:00
Karoy Lorentey
86f6c29e34 [stdlib] Temporarily reinstate original ObjectIdentifier.init as public
The new generalization sometimes causes a runtime hang that I’m still analyzing. The original declaration should be considered more specific for preexisting use cases, eliminating the source compatibility issue.
2025-03-27 11:24:31 -07:00
Pavel Yaskevich
6082173b8a Merge pull request #80280 from xedin/rdar-131732245
[TypeChecker] Avoid dropping pre-check diagnostics in `typeCheckParam…
2025-03-27 08:59:43 -07:00
Saleem Abdulrasool
87f2b88ada Concurrency: remove workaround for silencing UB
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.
2025-03-27 08:27:06 -07:00
Doug Gregor
edd118af72 [Runtime] Fix dynamic cast call for non-ObjC runtime 2025-03-27 06:59:03 -07:00
Mike Ash
433ff598f5 Merge pull request #80319 from mikeash/priority-escalation-retry-fix
[Concurrency] Avoid de-escalating a task when racing to escalate.
2025-03-27 09:36:21 -04:00
Doug Gregor
43df05a89c [SE-0470] Prohibit isolated conformances in dynamic casts marked as such
Certain dynamic casts cannot work safely with isolated conformances,
regardless of what executor the code runs on. For such cases, reject
all attempts to conform to the type.
2025-03-26 22:31:52 -07:00
nate-chandler
e8d871ced5 Merge pull request #80290 from nate-chandler/general-coro/20250325/1
[CoroutineAccessors] Directly reference allocators.
2025-03-26 21:47:09 -07:00
Allan Shortlidge
2f78ba8828 Sema: Extend _unsafeInheritExecutor_ hack to Clock.measure().
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.
2025-03-26 21:12:58 -07:00
Slava Pestov
51face17da Merge pull request #80282 from Steelskin/fabrice/define-swift-stdlib-build-types-missing
Disable CompatibilitySpans outside of stdlib build
2025-03-26 20:08:09 -04:00
Ben Rimmington
2f9f5ffd85 [stdlib] Update element constraints of Span 2025-03-26 22:32:08 +00:00
Pavel Yaskevich
d656f74652 [TypeChecker] Avoid dropping pre-check diagnostics in typeCheckParameterDefault
`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
2025-03-26 14:22:32 -07:00
Max Desiatov
eb1a2960b6 Enable _Concurrency for Embedded Swift with WASI (#79292)
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>
2025-03-26 21:14:05 +00:00
Mike Ash
7c3b06dc4f [Concurrency] Avoid de-escalating a task when racing to escalate.
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
2025-03-26 15:44:57 -04:00
Mike Ash
6397e30856 [Concurrency] Eliminate StatusRecordLockRecord.
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
2025-03-26 14:52:37 -04:00
Nate Chandler
0c2a38b10b [CoroutineAccessors] Directly reference allocators
Replace the call to a runtime function that looks up the allocator with
a direct reference to a just-emittedd sought-after global allocator.
2025-03-26 08:35:35 -07:00