Commit Graph

20133 Commits

Author SHA1 Message Date
Johannes Weiss
3f5c3244ce fix GroupInfo.json: was invalid JSON 2024-03-28 13:07:18 +00:00
Allan Shortlidge
590d3353e6 Frontend: Introduce an alias for the IsolatedAny experimental feature.
To preserve compatibility with older compilers that do not allow `IsolatedAny`
to be enabled in production compilers, use an alias experimental feature when
building the stdlib (`IsolatedAny2`).

Also, add `@_allowFeatureSuppression(IsolatedAny)` in a couple spots it was
forgotten.

Partially resolves rdar://125138945
2024-03-27 22:20:50 -07:00
Allan Shortlidge
37034282a1 stdlib: Adopt @_disallowFeatureSuppression(NoncopyableGenerics).
This prevents some re-declaration errors when building the standard library
from its `.swiftinterface` with older compilers.
2024-03-27 22:20:50 -07:00
Allan Shortlidge
2813fbe309 Frontend: Introduce an alias for the NoncopyableGenerics experimental feature.
The `.swiftinterface` of the standard library must remain compatible with some
older compilers. Unfortunately, some of those older compilers do not allow the
experimental feature `NoncopyableGenerics` to be enabled in production. To
allow the stdlib to build with non-copyable generics enabled and still have the
older compilers consume its interface, we have to use a new experimental
feature identifier that they do not know about.

Partially resolves rdar://125138945
2024-03-27 22:20:25 -07:00
Allan Shortlidge
ceee7648ae Merge pull request #72645 from tshortli/async-sequence-condfails
Concurrency: Declare explicit Failure typealiases on AsyncSequence iterators
2024-03-27 22:02:54 -07:00
Allan Shortlidge
9e875f9839 Concurrency: Declare explicit Failure typealiases on AsyncSequence iterators.
Associated type inference ought to take care of providing the `Failure`
typealias for these `AsyncIteratorProtocol` types. However, the inferred
typealias is printed with `@_implements` in the `.swiftinterface`, guarded with
the `$AssociatedTypeImplements` language feature guard, which means older
compilers cannot see the typealias and therefore think the conformance is
incomplete. To make sure the `_Concurrency` module's interface is backward
compatible, we must manually define these typealiases temporarily.

Part of rdar://125138945
2024-03-27 18:09:53 -07:00
Allan Shortlidge
a1dacc12d7 stdlib: Make typed throws ABI placeholders properly @usableFromInline.
Functions that are used in public `@inlinable` function bodies can't be marked
`@_spi` nor can they be made obsolete. Also, they must retain `rethrows` so
that use of these entry points from other `rethrows` functions is accepted.

Builds on https://github.com/apple/swift/pull/72365. Once we no longer have to
support pre-`$TypedThrows` compilers, all of this can be reverted.

Part of rdar://125138945
2024-03-27 14:57:56 -07:00
Alejandro Alonso
8ea3426273 Update comment about arrayDestroy in pointer 2024-03-27 14:02:06 -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
Eric Miotto
0cac358fe5 Do not install binary swiftmodule for Darwin
This is needed to support Apple internal configurations that would fail
consuming such binary swiftmodule (but work as expected when rebuilding
from the swiftinterface).

