Commit Graph

21492 Commits

Author SHA1 Message Date
Konrad 'ktoso' Malawski
75a3cacaec [Concurrency] Hide the _withSerialExecutor, we will introduce executor 2025-05-01 22:08:18 +09:00
Konrad 'ktoso' Malawski
fe0889b285 [Concurrency] Offer way to get SerialExecutor from Actor 2025-05-01 22:07:13 +09:00
Alastair Houghton
c072992fe4 Merge pull request #81201 from al45tair/eng/PR-150310927-6.2
[Concurrency] Fix issue with using Dispatch queues as executors.
2025-05-01 11:57:24 +01:00
Meghana Gupta
7b0ac8b5b6 Merge pull request #81216 from meg-gupta/fixcowcp
[6.2] Insert end_cow_mutation_addr for lifetime dependent values dependent on mutable addresses
2025-05-01 00:44:41 -07:00
Konrad 'ktoso' Malawski
3615dbf398 [Concurrency] Fix ptr auth for task priority escalation handler
We missed to sign the handler. Along the way the signature of it
changed, so adjust for that.

How to get the number:

```
func PROPER(bar: (TaskPriority, TaskPriority) -> Void) {
    let p = TaskPriority.default
    bar(p, p)
}
```

```
-> % swiftc -target arm64e-apple-macos13 example.swift -S -o - | swift demangle | grep -a3 autda
	stur	x8, [x29, #-64]
	mov	x17, x8
	movk	x17, #11839, lsl #48 <<<<<<<<<
	autda	x16, x17
	ldr	x8, [x16, #64]
	lsr	x8, x8, #0
	add	x8, x8, #15
```

Resolves rdar://150378890
2025-05-01 12:13:29 +09:00
Doug Gregor
fcedb0b2a4 Merge pull request #81125 from DougGregor/unsafe-call-effects-6.2
[6.2] [Strict memory safety] Provide argument-specific diagnostics for calls
2025-04-30 15:09:50 -07:00
Meghana Gupta
67b5290ac2 Disable runtime cow verification for mutableSpan property 2025-04-30 14:38:02 -07:00
Mike Ash
a44dadd0e0 [6.2][Concurrency] Fix alreadyLocked in withStatusRecordLock.
If the preloaded status is locked, then we need to reload it in order to distinguish between the current thread holding the lock and another thread holding the lock. Without this, if another thread holds the lock, then we won't set the is-locked bit. We'll still actually hold the lock, but other threads may perform operations locklessly if the bit is not set, which can cause a crash. By reloading status in that case, we ensure that the bit is always set correctly.

This manifested as crashes in task cancellation but could cause other task-related issues as well.

Also remove an assert of !isStatusRecordLocked() in AsyncTask::complete(). We allow other threads to access tasks and take the lock for things like cancellation, so the lock may legitimately be held at that point.

rdar://150327908
(cherry picked from commit 325b66ab20)
2025-04-30 13:56:29 -04:00
Guillaume Lessard
c5acba54fa Merge pull request #80777 from glessard/rdar138440979-MutableSpan-mutableBytes
[6.2, SE-0467] add mutableBytes to MutableSpan
2025-04-30 09:46:44 -07:00
Alastair Houghton
7f5f45ced2 [Concurrency] Fix issue with using Dispatch queues as executors.
We were failing to switch executors to Dispatch queues, where those
were being used as executors, which caused a variety of unusual
symptoms.

rdar://150310927
2025-04-30 14:29:14 +01:00
Alastair Houghton
ae47fd7140 [Concurrency] Fix copy-paste error.
The `__builtin_add_overflow` should have been adding to `leeway`, not to
`deadline`.

