Commit Graph

2441 Commits

Author SHA1 Message Date
nate-chandler
01bce39100 Merge pull request #71418 from nate-chandler/nfc/20240206/1/rename-inst-class
[NFC] SIL: Renamed SpecifyTestInst.
2024-02-06 22:02:05 -08:00
Nate Chandler
b535725647 [NFC] SIL: Renamed SpecifyTestInst.
The instruction's spelling was changed to `specify_test` but the class
name wasn't updated from `TestSpecificationInst`.  Update it here.
2024-02-06 16:29:09 -08:00
Ellie Shin
e38bc9756c Merge pull request #71083 from apple/es-sil-pkg
Support a package SILLinkage
2024-02-07 09:10:13 +09:00
Slava Pestov
d46bd335de Merge pull request #71371 from slavapestov/ncgenerics-fixes-3
Non-copyable generics fixes, part 3
2024-02-06 08:35:07 -05:00
Hamish Knight
7b012d825c Merge pull request #70600 from hamishknight/postal-service
[ASTWalker] Continue post-walking with `Action::SkipChildren`
2024-02-06 10:24:38 +00:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Slava Pestov
81027cff23 SIL: Drop conformances to Copyable and Escapable from substitution signature 2024-02-05 18:43:06 -05:00
Hamish Knight
15fa06dd37 [ASTWalker] Cleanup some cases manually doing post-walks
We can replace these with `Action::SkipChildren`.
2024-02-05 15:27:26 +00:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Erik Eckstein
86f23b089f SIL: add the [perf_constraint] flag in SILFunction
Specifies that the optimizer and IRGen must not add runtime calls which are not in the function originally.
This attribute is set for functions with performance constraints or functions which are called from functions with performance.
2024-02-05 12:26:30 +01:00
Rintaro Ishizaki
b839718351 [AST] Use scoped enum for attribute kinds
Align with other kind enum e.g. DeclKind.
2024-02-02 09:36:48 -08:00
nate-chandler
c0ad612d9a Merge pull request #71335 from nate-chandler/bitwise-copyable/sil-token
[BitwiseCopyable] Permit SILTokenType's nonconformance.
2024-02-02 06:58:39 -08:00
Slava Pestov
066cb8b9a4 SIL: One more SILPrinter fix 2024-02-01 23:35:33 -05:00
Nate Chandler
c148e11741 [TypeLowering] Allow SILToken to !BitwiseCopyable.
Like `ModuleType`, there's no reason to conform this flavor of trivial
type to `BitwiseCopyable`.  So permit it during verification.
2024-02-01 18:08:23 -08:00
Nate Chandler
159571c5ee [NFC] TypeLowering: Tweak verification.
Improved comments, and simplified assertion while making more stringent.
2024-02-01 18:06:45 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
nate-chandler
902a22d94a Merge pull request #71298 from nate-chandler/bitwise-copyable/remove-unchecked
[BitwiseCopyable] Remove @unchecked behavior.
2024-02-01 03:21:26 -08:00
Slava Pestov
af3ab14986 SILGen: Clean up substitution map construction to deal with Copyable 2024-01-31 21:55:52 -05:00
Slava Pestov
094328ddab SIL: Add some assertions 2024-01-31 21:55:52 -05:00
Nate Chandler
990c318941 Revert "NFC: [TypeLowering] Handle @unchecked BC fields."
This reverts commit 0ae0fdc3b1.
2024-01-31 17:11:55 -08:00
Slava Pestov
45f31b4516 AST: Refactor ASTPrinter to use getRequirementsWithInverses() 2024-01-31 18:40:35 -05:00
Erik Eckstein
b3e5f07a99 SILFunction: don't preserve specialized functions for the debugger 2024-01-31 17:16:12 +01:00
nate-chandler
a43faf89c8 Merge pull request #71242 from nate-chandler/bitwise-copyable/not-for-unchecked
[BitwiseCopyable] Don't derive on @unchecked field
2024-01-31 05:55:38 -08:00
Nate Chandler
0ae0fdc3b1 NFC: [TypeLowering] Handle @unchecked BC fields.
The appearance of a field whose type's conformance to BitwiseCopyable is
@unchecked permits the type not to conform.
2024-01-30 11:21:40 -08:00
Andrew Trick
13db95eac3 BridgedASTType::isEscapable 2024-01-30 08:38:57 -08:00
Andrew Trick
f5e5789984 Merge pull request #71206 from meg-gupta/lifetimedepsil
Lower lifetime dependence info into SIL and infer when absent
2024-01-29 19:56:25 -08:00
Doug Gregor
20b72a19f2 Merge pull request #71219 from DougGregor/abstraction-pattern-typed-throws-bad-assert
[Abstraction pattern] Eliminate unnecessary assertion for typed throws
2024-01-29 16:48:05 -08:00
Meghana Gupta
d598d0440d [NFC] Reorganize lifetime dependence utilities 2024-01-29 15:24:09 -08:00
Doug Gregor
2cef4b97b0 [Abstraction pattern] Eliminate unnecessary assertion for typed throws
Abstraction patterns can handle conversions involving typed throws
nowdays. Remove the assertion, fixing rdar://121617307.
2024-01-29 12:04:19 -08:00
Meghana Gupta
24d6a2953b Lower lifetime dependence info into SIL types 2024-01-29 11:41:41 -08:00
Arnold Schwaighofer
edd7eaa0d7 OSLog: os_log strings should be in the __oslogstring section on machO
rdar://121384422
2024-01-26 08:30:56 -08:00
John McCall
b0fb03d8c7 Create a uniform representation for function type isolation.
Not quite NFC because apparently the representation bleeds into what's
accepted in some situations where we're supposed to be warning about
conflicts and then making an arbitrary choice.  But what we're doing
is nonsense, so we definitely need to break behavior here.

