Commit Graph

17564 Commits

Author SHA1 Message Date
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
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
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
Guillaume Lessard
ea57dd93a0 [stdlib] work around autoclosure issues
- The move-only checker has issues with the existence of autoclosures.
- These `borrowing` accessors are within the purview of the move-only checker.
2025-04-18 10:45:00 -07:00
Guillaume Lessard
4ae1ad744d Revert "[temporary] disable small-string support"
This reverts commit ea44ff9fc9.
2025-04-18 10:44:59 -07:00
Michael Ilseman
393c24ddd7 UTF8Span (#78531) (#80890)
Add support for UTF8Span

Also, refactor validation and grapheme breaking
2025-04-18 10:01:15 -04:00
Doug Gregor
c363658147 Merge pull request #80887 from DougGregor/conformance-cache-extended-entry-deleak-6.2 2025-04-17 19:07:09 -07:00
Eric Miotto
a948f794c9 Merge pull request #80883 from edymtt/emiotto/mark-executorimpl_cpp-optional-6.2
[6.2] CMake Embedded Stdlib: mark `ExecutorImpl.cpp` as optional
2025-04-17 14:37:26 -07:00
Doug Gregor
cead04b530 [Conformance cache] Add allocated extended-storage for entries to the free list
This memory is part of the conformance cache concurrent hash map, so
when we clear the conformance cache, record each of the allocated
pointers within the concurrent map's free list. This way, it'll be
freed with the rest of the concurrent map when it's safe to do so.

(cherry picked from commit 885f829a63)
2025-04-17 09:03:16 -07:00
Doug Gregor
e8eed435ee [Runtime] Replace use of C++ new with malloc()
(cherry picked from commit d576fa30c9)
2025-04-17 09:03:13 -07:00
Eric Miotto
d542e5c728 [6.2] CMake Embedded Stdlib: mark ExecutorImpl.cpp as optional
This is needed for internal Apple configurations that build the Embedded
Stdlib on its own.

Addresses rdar://149410405

(cherry picked from commit a249e7fd8d)
2025-04-17 06:52:43 -07:00
Konrad `ktoso` Malawski
361ebea8d7 Merge pull request #80797 from ktoso/pick-wip-parent-cancel-must-cancel-group
[6.2][Concurrency] Parent task cancellation must cancel task group itself
2025-04-17 11:33:11 +09:00
Doug Gregor
15ecd6654d Merge pull request #80845 from DougGregor/relative-witness-tables-fixes-6.2
[6.2] Relative witness table fixes
2025-04-16 17:37:51 -07:00
Alastair Houghton
b5a61a1d48 Merge pull request #80796 from al45tair/eng/PR-149067144-6.2
[Concurrency] Fix size of AsyncTask::PrivateStorage.
2025-04-16 13:17:05 +01:00
Doug Gregor
77caa2dadd [Conformance cache] Handle missing protocol descriptors
This can happen when running against an older version of a library that
doesn't have the protocol defined.
2025-04-15 21:12:52 -07:00
Doug Gregor
e32174abae [Runtime] Don't use the low bit of a WitnessTable pointer in the conformance cache
With relative witness tables, the low bit of a witness table pointer is
an indicator that we need to load from the given pointer. We were also
using the low bit of the witness table pointer in the conformance
cache entry as part of a pointer union. Hilarity ensures [*].

Switch to another low bit by exploding the conformance cache key
into separate fields and taking the low bit of one of those pointers
that isn't reserved.

Fixes the remainder of rdar://149326058, I hope.

[*] No, I am not laughing.
2025-04-15 18:15:26 -07:00
Doug Gregor
2de64b666f [Runtime] Handle relative witness tables in _getIsolationCheckingOptionsFromExecutorWitnessTable
Part of rdar://148687148.
2025-04-15 18:15:06 -07:00
Konrad 'ktoso' Malawski
29b8e271e1 [Concurrency] Refactor _swift_taskGroup_cancelAllChildren -> _cancel
This way we do the right thing always when cancelling the group;
and we MAY visit the child tasks if we have to.
2025-04-14 17:44:00 +09:00