Addresses rdar://124390643
2024-03-27 10:56:55 -07:00
Kuba (Brecka) Mracek
70d1d998ab Merge pull request #72530 from kubamracek/embedded-add-ivar-destroyers
[embedded] Add IVarDestroyers into class metadata, add support for throws in initializers
2024-03-27 09:12:34 -07:00
Yuta Saito
52e8fbc115 Merge pull request #72345 from kateinoigakukun/katei/has-feature-swiftcall
[embedded] Use `__has_feature(swiftcc)` to detect Swift calling convention
2024-03-27 19:39:25 +09:00
Doug Gregor
cd20dbafbf [Runtime] Don't check suppressible protocols for non-key generic arguments 2024-03-26 21:33:53 -07:00
Kuba Mracek
37d9be636a [embedded] Handle NULL IVarDestroyers, expand test 2024-03-26 21:14:21 -07:00
Kuba Mracek
b8bd832fba [embedded] Add IVarDestroyers into class metadata, add support for throws in initializers 2024-03-26 20:52:17 -07:00
Eric Miotto
649618dc36 Remove duplicate call to install() for stdlib modules
Also amend the installation code handling macCatalyst to match the one
for regular swiftmodules.
2024-03-26 09:48:36 -07:00
Kuba (Brecka) Mracek
c256c1f594 Merge pull request #72563 from kubamracek/embedded-isUniquelyReferenced_native
[embedded] Add swift_isUniquelyReferenced_native into the embedded runtime
2024-03-26 09:16:12 -07:00
Kuba Mracek
8f247e2d36 [embedded] Add swift_isUniquelyReferenced_native into the embedded runtime 2024-03-25 11:51:01 -07:00
Kuba (Brecka) Mracek
89cd62604b Merge pull request #72472 from kubamracek/embedded-keypaths
[embedded] Compile-time (literal) KeyPaths for Embedded Swift
2024-03-25 10:58:51 -07:00
Kuba Mracek
595ea991ce [embedded] Guard @_transparent in UnsafePointer APIs with #if 2024-03-24 18:12:23 -07:00
Karoy Lorentey
70bc1b0da8 Merge pull request #72537 from lorentey/roll-back-most-cxxinterop-changes 2024-03-22 23:35:53 -07:00
Karoy Lorentey
621bd47c86 [cxx-interop] Back out ~Copyable changes for now
Keep the `@_borrowed` attributes on UnsafeCxx[Mutable]Iterator — it appears to be required with the new pointer types. (That’ll need some separate investigation.)

rdar://125146418
2024-03-22 17:58:56 -07:00
Mike Ash
41cd0ead61 Merge pull request #72501 from mikeash/remove-externalgenericmetadatabuilder
[Runtime] Remove ExternalGenericMetadataBuilder.
2024-03-22 16:03:26 -04:00
Karoy Lorentey
3c3ef072e5 Merge pull request #72477 from lorentey/undo-Result.map&.flatMap-generalization
[stdlib] Undo the generalization of `Result.map` & `.flatMap` for now
2024-03-22 12:20:17 -07:00
Ian Anderson
e209442dec Merge pull request #72465 from ian-twilightcoder/float_overlay_in_core
[CMake] Move ClangOverlays (_Builtin_float) to Core
2024-03-22 11:54:50 -07:00
Mike Ash
fe9de7beb5 [Runtime] Fix _swift_validatePrespecializedMetadata when type lookup fails.
When we fail to look up a type by name, we print an error, then try to compare anyway, which crashes. Skip the comparison when that happens.

While we're in there, modify _swift_validatePrespecializedMetadata to be more useful for debugging, by removing the parameters and having it print the results directly.
2024-03-22 13:52:32 -04:00
Doug Gregor
af38d88ba3 Fix typos spotted by code review, thank you! 2024-03-22 08:28:45 -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
Mike Ash
0491192337 [Runtime] Remove ExternalGenericMetadataBuilder. 2024-03-21 17:56:17 -04:00
Yuta Saito
5d55621de3 Merge pull request #71508 from mtj0928/main 2024-03-21 22:39:54 +09:00
Karoy Lorentey
0885068325 [stdlib] Undo the generalization of Result.map & .flatMap for now
We didn’t do this for Optional’s equivalent methods yet, so it seems premature to do it for Result.
2024-03-20 18:42:07 -07:00
Yuta Saito
f4d3ee6a92 [embedded] Use __has_extension(swiftcc) to detect Swift calling convention
This change replaces the use of `__has_feature(swiftasynccc)` with
`__has_extension(swiftcc)` to detect the SwiftCC availability. The former
condition works fine for most platforms that support both SwiftCC and
SwiftAsyncCC or neither, but it fails for WebAssembly, which supports
SwiftCC but not SwiftAsyncCC.

