Commit Graph

21434 Commits

Author SHA1 Message Date
Guillaume Lessard
b90a6fcb41 [stdlib] add CollectionOfOne.mutableSpan 2025-04-09 09:56:06 -07:00
Slava Pestov
17868a7b50 CompatibilitySpan: Fix stdlib build on visionOS
Swift CI tests visionOS, but PR testing does not. Oops.
2025-04-09 12:37:45 -04:00
Max Desiatov
ccd9cf7b5e Concurrency: Move code between Executor{Bridge,Impl}.cpp (#80601)
New `ExecutorImpl.cpp` is excluded when building Embedded Swift stdlib. This fixes duplicate symbol errors when using Embedded Swift.
2025-04-09 05:36:07 -07:00
Alejandro Alonso
fafdc8663b Make _Cell public 2025-04-08 16:07:54 -07:00
Mike Ash
f01d46ce38 [Runtime] Handle relative witness tables in _checkWitnessTableIsolation.
We need to use lookThroughOptionalConditionalWitnessTable when relative witness tables are being used.

rdar://148687148
2025-04-08 16:14:48 -04:00
Slava Pestov
8c11d78672 Merge pull request #80510 from slavapestov/mutable-span-compat
CompatibilitySpan: Add MutableRawSpan.swift, MutableSpan.swift
2025-04-08 15:03:59 -04:00
Mike Ash
e3057031da [RemoteMirror] Fix AsyncTask child iteration.
Iterating child tasks depends on knowing the size of AsyncTask, and changing the size of the task broke it. Instead of relying on mirroring the full structure in our out-of-process definitions, add a debug variable to libswift_Concurrency that contains the size of AsyncTask.

While we're there, add some more validation to child task enumeration. Check each child task's metadata pointer to make sure that it actually points to the AsyncTask metadata, and have the inner loop also increment and check ChildTaskLoopCount to stop runaway iteration in that loop.
2025-04-08 13:09:29 -04:00
Slava Pestov
43da773685 stdlib: Update {Mutable,}{Raw,}Span availability for backward deployment 2025-04-07 21:32:48 -04:00
Slava Pestov
4c8c3aab4f CompatibilitySpan: Add MutableRawSpan.swift, MutableSpan.swift 2025-04-07 21:32:44 -04:00
Slava Pestov
1d25522ceb cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-07 21:32:14 -04:00
Meghana Gupta
90324721ad [NFC] Update comment 2025-04-07 16:49:37 -07:00
Mike Ash
1f0696ae05 Merge pull request #80505 from mikeash/metadata-cycle-race-fix
[Runtime] Fix a false metadata cycle diagnostic when threads race to instantiate cyclical metadata.
2025-04-07 16:59:27 -04:00
Philippe Hausler
9d1d917091 [Observation] ensure event triggers on deinitialization passes as if all properties that are being observed have changed (for weak storage) (#79823)
* [Observation] ensure event triggers on deinitialziation passes as if all properties that are being observed have changed (for weak storage)

* Add missing deinitialize method for synthetically triggering willSet

* Correct the weak location for tests

* Correct the test to actually test the deinitialization willSet trigger instead of testing weak value deinitialization time

* Refine the tests for deinit triggers to more tightly trigger deinitialization and weak references

* Correct missing trailing closure on deinit replacement

* Ensure all potential ids are triggered at the deinitialization edge trigger
2025-04-07 13:03:56 -07:00
Meghana Gupta
2d9217bb4f Merge pull request #80541 from meg-gupta/inoutreland
Reland #80452
2025-04-07 10:20:10 -07:00
Egor Zhdan
1ea54588d0 Merge pull request #78841 from CrazyFanFan/feature/replace_self_type_with_generics
[cxx-interop]: Refactor `CxxDictionary` protocols to use generics instead of `Self`.
2025-04-07 11:50:36 +01:00
nate-chandler
0063af561f Merge pull request #80520 from nate-chandler/general-coro/20250403/1
[CoroutineAccessors] Use async bit in descriptors.
2025-04-04 15:47:19 -07:00
Guillaume Lessard
7dd029c372 Revert "[temporary] disable spans over inline elements"
This reverts commit e5c7dfc430.
2025-04-04 14:50:51 -07:00
Mike Ash
9ad534bc4a [Runtime] Fix a false metadata cycle diagnostic when threads race to instantiate cyclical metadata.
The metadata creation system detects cycles where metadata depends on other metadata which depends on the first one again and raises a fatal error if the cycle can't be fulfilled.

Some cycles can be fulfilled. The cycle may involve a requirement for a metadata state less than full transitive completeness which can be reached without resolving the entire cycle. We only want to raise a fatal error when we detect a cycle that can't be fulfilled.

Normally this happens because the cycle checking in `blockOnMetadataDependency` only sees a cycle when it can't be fulfilled. Metadata initialization is advanced as far as it can be at each stage, so a cycle that can be fulfilled will see a fulfilling state and won't generate the dependency in the first place, since we only generate dependencies that haven't yet been met.

However, when two threads race to create types in a cycle, we can end up with such a dependency, because the dependency may be generated before another thread fulfilled yet. The cycle checker doesn't account for this and incorrectly raises a fatal error in that case.

Fix this by checking the cyclic dependency against the metadata's current state. If we have a dependency that's already been fulfilled, then there isn't really a dependency cycle. In that case, don't raise a fatal error.

rdar://135036243
2025-04-04 17:49:55 -04:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Doug Gregor
b850395611 Merge pull request #80518 from DougGregor/resurrect-allow-unsafe-attribute
[stdlib] Reinstate AllowUnsafeAttribute experimental feature on libraries
2025-04-04 05:20:27 -07:00
Konrad `ktoso` Malawski
8d72db58fe Merge pull request #80522 from ktoso/wip-better-assertion-pop-record
[Concurrency] Improve assertion to validate we pop the EXACT record we intend to
2025-04-04 18:11:56 +09:00
Meghana Gupta
50ea777936 Merge pull request #80452 from meg-gupta/lifetimeinout
Add support for inout lifetime dependence
2025-04-04 02:04:53 -07:00
Konrad 'ktoso' Malawski
0cb39ddd8a [Concurrency] Improve assertion to validate we pop the EXACT record we intend to 2025-04-04 13:25:58 +09:00
Nate Chandler
66ca0d8d4b [CoroutineAccessors] Use async bit in descriptors.
To facilitate back deployment, make use of the fact that the async bit
has up to now never been set for read and modify accessors and claim
that set bit to indicate that it is a callee-allocated coroutine.  This
has the virtue of being completely back deployable because like async
function pointers coro function pointers must be auth'd and signed as
data.
2025-04-03 19:49:44 -07:00
Doug Gregor
0100104ff7 [stdlib] Reinstate AllowUnsafeAttribute experimental feature on libraries
We need this so that older compilers can handle the .swiftinterface
files we generate. It's unnecessary for newer compilers and can be
removed later.

Fixes rdar://148529962.
2025-04-03 18:07:19 -07:00
Meghana Gupta
493f0b782e Introduce InoutLifetimeDependence feature 2025-04-03 17:32:09 -07:00
Meghana Gupta
f4a980d62d Update stdlib 2025-04-03 17:32:09 -07:00
Artem Chikin
69b4ea3469 Merge pull request #80421 from swiftlang/revert-80246-playing-with-pointy-pointers
Revert "Concurrency: remove workaround for silencing UB"
2025-04-03 16:12:53 -07:00
Allan Shortlidge
a6d311e3ed Merge pull request #80501 from tshortli/stdlib-warnings
stdlib: Address #StrictMemorySafety and unreachable code warnings
2025-04-03 15:05:51 -07:00
Alastair Houghton
1745467062 Merge pull request #80492 from al45tair/eng/PR-148506256
[Concurrency] Fix race condition in `_runAsyncMain`.
2025-04-03 18:57:23 +01:00
Allan Shortlidge
14e0eed88f stdlib: Address unreachable code warnings. 2025-04-03 10:19:46 -07:00
Allan Shortlidge
d32310fb76 stdlib: Address new #StrictMemorySafety warnings. 2025-04-03 10:18:39 -07:00
Alejandro Alonso
06937d89a6 [stdlib] Update availability of EnumeratedSequence collection conformance (#80471) 2025-04-03 14:48:05 +01:00
Alastair Houghton
a9ed11ca96 [Concurrency] Fix race condition in _runAsyncMain.
As of the custom main/global executor changes, there is a race in
`_runAsyncMain()` to construct the main executor; if this goes the wrong way,
the IRGen async tests, which use this function, can fail.

Fix by explicitly constructing a task and enqueing it on the main executor,
instead of detaching a task and trying to hop to it.

rdar://148506256
2025-04-03 12:07:52 +01:00
Guillaume Lessard
aedb869c69 Merge pull request #80116 from glessard/rdar137710901-utf8view-span-notsmol
[SE-0456] Span properties over utf8 views
2025-04-03 01:02:14 -07:00
Guillaume Lessard
7539366c46 [stdlib] rename internal and private symbols 2025-04-02 17:53:13 -07:00
Guillaume Lessard
278f76b666 [stdlib] remove a repetition 2025-04-02 17:53:13 -07:00
Guillaume Lessard
5eab44651d [stdlib] document performance limitations on String’s span 2025-04-02 17:53:13 -07:00
Guillaume Lessard
f3a01663ac [stdlib] document limitations for Substring’s span 2025-04-02 17:53:13 -07:00
Guillaume Lessard
bde7a1871c [stdlib] harden bounds checking in Substring’s span 2025-04-02 17:53:12 -07:00
Guillaume Lessard
0bbec0c6d8 [stdlib] a less public association key
- with tweaks in associated object code
2025-04-02 17:53:12 -07:00
Guillaume Lessard
0976b61ecc Apply suggestions from code review
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2025-04-02 17:53:12 -07:00
Guillaume Lessard
ea44ff9fc9 [temporary] disable small-string support 2025-04-02 17:53:12 -07:00
Alastair Houghton
941991b9e1 Merge pull request #80439 from al45tair/eng/PR-148337712
[Concurrency] Use the correct Dispatch clock.
2025-04-02 16:11:37 +01:00
eeckstein
6c0b7782f5 Merge pull request #80404 from eeckstein/optimize-floating-point
Optimizer: add some floating point optimizations
2025-04-02 13:06:25 +02:00
Konrad `ktoso` Malawski
28c4930f4f [Concurrency] Avoid inserting handler record in already cancelled task. (#80456)
This avoids the potential to race with the triggering coming from
task_cancel, because we first set the cancelled flag, and only THEN
take the lock and iterate over the inserted records. Because of this we
could: T1 flip the cancelled bit; T2 observes that, and triggers
"immediately" during installing the handler record. T1 then proceeds to
lock records and trigger it again, causing a double trigger of the
cancellation handler.

resolves https://github.com/swiftlang/swift/issues/80161
resolves rdar://147493150
2025-04-02 19:21:18 +09:00
Crazy凡
b4531a6ae8 [cxx-interop]: Refactor CxxDictionary protocols to use generics instead of Self.
- Add support for merging `std::map` and `std::unordered_map` with each other seamlessly.
- Add support for typed throws
2025-04-02 09:14:06 +08:00
David Smith
f800fdf3d2 Adopt indirect tagged strings (#80425)
Fixes rdar://142991821
2025-04-01 12:53:29 -07:00
Julian Lettner
a7ade95529 Remove Malloc Type Descriptor cache (#80355)
Remove Malloc Type Descriptor cache and trivialize
`computeMallocTypeSummary()` to only provide
language.  The remaining info in
`malloc_type_summary_t` are currently not used by
the allocator.

The principled, long-term solution is to have the
Swift compiler compute type descriptors for Swift
types.

rdar://137993434
2025-04-01 10:07:29 -07:00