Commit Graph

17564 Commits

Author SHA1 Message Date
David Smith
bed89567d4 Disable calling _swift_stdlib_dyld_is_objc_constant_string, it's unnecessary currently (#77064) 2024-10-17 19:01:08 -07:00
swift-ci
5bfc87531f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 18:21:11 -07:00
Michael Gottesman
1a07030a0a Merge pull request #77028 from gottesmm/swift_task_runOnMainActor
[concurrency] Implement swift_task_runOnMainActor/hop to main actor thunk
2024-10-17 18:11:24 -07:00
swift-ci
f207571405 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 14:48:02 -07:00
Dario Rexin
5b8cfa473f Merge pull request #77078 from drexin/wip-oops
[Runtime] Use aligned offset to compute new field offset for unmanage…
2024-10-17 14:42:33 -07:00
Michael Gottesman
b1750bad1a [concurrency] Implement swift_task_runOnMainActor.
This routine takes a synchronous non-throwing main actor isolated closure
without a result. If we are dynamically on the main actor, we just run the
closure synchronously. Otherwise, we run a new task on the main actor and call
the closure on that.

This builds on top of the previous commit by using
swift_task_isCurrentExecutorWithFlags in the implementation of this function.

To backwards deploy this function on Darwin, I used some tricks from libdispatch
to validate that we are on the main queue.
2024-10-17 11:17:38 -07:00
Michael Gottesman
5fa02d8711 [concurrency] Add a new entrypoint: swift_task_isCurrentExecutorWithFlags.
This entrypoint is similar to swift_task_isCurrentExecutor except that it
provides an ABI level option flag that enables one to configure its behavior in
a backwards deployable manner via the option flag.

I used this to expose at the ABI level the ability to check the current executor
without crashing on failure, while preserving the current behavior of
swift_task_isCurrentExecutor (which crashes on failure).

I am going to use this to implement swift_task_runOnMainActor.
2024-10-17 11:17:38 -07:00
swift-ci
083ff08307 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 10:55:18 -07:00
Augusto Noronha
17926e78fa Merge pull request #77038 from augusto2112/stop-spare-bits-debug
[DebugInfo] Stop emitting spare bits mask in debug info
2024-10-17 10:41:28 -07:00
Mike Ash
763666ed6c Merge pull request #77031 from mikeash/actor-enqueue-retain
[Concurrency] Retain the actor around the CAS in enqueue() when necessary.
2024-10-17 13:38:04 -04:00
Dario Rexin
2bcece3e52 [Runtime] Use aligned offset to compute new field offset for unmanaged properties in CVW
The original fix only added the field size to the unaligned offset, which is not correct.
2024-10-17 10:31:07 -07:00
swift-ci
70ece60b69 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 10:11:01 -07:00
Dario Rexin
0ec1f4b6ce Merge pull request #76799 from drexin/wip-137066879
[Runtime] Properly compute offset for unmanaged properties in generic…
2024-10-17 09:42:22 -07:00
swift-ci
1df3ffb7cb Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 09:12:58 -07:00
Tim Kientzle
5bd2c4b93c Merge pull request #77027 from tbkka/tbkka-remotemirror-classexistential
Fix multi-payload enums with Class Existential payloads on 32-bit targets
2024-10-17 08:57:38 -07:00
Tim Kientzle
689ffbe28b A separate "indirect case" counter didn't properly distinguish generic indirect vs. non-generic indirect.
Counting indirect cases as regular non-empty cases is a better fit.
2024-10-17 08:49:08 -07:00
swift-ci
6d6062cf59 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-16 23:07:22 -07:00
Kuba Mracek
2358cc973d [Concurrency] Split out the default cooperative executor into a separate opt-in library 2024-10-16 22:49:22 -07:00
Kuba (Brecka) Mracek
44bea0552a Merge pull request #76029 from kubamracek/embedded-traps-unique
[embedded] Make assert helper functions always inlined to avoid trap basic blocks from merging
2024-10-16 22:46:39 -07:00
Tim Kientzle
fe90ad5684 Let indirect enum cases export spare bits
To determine the correct enum layout, we first count various
categories of cases.  Before, we counted indirect generic cases as
"generic", but regular "generic" cases can't export spare bits.

Change this to count "indirect" cases as a separate category.
In particular, this ensures that fully-indirect enums use
spare bits from the pointers even when some or all of the cases
are generic.

Resolves rdar://133890406
2024-10-16 18:31:28 -07:00
Tim Kientzle
cfc7b2ef2e Use SWIFT_FALLTHROUGH 2024-10-16 17:02:47 -07:00
Tim Kientzle
502941ca5a More arcana about MPEs carrying class existentials
The first word in a class existential is the class pointer itself.
This pointer exposes spare bits differently depending
on the platform, which becomes apparent when you try to reflect
an Optional carrying such an MPE.

Add new test cases and some logic to zero out the first
word of spare bit information only on platforms with 8-byte pointers.
2024-10-16 16:06:37 -07:00
Mike Ash
6b01fed9c4 [Concurrency] Retain the actor around the CAS in enqueue() when necessary.
It's possible that the job we enqueue holds the last strong reference to the actor. If that job runs on another thread after we enqueue it, then it's possible for `this` to be destroyed while we're still in this function. We need to use `this` after the enqueue when the priorities don't match. When it looks like that will happen, retain `this` before the enqueue to ensure it stays alive until we're done with it.

Introduce a defensive retain helper class that makes it easy to do a single retain under certain conditions even in a loop, and does RAII to balance it with a release when the scope exits.