We add `swiftcc` extension to Clang, and use it here.
2024-03-20 23:07:29 +00:00
Kuba Mracek
b642d771be [embedded] Compile-time (literal) KeyPaths for Embedded Swift
Enable KeyPath/AnyKeyPath/PartialKeyPath/WritableKeyPath in Embedded Swift, but
for compile-time use only:

- Add keypath optimizations into the mandatory optimizations pipeline
- Allow keypath optimizations to look through begin_borrow, to make them work
  even in OSSA.
- If a use of a KeyPath doesn't optimize away, diagnose in PerformanceDiagnostics
- Make UnsafePointer.pointer(to:) transparent to allow the keypath optimization
  to happen in the callers of UnsafePointer.pointer(to:).
2024-03-20 15:35:46 -07:00
Ian Anderson
54927e27f4 [CMake] Move ClangOverlays (_Builtin_float) to Core
The _Builtin_float overlay layers under the Libc overlays, and so it needs to be in the core stdlib group.

rdar://125068518
2024-03-20 12:51:40 -07:00
Stephen Canon
d24843eea0 Replace two reduces with explicit loops in SIMD implementations. (#72423)
* Replace two `reduce`s with explicit loops in SIMD implementations.

`reduce` has enough machinery that it pushes us over some inlining thresholds before optimizations happen, resulting in much worse codegen for String breadcrumbs. So a nice pickup there, but also generally applicable to other code as well.
2024-03-20 10:05:35 -04:00
Doug Gregor
f265226550 Merge pull request #72441 from DougGregor/noncopyable-build-cleanup 2024-03-19 19:55:30 -07:00
Doug Gregor
922e3daaea Remove build infrastructure for globally enabling noncopyable types
Now that the compilation model of noncopyable types is enabled everywhere,
and one can enable the feature for specific modules, we no longer need a
separate build-script/CMake option to enable it globally. Remove it all.
2024-03-19 13:35:31 -07:00
Erik Eckstein
f6a28d81b0 stdlib: enable a check for a special case in Array.append(contentsOf:)
The check for the special case if the sequence is an Array was disabled in embedded swift.
It can be enabled because we now remove the cast after specialization.
Saves some code size when appending one array to another array.
2024-03-19 11:58:16 +01:00
Karoy Lorentey
f24e18cb01 Merge pull request #71688 from lorentey/noncopyable-primitives
[stdlib] Start adopting noncopyable generics in the stdlib
2024-03-18 20:45:24 -07:00
Allan Shortlidge
ca925ab379 stdlib: Resolve an un-mutated var warning.
NFC.
2024-03-18 16:33:17 -07:00
Karoy Lorentey
e88750eb0c [stdlib] Apply review notes from @glessard (thanks!) 2024-03-18 11:09:08 -07:00
Guillaume Lessard
3b09ecec74 [gardening] update copyright notice
[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice
2024-03-18 11:08:32 -07:00
Karoy Lorentey
afa459edd8 [stdlib] ManagedBuffer: Add @_preInverseGenerics for $Embedded 2024-03-18 11:08:32 -07:00
Karoy Lorentey
7d7d7aea1b [stdlib] Delete leftover workaround 2024-03-18 11:03:49 -07:00
Karoy Lorentey
b54c2b4d32 [Synchronization] Generalize U[M]BP’s AtomicRepresentable conformance 2024-03-18 11:03:49 -07:00
Karoy Lorentey
cf1c92f461 [stdlib] Remove all new public API for now 2024-03-18 11:03:49 -07:00
Karoy Lorentey
38001ae739 [stdlib] Apply @Azoy’s remaining review notes (thanks!) 2024-03-18 11:03:49 -07:00
Karoy Lorentey
2a1f15587e [stdlib] Use hasFeature(Foo) instead of opaque $Foo syntax 2024-03-18 11:03:49 -07:00