Commit Graph

2588 Commits

Author SHA1 Message Date
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Pavel Yaskevich
72eb8abadb [Sema/SILGen] Don't emit dynamic actor isolation checks when -disable-dynamic-actor-isolation flag is used 2024-04-15 09:19:22 -07:00
Pavel Yaskevich
03e9d4258e [Frontend] NFC: Promote DynamicActorIsolation to an upcoming feature flag 2024-04-14 21:28:13 -07:00
Nate Chandler
943cc3cc7c [NoncopyablePartialConsumption] Enable.
SE-429 was accepted.

rdar://126275392
2024-04-11 08:19:29 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Meghana Gupta
76581eac95 Disable test Interpreter/escapable_generics_casting.swift 2024-04-08 11:54:33 -07:00
Nate Chandler
548adb94df [Test] Fix uniqueness check lines for 64 bit.
rdar://125628293
2024-04-04 08:43:43 -07:00
nate-chandler
4677d1432a Merge pull request #72814 from nate-chandler/test/disable/rdar125628293
[Test] Disable a test on arm64_32.
2024-04-03 17:12:44 -07:00
Kavon Farvardin
e759a28f56 Merge pull request #72786 from kavon/ncgenerics-associatedtype-restriction
NCGenerics: introduce `SuppressedAssociatedTypes`
2024-04-03 16:28:54 -07:00
Nate Chandler
b466ba4972 [Test] Disable a test on arm64_32.
At least while we're investigating.

rdar://125628293
2024-04-03 13:36:36 -07:00
Kavon Farvardin
30983530b6 NCGenerics: introduce SuppressedAssociatedTypes
The model for associated types hasn't been fully worked-out for
noncopyable generics, but there is some support already that is being
used by the stdlib for an internal-only (and rather cursed) protocol
`_Pointer` to support `UnsafePointer`, etc.

This patch gates the existing experimental support for associated types
behind a feature flag. This flag doesn't emit feature-guards in
interfaces, since support for it is tied closely to NoncopyableGenerics
and has been there from its early days.
2024-04-02 16:53:36 -07:00
Doug Gregor
ae01d20428 Runtime checking for associated types conforming to invertible protocols
Emit metadata for runtime checks of conformances of associated types to
invertible protocols, e.g., `T.Assoc: Copyable`. This allows us to
correctly handle, e.g., dynamic casting involving conditional
conformances that have such constraints.

