Commit Graph

21492 Commits

Author SHA1 Message Date
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
Guillaume Lessard
e81fbe5f48 [stdlib] use “LifetimeDependenceMutableAccessors” 2025-04-15 22:25:24 -07: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
Konrad 'ktoso' Malawski
059e5dd15e [Concurrency] Parent task cancellation must cancel task group itself.
Seems that during refactorings of child cancellations we somehow missed
also cancelling the group itself. It seems we did not have good test
coverage of the addTaskUnlessCancelled somehow and thus this slipped
through.

This adds a regression test for addTaskUnlessCancelled and fixes how we
handle the cancellation effect in TaskStatus.

resolves #80789
resolves rdar://149177600
2025-04-14 17:43:55 +09:00
Alastair Houghton
55ec37253e [Concurrency] Fix size of AsyncTask::PrivateStorage.
Because `TaskAllocator` is not a round multiple of the machine word
size on 64-bit platforms, I think we end up with padding before the
`TaskLocal::Storage` following it, which makes the `PrivateStorage`
structure larger than the calculation in `ABI/Task.h`.

rdar://149067144
2025-04-14 09:28:50 +01:00
Alastair Houghton
670be7df63 [Concurrency] Remove -executor-factory option and replace with magic type.
We decided that using a magic typealias to set the executor factory was better
than using a compiler option. Remove the `-executor-factory` option, and replace
by looking up the `DefaultExecutorFactory` type, first in the main module, and
then if that fails in Concurrency.

rdar://149058236
2025-04-14 09:23:03 +01:00
Meghana Gupta
c22acc530e [6.2] Revert #79707
Revert "Merge pull request #79707 from DougGregor/transparent-integer-conversions"

This reverts commit 9c2c4ea07f, reversing
changes made to 829e03c104.
2025-04-11 10:57:14 -07:00
Guillaume Lessard
cb390140d6 [stdlib] correct MutableRawSpan sizing 2025-04-10 10:31:18 -07:00
Guillaume Lessard
53b6b45bda [stdlib] update lifetime annotation syntax 2025-04-10 10:31:18 -07:00
Guillaume Lessard
77431f5217 [stdlib] add MutableSpan.mutableBytes 2025-04-10 10:31:05 -07:00
Meghana Gupta
b3881cde1d Merge pull request #80645 from meg-gupta/lifetimeinoutcp
[6.2] Add support for inout lifetime dependencies
2025-04-10 03:04:28 -07:00
Mike Ash
29db1eca14 Merge pull request #80644 from mikeash/fix-task-sizes-6.2
[6.2][Concurrency] Fix task status and private storage sizes.
2025-04-09 13:37:37 -04:00
Mike Ash
c689d748eb Merge pull request #80612 from mikeash/metadata-cycle-race-fix-6.2
[6.2][Runtime] Fix a false metadata cycle diagnostic when threads race to instantiate cyclical metadata.
2025-04-09 13:28:23 -04:00
Meghana Gupta
00bda986a9 Introduce InoutLifetimeDependence feature 2025-04-09 10:19:11 -07:00
Meghana Gupta
0c5edc5222 Update stdlib 2025-04-09 10:19:11 -07:00
Guillaume Lessard
79fb06faf3 [stdlib] update lifetime annotation syntax 2025-04-09 09:56:06 -07:00
Guillaume Lessard
f931d296a2 [stdlib] add InlineArray.mutableSpan 2025-04-09 09:56:06 -07:00
Guillaume Lessard
b90a6fcb41 [stdlib] add CollectionOfOne.mutableSpan 2025-04-09 09:56:06 -07:00
Mike Ash
5a37a27798 [Runtime] Handle relative witness tables in _checkWitnessTableIsolation.
We need to use lookThroughOptionalConditionalWitnessTable when relative witness tables are being used.

rdar://148687148
(cherry picked from commit f01d46ce38)
2025-04-08 16:17:09 -04:00
Mike Ash
7edc799b16 [6.2][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.

rdar://148836760

(cherry picked from commit e3057031da)
2025-04-08 15:23:05 -04:00
Doug Gregor
bd83ae14f4 Merge pull request #80552 from DougGregor/resurrect-allow-unsafe-attribute-6.2 2025-04-08 09:43:19 -07:00
Mike Ash
c64a5662f2 [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
(cherry picked from commit 9ad534bc4a)
2025-04-07 17:00:03 -04:00
Nate Chandler
63a1bb0705 [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-04 15:50:11 -07:00
Doug Gregor
06c0efbce6 [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.

(cherry picked from commit 0100104ff7)
2025-04-04 15:18:25 -07:00
Guillaume Lessard
7dd029c372 Revert "[temporary] disable spans over inline elements"
This reverts commit e5c7dfc430.
2025-04-04 14:50:51 -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