This is setting up for isolated(any) and isolated(caller).  I tried
to keep that out of the patch as much as possible, though.
2024-01-25 22:11:01 -05:00
Kavon Farvardin
b8cd7effeb Merge pull request #70866 from kavon/ncgenerics-stdlib-building-v4
Build Stdlib with Noncopyable Generics (Part 4)
2024-01-25 07:09:38 -08:00
Meghana Gupta
c3c7465a44 Merge pull request #71125 from meg-gupta/rdar121485860
Don't duplicate builtin "once"
2024-01-25 01:49:15 -08:00
Meghana Gupta
1369043c6c Don't duplicate builtin "once"
Fixes rdar://121485860
2024-01-24 14:40:43 -08:00
Kavon Farvardin
cf42840bf8 NCGenerics: isMoveOnly and reference ownership
ReferenceStorageType can only contain a type that is class-like, like a
SILBox or a class-constrained existential, etc.

While classes do not and are not planned to officially support being
noncopyable, we do still have a lingering experiemental feature that
allows classes to be marked `@_moveOnly`. Thus, the best way to handle
queries about a `ReferenceStorageType` being move-only or noncopyable is
 to check whether the referent is.
2024-01-23 22:42:38 -08:00
Kavon Farvardin
107475b224 SILType: Avoid asking ASTType if it is Noncopyable
It's better to ask SILType if it is MoveOnly than go to the AST type and
 ask if it is noncopyable, because some types in SIL do not have a
 well-defined notion of conformance in the AST.
2024-01-23 22:42:38 -08:00
Kavon Farvardin
a72925248b [NCGenerics] fix a few isNoncopyable calls
These calls were being made on types either with a type parameter, or a
SIL-only type that doesn't actually have conformances.

In such cases, it's better to use SILType's move-only query methods.
2024-01-23 22:42:38 -08:00
Kavon Farvardin
58480c3be1 [NCGenerics] provide namespace for CanBeInvertible 2024-01-23 22:42:38 -08:00
Kavon Farvardin
b4985f7fde [NFC] replace canBeNoncopyable
First, "can have an absence of Copyable" is a rather confusing notion,
so the query is flipped to "can be Copyable". Next, it's more robust to
ask if a conformance exists for the TypeDecl to answer that question,
rather than trying to replicate what happens within that conformance
lookup.