The model we use here is to emit an invertible-protocol constraint
that leaves only the specific bit clear in the invertible protocol
set.
2024-04-02 16:42:16 -07:00
Doug Gregor
2b390d1a6a Mark tests that require the new runtime for invertible protocols support
Fixes rdar://125628899
2024-03-29 14:48:33 -07:00
Becca Royal-Gordon
576a4bac36 Merge pull request #72596 from beccadax/objcimpl-real-name
Add @implementation and feature flags for objcImpl
2024-03-28 23:48:24 -07:00
Konrad `ktoso` Malawski
86f5441294 [SerialExecutor] SerialExecutor.checkIsolated() to check its own tracking for isolation checks (#71172) 2024-03-29 07:06:34 +09:00
Becca Royal-Gordon
492d4ad49d Add experimental feature flags for @implementation
• ObjCImplementation controls @implementation on extensions
• CImplementation controls @implementation and @_objcImplementation on cdecl functions

Why the difference between them? Because `@_objcImplementation extension` has already been adopted pretty widely, while `@_objcImplementation @_cdecl` is very new.
2024-03-27 14:29:57 -07:00
Doug Gregor
bbfdf7b36a Merge pull request #72470 from DougGregor/dynamic-suppressible-protocols
Metadata and runtime support for suppressible protocol requirements
2024-03-27 11:49:00 -07:00
Doug Gregor
11774e5d17 [Runtime] Check function types against suppressible protocols
Form a set of suppressed protocols for a function type based on
the extended flags (where future compilers can start recording
suppressible protocols) and the existing "noescape" bit. Compare
that against the "ignored" suppressible protocol requirements, as we
do for other types.

This involves a behavior change if any client has managed to evade the
static checking for noescape function types, but it's unlikely that
existing code has done so (and it was unsafe anyway).
2024-03-22 07:45:50 -07:00
Doug Gregor
5b020068c5 Extend runtime checking for suppressible protocols
Add more runtime support for checking suppressible protocol requirements:
* Parameter packs now check all of the arguments appropriately
* Most structural types now implement checking (these are hard to test).
2024-03-21 19:22:28 -07:00
Doug Gregor
b167eece42 Metadata and runtime support for suppressible protocol requirements
Introduce metadata and runtime support for describing conformances to
"suppressible" protocols such as `Copyable`. The metadata changes occur
in several different places:

* Context descriptors gain a flag bit to indicate when the type itself has
  suppressed one or more suppressible protocols (e.g., it is `~Copyable`).
  When the bit is set, the context will have a trailing
  `SuppressibleProtocolSet`, a 16-bit bitfield that records one bit for
  each suppressed protocol. Types with no suppressed conformances will
  leave the bit unset (so the metadata is unchanged), and older runtimes
  don't look at the bit, so they will ignore the extra data.
* Generic context descriptors gain a flag bit to indicate when the type
  has conditional conformances to suppressible protocols. When set,
  there will be trailing metadata containing another
  `SuppressibleProtocolSet` (a subset of the one in the main context
  descriptor) indicating which suppressible protocols have conditional
  conformances, followed by the actual lists of generic requirements
  for each of the conditional conformances. Again, if there are no
  conditional conformances to suppressible protocols, the bit won't be
  set. Old runtimes ignore the bit and any trailing metadata.
* Generic requirements get a new "kind", which provides an ignored
  protocol set (another `SuppressibleProtocolSet`) stating which
  suppressible protocols should *not* be checked for the subject type
  of the generic requirement. For example, this encodes a requirement
  like `T: ~Copyable`. These generic requirements can occur anywhere
  that there is a generic requirement list, e.g., conditional
  conformances and extended existentials. Older runtimes handle unknown
  generic requirement kinds by stating that the requirement isn't
  satisfied.

Extend the runtime to perform checking of the suppressible
conformances on generic arguments as part of checking generic
requirements. This checking follows the defaults of the language, which
is that every generic argument must conform to each of the suppressible
protocols unless there is an explicit generic requirement that states
which suppressible protocols to ignore. Thus, a generic parameter list
`<T, Y where T: ~Escapable>` will check that `T` is `Copyable` but
not that it is `Escapable`, and check that `U` is both `Copyable` and
`Escapable`. To implement this, we collect the ignored protocol sets
from these suppressed requirements while processing the generic
requirements, then check all of the generic arguments against any
conformances not suppressed.

Answering the actual question "does `X` conform to `Copyable`?" (for
any suppressible protocol) looks at the context descriptor metadata to
answer the question, e.g.,

1. If there is no "suppressed protocol set", then the type conforms.
This covers types that haven't suppressed any conformances, including
all types that predate noncopyable generics.
2. If the suppressed protocol set doesn't contain `Copyable`, then the
type conforms.
3. If the type is generic and has a conditional conformance to
`Copyable`, evaluate the generic requirements for that conditional
conformance to answer whether it conforms.

The procedure above handles the bits of a `SuppressibleProtocolSet`
opaquely, with no mapping down to specific protocols. Therefore, the
same implementation will work even with future suppressible protocols,
including back deployment.

The end result of this is that we can dynamically evaluate conditional
conformances to protocols that depend on conformances to suppressible
protocols.

Implements rdar://123466649.
2024-03-21 14:57:47 -07:00
Pavel Yaskevich
e424ede877 Merge pull request #72440 from xedin/rdar-123810657-runtime-gate
[Tests] NFC: Gate preconcurrency conformances runtime test on presenc…
2024-03-20 10:35:58 -07:00
Joe Groff
dc4c874c49 Merge pull request #72452 from jckarter/pruned-liveness-try-apply-conditional-def
FieldSensitivePrunedLiveness: Handle conditionality of `try_apply` defs.
2024-03-20 07:43:42 -07:00
Joe Groff
1166f2e0d8 FieldSensitivePrunedLiveness: Handle conditionality of try_apply defs.
A `try_apply` with indirect out arguments is only a def for those arguments on
the success path. Model this by sinking the def-ness of the instruction into the
success branch of the try_apply, and introducing a new `DeadToLiveEdge` mode for
block liveness which stops propagation of use-before-def conditions into the
block that introduced the def. Fixes rdar://118567869.
2024-03-19 22:46:26 -07:00
Pavel Yaskevich
34f96242fe [Tests] NFC: Gate preconcurrency conformances runtime test on presence of concurrency runtime
Resolves: rdar://123810657
2024-03-19 15:00:01 -07:00
Nate Chandler
9bc5ef1108 [Test] Update test and target to 5.6 aligned.
The test emits a different function based on deployment target.  And
that different function results in different behavior.  But some
platforms don't have old enough deployment targets to use the function
for older platforms.  So just target newer platforms.

rdar://124700033
2024-03-15 12:09:08 -07:00
Tim Kientzle
c63d181b25 Add some progress info to make failures here easier to understand 2024-03-15 10:55:40 -07:00
Nate Chandler
2f83828481 [Test] NoncopyablePartialConsumption: Added test. 2024-03-14 07:26:32 -07:00
Nate Chandler
a14b3fa7f7 [Gardening] Test: Renamed test file. 2024-03-14 07:26:32 -07:00
Nate Chandler
c612f3c33b [Test] Added test for value partial consumption.
This test didn't compile without the fix to CanonicalizeInstruction.
2024-03-13 17:42:33 -07:00
Joe Groff
5a326a1465 Merge pull request #72193 from jckarter/memory-lifetime-verifier-nondestructive-enum-addr
MemoryLifetimeVerifier: Treat only destructive enum_data_addr insns as writes.
2024-03-11 21:16:59 -07:00
Joe Groff
2722f1adcd MemoryLifetimeVerifier: Treat only destructive enum_data_addr insns as writes.
It is ok to project the data from an enum in cases where we know spare bit
packing can never happen. Fixes rdar://124240723.
2024-03-11 09:49:57 -07:00
Kavon Farvardin
4e62b21f73 Merge pull request #72204 from kavon/ncgenerics-fixes-3-8-2024
NCGenerics: More Builtin fixes and casting test fix
2024-03-08 20:31:14 -08:00
Pavel Yaskevich
b17f0b534c Merge pull request #71855 from xedin/fix-sendable-keypath-conformance-issues
[AST] Special handling for existentials with superclass and marker pr…
2024-03-08 13:06:01 -08:00
Kavon Farvardin
f226f6c1d8 NCGenerics: fix mistake in casting test 2024-03-08 10:58:15 -08:00
Kavon Farvardin
0275f35f74 add missing REQUIRES: executable_test 2024-03-07 15:41:03 -08:00
Pavel Yaskevich
0ab7e12aa2 [IRGen] Strip marker protocols from type symbol's mangling 2024-03-07 13:31:39 -08:00
Kavon Farvardin
d5ca8ee13e Merge pull request #72137 from kavon/ncgenerics-conditional-conformances
GenProto: drop conditional Copyable reqs from protocol conformance descriptors
2024-03-07 11:14:51 -08:00
Nate Chandler
fb0ae6ecbb [NoncopyablePartialConsumption] Allow consume.
Allow a noncopyable value to be partially consumed via the `consume`
keyword.
2024-03-06 18:58:38 -08:00
nate-chandler
567c6adf3f Merge pull request #72131 from nate-chandler/rdar124165278
[Test] Added executable_test requirement.
2024-03-06 17:41:13 -08:00
Kavon Farvardin
49fdf19b10 NCGenerics: add casting test 2024-03-06 17:06:35 -08:00
Mike Ash
4d484c9f12 Merge pull request #71993 from mikeash/fix-32-bit-unowned-refcount-overflow
[Runtime] Fix strong and unowned refcount overflow on 32-bit.
2024-03-06 17:54:26 -05:00
Nate Chandler
008295315a [Test] Added executable_test requirement.
rdar://124165278
2024-03-06 14:42:13 -08:00
Kavon Farvardin
108fd05619 flesh out more of Swiftskell test 2024-03-05 21:50:19 -08:00
Alejandro Alonso
cccd1b4f43 Merge pull request #72024 from belkadan/protocol-extension-default-arguments-test-case
Test existing behavior of default arguments in protocol extensions
2024-03-04 23:28:46 -08:00
Nate Chandler
fb760f4846 [IRGen] Require same copyability to reuse layout.
Previously, in place of the layout of an aggregate which consisted of
exactly one field, the layout of that one field would be used.  This is
incorrect in the case that the aggregate is noncopyable but the field is
not.  Here, it's checked that the move-only-ness of the field matches
the move-only-ness of the aggregate.

rdar://123197751
2024-03-04 14:35:05 -08:00
Mike Ash
13b58a0b5c [Runtime] Fix strong and unowned refcount overflow on 32-bit.
Fix overflow detection on unowned refcounts so that we create a side table when incrementing from 126. Implement strong refcount overflow to the side table.

The unowned refcount is never supposed to be 127, because that (sometimes) represents the immortal refcount. We attempt to detect that by checking newValue == Offsets::UnownedRefCountMask, but the mask is shifted so that condition is never true. We managed to hit the side table case when incrementing from 127, because it looks like the immortal case. But that broke when we fixed immortal side table initialization in b41079a8f54ae2d61c68cdda46c74232084af020. With that change, we now create an immortal side table when overflowing the unowned refcount, then try to increment the unowned refcount in that immortal side table, which traps.

rdar://123788910
2024-03-01 09:42:45 -05:00
Jordan Rose
475b8ec455 Test existing behavior of default arguments in protocol extensions 2024-02-29 22:19:47 -08:00
Pavel Yaskevich
b3d7a1d0f5 [Tests] NFC: Disable @preconcurrency conformances executable test on backdeployment runtime 2024-02-29 09:16:40 -08:00
Slava Pestov
48f46f0e3c Sema: Redo the normalization in TypeResolver::resolveCompositionType() 2024-02-24 07:25:59 -05:00
Slava Pestov
780c4e9a6d Sema: Fix isValidKeyPathDynamicMemberLookup() for noncopyable generics 2024-02-24 07:25:59 -05:00