rdar://135400933
2024-10-16 16:51:29 -04:00
Tim Kientzle
f5de38e2cc Remove RemoteInspection code to fetch no-longer-used reflection metadata
without relying on spare bit information in the reflection metadata
(which was added in #40906).  As a result, we can remove the
code from #40906.

This is the first step in such removal.  It removes the RemoteMirror
code for looking up such metadata.  It leaves behind:

* Sufficient stubs for LLDB to continue to build.  Once LLDB is updated, these stubs can be removed as well.

* The compiler code to emit such metadata.  This allows new binaries to still reflect MPEs on older runtimes.  This will need to be kept for a transitional period.

(cherry picked from commit c20ef6de2a)
2024-10-16 11:12:32 -07:00
swift-ci
4ac1f2887f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-15 10:16:56 -07:00
Egor Zhdan
844d103f0d Merge pull request #77006 from swiftlang/egorzhdan/cxx-contiguous
[cxx-interop] Add `UnsafeCxxContiguousIterator` & `UnsafeCxxMutableContiguousIterator` protocols
2024-10-15 19:01:15 +02:00
Tim Kientzle
a105cf5323 Fix multi-payload enums with Class Existential payloads on 32-bit targets
Class existentials expose spare bits from all of the pointers, not just the first one.
Due to a bad bug here, we were properly exposing spare bits from the first pointer,
but then claiming that all bits of subsequent pointers were spare.
This accidentally resulted in the correct operation on 64-bit targets
(it picked the highest-order spare bit, which happened to be spare
in both the broken mask and the correct mask).  But on 32-bit targets,
this exposed the high-order bits of pointers, which is incorrect.

Expand the test a bit while we're here as well.

Resolves rdar://132715829
2024-10-15 09:28:01 -07:00
swift-ci
2dc48645a1 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-15 08:35:32 -07:00
Egor Zhdan
3a200deee9 [cxx-interop] Add UnsafeCxxContiguousIterator & UnsafeCxxMutableContiguousIterator protocols
This adds a pair of Swift protocols that represents C++ iterator types conforming to `std::contiguous_iterator_tag` requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as `std::vector` from Swift, for instance, by providing an overload of `withContiguousStorageIfAvailable` for contiguous containers.

rdar://137877849
2024-10-15 14:30:09 +01:00
Kuba Mracek
d2dac4ed72 [Concurrency] Avoid relying on stderr, fprintf(), write() in Embedded Concurrency runtime 2024-10-14 13:36:14 -07:00
swift-ci
f0b98875ec Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 17:33:30 -07:00
Nate Cook
9265743adc Add validation to CollectionDifference decoder (#76876)
The `CollectionDifference` type has a few different invariants
that were not being validated when initializing using the type's
`Decodable` conformance, since the type was using the
autogenerated `Codable` implementation. This change provides
manual implementations of the `Encodable` and `Decodable`
requirements, and adds tests that validate the failure when trying
to decode invalid JSON for CollectionDifference (and a few other
types).
2024-10-11 17:23:55 -07:00
swift-ci
e1cfbb45cc Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 11:19:47 -07:00
Ben Troller
5c032d91d0 Merge pull request #75993 from btroller/btroller-134364958-optimize-brute-force-search-in-readTypeRef
[RemoteMirror] Optmize brute-force search in TypeRefBuilder::ReflectionTypeDescriptorFinder::readTypeRef().
2024-10-11 11:08:51 -07:00
swift-ci
0224d4de9b Merge remote-tracking branch 'origin/main' into rebranch 2024-10-10 23:35:46 -07:00
David Smith
bca125c760 rdar://137709108 (Mitigate the code size increase from eager-lazy array bridging by marking some methods release none) (#76966) 2024-10-10 23:29:25 -07:00
swift-ci
e4e9dfb39a Merge remote-tracking branch 'origin/main' into rebranch 2024-10-10 22:33:56 -07:00
Kuba Mracek
d06f2cbb76 [embedded] Add armv7m-apple-none-macho as an embedded cross-compiling target 2024-10-10 15:27:46 -07:00
swift-ci
7b9b00a900 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-10 03:54:29 -07:00
Konrad `ktoso` Malawski
bd554ba524 Merge pull request #76883 from nickolas-pohilets/mpokhylets/move-task-locals-header 2024-10-10 19:38:35 +09:00
swift-ci
260bdcf278 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-09 04:33:41 -07:00
Alastair Houghton
a0a77fa401 Merge pull request #76870 from al45tair/eng/PR-137286187
[Concurrency] Remove C++ runtime references from embedded Concurrency.
2024-10-09 12:33:26 +01:00
swift-ci
e75d787e75 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 22:54:27 -07:00
Karoy Lorentey
ee4d4a33bd Merge pull request #75433 from lorentey/string-index-printing2 2024-10-08 22:34:03 -07:00
swift-ci
40aee60b24 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 19:09:12 -07:00
Allan Shortlidge
0c09c6d778 Concurrency: Fix warnings in the runtime.
Addresses an unused variable warning and an unreachable code warning.
2024-10-08 14:49:17 -07:00
swift-ci
493022109b Merge remote-tracking branch 'origin/main' into rebranch 2024-10-07 21:33:06 -07:00
Konrad `ktoso` Malawski
8ae66ec1a5 Merge pull request #76888 from ktoso/wip-improve-execute-buffer-init-tracking 2024-10-08 13:21:42 +09:00
Karoy Lorentey
29cf262ef7 [stdlib] String.Index: conform to CustomDebugStringConvertible instead
Apply the LSG’s modifications as detailed in their review notes.
2024-10-07 17:00:13 -07:00
Karoy Lorentey
28ed16b469 [stdlib] String.Index.description: Explicitly note that the returned format is not stable
This tends to be generally through for most `description` properties, but explicitly calling it out should help preventing people from trying to parse the result in this case.
2024-10-07 16:02:18 -07:00