Also renames `TypeDecl::isEscapable` to match.
2024-01-23 22:42:38 -08:00
Michael Gottesman
6f3d45219a [ast] Represent a parameter's isolation at the SIL level.
I did this by adding flag on SILParamInfo.

rdar://121387872
2024-01-23 15:20:22 -08:00
Ellie Shin
0e8ffef6cd Merge pull request #70897 from apple/es-pkg-fx
Change effectiveAccessLevel of `package` decls from `public` to `package`.
2024-01-24 07:35:13 +09:00
Doug Gregor
8c448a5b21 Merge pull request #71043 from DougGregor/distributed-actor-to-actor
Introduce a builtin and API for getting the local actor from a distributed one
2024-01-23 13:02:04 -08:00
Ellie Shin
7267d58e6a updates 2024-01-23 11:02:49 -08:00
Ellie Shin
ab3b5add3a Currently decls defined with package access level have a different
access level for optimization: `public`. It requires an extra check for
the actual access level that was declared when determining serialization
since the behavior should be different.

This PR sets its effective access level to `package` as originally defined,
updates call sites to make appropriate acces level comparisons, and removes
`package` specific checks.
2024-01-23 11:02:49 -08:00
Andrew Trick
246da83f0f Merge pull request #71055 from atrick/lifetime-dependence
Lifetime dependence utilities
2024-01-23 08:19:24 -08:00
Andrew Trick
37171e698a Handle mark_dependence [nonescaping] like a borrowing instruction. 2024-01-22 23:57:03 -08:00
Doug Gregor
97ea19d191 Introduce a builtin and API for getting the local actor from a distributed one
When an actual instance of a distributed actor is on the local node, it is
has the capabilities of `Actor`. This isn't expressible directly in the type
system, because not all `DistributedActor`s are `Actor`s, nor is the
opposite true.

Instead, provide an API `DistributedActor.asLocalActor` that can only
be executed when the distributed actor is known to be local (because
this API is not itself `distributed`), and produces an existential
`any Actor` referencing that actor. The resulting existential value
carries with it a special witness table that adapts any type
conforming to the DistributedActor protocol into a type that conforms
to the Actor protocol. It is "as if" one had written something like this:

    extension DistributedActor: Actor { }

which, of course, is not permitted in the language. Nonetheless, we
lovingly craft such a witness table:

* The "type" being extended is represented as an extension context,
rather than as a type context. This hasn't been done before, all Swift
runtimes support it uniformly.

* A special witness is provided in the Distributed library to implement
the `Actor.unownedExecutor` operation. This witness back-deploys to the
Swift version were distributed actors were introduced (5.7). On Swift
5.9 runtimes (and newer), it will use
`DistributedActor.unownedExecutor` to support custom executors.

* The conformance of `Self: DistributedActor` is represented as a
conditional requirement, which gets satisfied by the witness table
that makes the type a `DistributedActor`. This makes the special
witness work.

* The witness table is *not* visible via any of the normal runtime
lookup tables, because doing so would allow any
`DistributedActor`-conforming type to conform to `Actor`, which would
break the safety model.

* The witness table is emitted on demand in any client that needs it.
In back-deployment configurations, there may be several witness tables
for the same concrete distributed actor conforming to `Actor`.
However, this duplication can only be observed under fairly extreme
circumstances (where one is opening the returned existential and
instantiating generic types with the distributed actor type as an
`Actor`, then performing dynamic type equivalence checks), and will
not be present with a new Swift runtime.

All of these tricks together mean that we need no runtime changes, and
`asLocalActor` back-deploys as far as distributed actors, allowing it's
use in `#isolation` and the async for...in loop.
2024-01-22 17:27:31 -08:00
Joe Groff
47ee847ceb Merge pull request #71025 from jckarter/borrowing-switch-1
SILGen: Always match noncopyable values by borrowing.
2024-01-22 15:02:26 -08:00