rdar://150290165
2025-04-30 10:19:04 +01:00
Konrad `ktoso` Malawski
ec7ed9ac39 [6.2][Concurrency] Hashable funcs should be inlinable for AsyncStream (#81127)
Small review followup for https://github.com/swiftlang/swift/pull/81064/

The impls should be @inlinable.

Original PR: https://github.com/swiftlang/swift/pull/81126
Radar: rdar://149914179
2025-04-30 00:58:01 -07:00
Guillaume Lessard
e9b21cff7d Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62
[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-29 12:30:10 -07:00
Guillaume Lessard
b442d3177b Merge pull request #80740 from glessard/rdar137710901-addressable-span-properties
[6.2, SE-0456, -0467] enable span properties for inline-storage types
2025-04-29 12:29:34 -07:00
Eric Miotto
62f391e32e 6.2: Add _Builtin_float dependency to Distributed and Synchronization
This will avoid errors in CI when the latter ones are scheduled before
the former.

Addresses rdar://149558141

(cherry picked from commit 231a9d989d)
2025-04-29 08:24:14 -07:00
Konrad 'ktoso' Malawski
25413d2ef4 [embedded][Concurrency] Further refine C-api boundary for isIsolating... 2025-04-29 22:29:54 +09:00
Konrad 'ktoso' Malawski
a63356ed0d [Concurrency] adjust how we fail creating an IsIsolatingCurrentContextDecision 2025-04-28 20:26:17 +09:00
Konrad 'ktoso' Malawski
eaf0b15ea3 [Concurrency] Change isIsolatingCurrent... to return Bool?
This changes the isIsolatingCurrentContext function to return `Bool?`
and removes all the witness table trickery we did previously to detect
if it was implemented or not. This comes at a cost of trying to invoke
it always, before `checkIsolated`, but it makes for an simpler
implementation and more checkable even by third party Swift code which
may want to ask this question.

Along with the `withSerialExecutor` function, this now enables us to
check the isolation at runtime when we have an `any Actor` e.g. from
`#isolation`.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/
review discussions
2025-04-28 19:17:58 +09:00
Max Desiatov
c51eaa336a Revert "Revert "Concurrency: Move code between Executor{Bridge,Impl}.cpp"" (#80692)
* Revert "Revert "Concurrency: Move code between `Executor{Bridge,Impl}.cpp`""

* Update CMakeLists.txt
2025-04-28 19:16:32 +09:00
Andrew Trick
716b66091b Merge pull request #81118 from atrick/62-rdar146319009-borrow-constraint
[6.2] Bypass lifetime diagnostics in interfaces for copied arguments.
2025-04-27 22:13:18 -07:00
Doug Gregor
7f29a27e3d [Strict memory safety] Update standard library for unsafe treated as a call effect
(cherry picked from commit 050a514588)
2025-04-26 07:45:32 -07:00
Konrad 'ktoso' Malawski
b33404e9d2 [Distributed] thread-safety also for parameter type metadata
We had fixed this bug in https://github.com/swiftlang/swift/pull/79381
but missed to realize the same problem existed for parameters as well.

This corrects the swift_func_getParameterTypeInfo impl, and also removes
the entire "unsafe" method, we no longer use it anywhere.

Resolves rdar://146679254
2025-04-26 21:36:40 +09:00
Andrew Trick
f71b8366e7 Add _overrideLifetime to Span APIs
The implementation previously took advantage of a missing diagnostic. They
returned a borrowed Span with a dependency on a copied argument. This illegally
promotes the dependency. This is what the author intended to do (the
implementation was correct) but the compiler can't know that so the code needs
to be explicit about overriding the lifetime.

(cherry picked from commit e9d11283b9)
2025-04-25 19:21:16 -07:00
Gábor Horváth
3983642cb9 Merge pull request #81098 from swiftlang/gaborh/mutable-span-conversion-6.2 2025-04-25 11:36:24 -07:00
Doug Gregor
cbcaf5ed4d Merge pull request #81064 from ktoso/pick-hashable-continuation
[6.2][Concurrency] Add Hashable conformance to Async(Throwing)Stream.Continuation
2025-04-25 09:33:25 -07:00
Gabor Horvath
07a7afe142 [6.2][cxx-interop] Proper conversions between MutableSpan and C++ span
Explanation: One of the initializers were missing and the other was crashing at
runtime due to a faulty signature in the overlay.
Issue: rdar://149846666
Risk: Low, the fix is additive.
Testing: Regression test added.
Original PR: #81097
Reviewer:
2025-04-25 11:31:39 +01:00
Evan Wilde
732808147d Merge pull request #81040 from etcwilde/ewilde/6.2-runtime-fix-clobbered-memories
[🍒][SwiftCore]: Don't always clobber memory
2025-04-24 10:02:27 -07:00
Mykola Pokhylets
3fdcb49fb2 Use concrete SwiftStdlib version 2025-04-24 13:17:04 +09:00
Mykola Pokhylets
ee2e86c7fc Added explicit availability attribute for each protocol requirement
To fix failing test/api-digester/stability-concurrency-abi.test
2025-04-24 13:17:00 +09:00
Mykola Pokhylets
d1b3cca1d9 Added Hashable conformance to Async(Throwing)Stream.Continuation 2025-04-24 13:16:54 +09:00
Evan Wilde
be7cc109e6 [SwiftCore]: Don't always clobber memory
The new build system set `SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS` to 0.
Unfortunately, the check in the Swift runtime used `#ifdef`, so even
though it was turned off, it was actually enabled in some cases.

Fixing the issue in the build system as well as switching the check to
verify that value of `SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS` is taken into
account in the sources. C/C++ implicitly defines macro values to 1 when
set without a value and 0 when it is not set.

Also making the hex a bit more recognizable and grep'able by including
it as a comment.

Fixes: rdar://149210738
(cherry picked from commit 6f39a52afc)
2025-04-23 11:18:19 -07:00
Slava Pestov
a10356aa27 Merge pull request #80680 from slavapestov/compatibility-span-6.2
[6.2] Cherry-pick recent CompatibilitySpan work
2025-04-23 01:00:29 -04:00
Ian Anderson
cbb0347bea Merge pull request #80994 from ian-twilightcoder/embedded-builtin_float
[6.2][embedded] Build the _Builtin_float overlay in embedded Swift mode
2025-04-22 21:53:12 -07:00
Meghana Gupta
e4b60db09a Merge pull request #80956 from meg-gupta/cposlog
[6.2] Reland #79707
2025-04-22 21:00:05 -07:00
Mike Ash
36d67e990f Merge pull request #80949 from mikeash/function-cast-6.2
[6.2][Runtime] Add function_cast, switch from std::bit_cast.
2025-04-22 16:25:06 -04:00
Ian Anderson
b523649cb5 [6.2][embedded] Build the _Builtin_float overlay in embedded Swift mode
Add embedded targets for the _Builtin_float overlay.

rdar://123951443
2025-04-22 10:11:52 -07:00
Karoy Lorentey
3fce89c2e8 [stdlib] Allow metatype comparisons to work with outdated compilers
Add a new language feature to avoid the stdlib’s swiftinterface becoming unintelligible to outdated compiler builds due to the generalization of Builtin.is_same_metatype.

rdar://149396721
(cherry picked from commit 0c406b89e6)
2025-04-22 10:02:20 -07:00
Doug Gregor
28d2bef2d1 Merge pull request #80946 from DougGregor/safe-nested-in-unsafe-fixes-6.2
[6.2] [Strict memory safety] Improve handling of safe types nested within unsafe ones
2025-04-21 17:22:13 -07:00
QuietMisdreavus
61c4a0311f [6.2] [SymbolGraphGen] add flags to filter platforms out of availability metadata (#80806)
rdar://144379124
2025-04-21 14:48:43 -06:00
Slava Pestov
9dfe53e343 CompatibilitySpan: Fix stdlib build on visionOS
Swift CI tests visionOS, but PR testing does not. Oops.
2025-04-21 15:01:29 -04:00
Slava Pestov
001b1129f7 stdlib: Update {Mutable,}{Raw,}Span availability for backward deployment 2025-04-21 15:01:29 -04:00
Slava Pestov
b3eb1a5bbd CompatibilitySpan: Add MutableRawSpan.swift, MutableSpan.swift 2025-04-21 15:01:28 -04:00
Slava Pestov
4af982902c cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-21 15:01:28 -04:00
Meghana Gupta
adb809369f Reland #79707
Revert "Merge pull request #80767 from meg-gupta/reverttransparent"

This reverts commit 198a802719, reversing
changes made to 8eb43af590.
2025-04-21 11:23:00 -07:00
Meghana Gupta
856cbaff9d Add @_transparent to some integer operations in the stdlib
@_transparent will ensure there are inlined in MandatoryInlining which runs before OSLogOptimization.

OSLogOptimization does not look through their calls because they are not marked with
@_semantics("constant_evaluable") which requires them to also be annotated as @_optimize(none)

rdar://148256435
2025-04-21 11:22:26 -07:00
Mike Ash
b2d6514b63 [6.2][Runtime] Add function_cast, switch from std::bit_cast.
Function types aren't always trivially copyable, e.g. with address-discriminated signed pointers on ARM64e. Introduce a function_cast helper and use that instead.

(cherry picked from commit 185b739cf1)
2025-04-21 12:47:48 -04:00
Doug Gregor
19975bc78f Remove extraneous unsafe from the concurrency library
(cherry picked from commit 1c9875e14a)
2025-04-21 09:03:34 -07:00
Doug Gregor
3724f84376 [Strict memory safety] Update standard library for nested safe/unsafe types
Use this to mark a few internal types @safe now that it works properly.

(cherry picked from commit 457eb4cc64)
2025-04-21 09:03:30 -07:00
Doug Gregor
469b30334c [Strict memory safety] Remove now-extraneous "unsafe" from the standard libraries
Now that we aren't propagating "unsafe" to nested types, remove
unnecessary "unsafe" keywords from the standard library.

(cherry picked from commit fe6856726e)
2025-04-21 09:03:23 -07:00
Evan Wilde
506d128487 Fix Bootstrap: UTF8EncoddingError
The pass that annotated control-flow positions unreachable after an
infinite loop was migrated to pure Swift in PR 79186
(https://github.com/swiftlang/swift/pull/79186). As a result, the
C++-only bootstrap compiler is unable to determine that the
code-location is unreachable. Placing a fatalError after the infinite
while loop.

Fixes: rdar://149568740
(cherry picked from commit 783c969e10)
2025-04-20 09:06:38 -07:00