Skip to content

Commit 95d2bac

Browse files
authored
Merge pull request #4362 from swiftwasm/katei/merge-main-2022-03-11
Merge main 2022-03-11
2 parents 3be7ec1 + 6309754 commit 95d2bac

File tree

345 files changed

+4644
-3277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+4644
-3277
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ jobs:
129129
restore-keys: |
130130
${{ matrix.target }}-sccache-v11-
131131
132-
- name: Clean stdlib build directory
132+
- name: Clean build directory
133133
if: ${{ matrix.clean_build_dir }}
134134
run: |
135135
rm -rf ${{ github.workspace }}/target-build \
136136
${{ github.workspace }}/host-build \
137+
${{ github.workspace }}/build-sdk \
137138
${{ github.workspace }}/host-toolchain-sdk \
138139
${{ github.workspace }}/dist-toolchain-sdk
139140

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ Types
635635
type ::= protocol-list 'p' // existential type
636636
type ::= protocol-list superclass 'Xc' // existential type with superclass
637637
type ::= protocol-list 'Xl' // existential type with AnyObject
638+
type ::= protocol-list 'y' (type* '_')* type* retroactive-conformance* 'Xp' // parameterized protocol type
638639
type ::= type-list 't' // tuple
639640
type ::= type generic-signature 'u' // generic type
640641
type ::= 'x' // generic param, depth=0, idx=0

docs/CppInteropability/GettingStartedWithC++Interop.md renamed to docs/CppInteroperability/GettingStartedWithC++Interop.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,23 @@ struct ContentView: View {
5959
```
6060

6161
```
62-
//In Cxx.cpp
62+
//In Cxx.hpp
63+
64+
#ifndef Cxx_hpp
65+
#define Cxx_hpp
6366
64-
#include "Cxx.hpp"
6567
int cxxFunction(int n) {
6668
return n;
6769
}
68-
70+
#endif
6971
```
7072

7173
```
72-
//In Cxx.hpp
73-
74-
#ifndef Cxx_hpp
75-
#define Cxx_hpp
74+
//In Cxx.cpp
7675
76+
#include "Cxx.hpp"
7777
int cxxFunction(int n);
7878
79-
#endif
8079
8180
```
8281

@@ -198,7 +197,7 @@ CxxInterop.main()
198197
199198
```
200199

201-
- In your projects direcetoy, run `cmake` to generate the systems build files
200+
- In your project's directory, run `cmake` to generate the systems build files
202201

203202
- To generate an Xcode project run `cmake -GXcode`
204203
- To generate with Ninja run `cmake -GNinja`

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,10 +830,20 @@ the compiler.
830830

831831
This `async` function uses the pre-SE-0338 semantics of unsafely inheriting the caller's executor. This is an underscored feature because the right way of inheriting an executor is to pass in the required executor and switch to it. Unfortunately, there are functions in the standard library which need to inherit their caller's executor but cannot change their ABI because they were not defined as `@_alwaysEmitIntoClient` in the initial release.
832832

833+
833834
## `@_spi_available(platform, version)`
834835

835836
Like `@available`, this attribute indicates a decl is available only as an SPI.
836837
This implies several behavioral changes comparing to regular `@available`:
837838
1. Type checker diagnoses when a client accidently exposes such a symbol in library APIs.
838839
2. When emitting public interfaces, `@_spi_available` is printed as `@available(platform, unavailable)`.
839840
3. ClangImporter imports ObjC macros `SPI_AVAILABLE` and `__SPI_AVAILABLE` to this attribute.
841+
842+
843+
## `_local`
844+
845+
A distributed actor can be marked as "known to be local" which allows avoiding
846+
the distributed actor isolation checks. This is used for things like `whenLocal`
847+
where the actor passed to the closure is known-to-be-local, and similarly a
848+
`self` of obtained from an _isolated_ function inside a distributed actor is
849+
also guaranteed to be local by construction.

include/swift/AST/ASTContext.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,11 @@ class ASTContext final {
658658

659659
/// Retrieve the declaration of DistributedActorSystem.make().
660660
///
661-
/// \param actorOrSystem distributed actor or actor system to get the
662-
/// remoteCall function for. Since the method we're looking for is an ad-hoc
663-
/// requirement, a specific type MUST be passed here as it is not possible
664-
/// to obtain the decl from just the `DistributedActorSystem` protocol type.
661+
/// \param thunk the function from which we'll be invoking things on the obtained
662+
/// actor system; This way we'll always get the right type, taking care of any
663+
/// where clauses etc.
665664
FuncDecl *getMakeInvocationEncoderOnDistributedActorSystem(
666-
NominalTypeDecl *actorOrSystem) const;
665+
AbstractFunctionDecl *thunk) const;
667666

668667
// Retrieve the declaration of
669668
// DistributedInvocationEncoder.recordGenericSubstitution(_:).

include/swift/AST/ASTDemangler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class ASTBuilder {
112112
bool isClassBound,
113113
bool forRequirement = true);
114114

115+
Type createParameterizedProtocolType(Type base, ArrayRef<Type> args);
116+
115117
Type createExistentialMetatypeType(Type instance,
116118
Optional<Demangle::ImplMetatypeRepresentation> repr=None);
117119

include/swift/AST/Attr.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ TYPE_ATTR(async)
5757
TYPE_ATTR(Sendable)
5858
TYPE_ATTR(unchecked)
5959
TYPE_ATTR(_typeSequence)
60+
TYPE_ATTR(_local)
6061

6162
// SIL-specific attributes
6263
TYPE_ATTR(block_storage)
@@ -720,6 +721,13 @@ DECL_ATTR(_backDeploy, BackDeploy,
720721
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
721722
129)
722723

724+
CONTEXTUAL_SIMPLE_DECL_ATTR(_local, KnownToBeLocal,
725+
DeclModifier | OnFunc | OnParam | OnVar |
726+
DistributedOnly |
727+
ABIBreakingToAdd | ABIBreakingToRemove |
728+
APIBreakingToAdd | APIBreakingToRemove,
729+
130)
730+
723731
// If you're adding a new underscored attribute here, please document it in
724732
// docs/ReferenceGuides/UnderscoredAttributes.md.
725733

include/swift/AST/Decl.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,8 +2693,7 @@ class ValueDecl : public Decl {
26932693
/// property, or the uncurried result type of a method/subscript, e.g.
26942694
/// '() -> () -> Self'.
26952695
GenericParameterReferenceInfo findExistentialSelfReferences(
2696-
Type baseTy, const DeclContext *useDC,
2697-
bool treatNonResultCovariantSelfAsInvariant) const;
2696+
Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const;
26982697
};
26992698

27002699
/// This is a common base class for declarations which declare a type.
@@ -4491,10 +4490,6 @@ class ProtocolDecl final : public NominalTypeDecl {
44914490
/// semantics but has no corresponding witness table.
44924491
bool isMarkerProtocol() const;
44934492

4494-
/// Is a protocol that can only be conformed by distributed actors.
4495-
/// Such protocols are allowed to contain distributed functions.
4496-
bool inheritsFromDistributedActor() const;
4497-
44984493
private:
44994494
void computeKnownProtocolKind() const;
45004495

@@ -5255,6 +5250,10 @@ class VarDecl : public AbstractStorageDecl {
52555250
/// Does this have a 'distributed' modifier?
52565251
bool isDistributed() const;
52575252

5253+
/// Is this var known to be a "local" distributed actor,
5254+
/// if so the implicit throwing ans some isolation checks can be skipped.
5255+
bool isKnownToBeLocal() const;
5256+
52585257
/// Is this a stored property that will _not_ trigger any user-defined code
52595258
/// upon any kind of access?
52605259
bool isOrdinaryStoredProperty() const;
@@ -6309,6 +6308,13 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
63096308
/// Returns 'true' if the function is distributed.
63106309
bool isDistributed() const;
63116310

6311+
/// For a 'distributed' target (func or computed property),
6312+
/// get the 'thunk' responsible for performing the 'remoteCall'.
6313+
///
6314+
/// \return the synthesized thunk, or null if the base of the call has
6315+
/// diagnosed errors during type checking.
6316+
FuncDecl *getDistributedThunk() const;
6317+
63126318
/// Returns 'true' if the function has the @c @_backDeploy attribute.
63136319
bool isBackDeployed() const;
63146320

@@ -6456,6 +6462,16 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
64566462
/// 'DistributedActorSystem' protocol.
64576463
bool isDistributedActorSystemRemoteCall(bool isVoidReturn) const;
64586464

6465+
/// Determines whether this function is a 'makeInvocationEncoder' function,
6466+
/// which is used as ad-hoc protocol requirement by the
6467+
/// 'DistributedActorSystem' protocol.
6468+
bool isDistributedActorSystemMakeInvocationEncoder() const;
6469+
6470+
/// Determines if this function is a 'recordGenericSubstitution' function,
6471+
/// which is used as ad-hoc protocol requirement by the
6472+
/// 'DistributedTargetInvocationEncoder' protocol.
6473+
bool isDistributedTargetInvocationEncoderRecordGenericSubstitution() const;
6474+
64596475
/// Determines if this function is a 'recordArgument' function,
64606476
/// which is used as ad-hoc protocol requirement by the
64616477
/// 'DistributedTargetInvocationEncoder' protocol.

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,46 +1561,16 @@ ERROR(attr_availability_duplicate,none,
15611561
(StringRef, StringRef))
15621562

15631563
// originallyDefinedIn
1564-
// FIXME(backDeploy): Refactor to share with back deployment attr
15651564
ERROR(originally_defined_in_missing_rparen,none,
15661565
"expected ')' in @_originallyDefinedIn argument list", ())
15671566

1568-
// FIXME(backDeploy): Refactor to share with back deployment attr
1569-
ERROR(originally_defined_in_unrecognized_platform,none,
1570-
"unrecognized platform name in @_originallyDefinedIn argument list", ())
1571-
1572-
// FIXME: This is unused and can be removed
1573-
ERROR(originally_defined_in_unrecognized_property,none,
1574-
"unrecognized property in @_originallyDefinedIn argument list", ())
1575-
15761567
ERROR(originally_defined_in_need_original_module_name,none,
15771568
"expected 'module: \"original\"' in the first argument to "
15781569
"@_originallyDefinedIn", ())
15791570

15801571
ERROR(originally_defined_in_need_nonempty_module_name,none,
15811572
"original module name cannot be empty in @_originallyDefinedIn", ())
15821573

1583-
// FIXME(backDeploy): Refactor to share with back deployment attr
1584-
ERROR(originally_defined_in_need_platform_version,none,
1585-
"expected at least one platform version in @_originallyDefinedIn", ())
1586-
1587-
// FIXME(backDeploy): Refactor to share with back deployment attr
1588-
WARNING(originally_defined_in_major_minor_only,none,
1589-
"@_originallyDefinedIn only uses major and minor version number", ())
1590-
1591-
// FIXME(backDeploy): Refactor to share with back deployment attr
1592-
WARNING(originally_defined_in_missing_platform_name,none,
1593-
"* as platform name has no effect", ())
1594-
1595-
// FIXME(backDeploy): Refactor to share with back deployment attr
1596-
WARNING(originally_defined_in_swift_version, none,
1597-
"Swift language version checks has no effect "
1598-
"in @_originallyDefinedIn", ())
1599-
1600-
WARNING(originally_defined_in_package_description, none,
1601-
"PackageDescription version checks has no effect "
1602-
"in @_originallyDefinedIn", ())
1603-
16041574
// backDeploy
16051575
ERROR(attr_back_deploy_missing_rparen,none,
16061576
"expected ')' in '@_backDeploy' argument list", ())

include/swift/AST/DiagnosticsSema.def

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,8 +1935,8 @@ WARNING(type_does_not_conform_swiftui_warning,none,
19351935

19361936
ERROR(non_final_class_cannot_conform_to_self_same_type,none,
19371937
"non-final class %0 cannot safely conform to protocol %1, "
1938-
"which requires that 'Self' is exactly equal to %2",
1939-
(Type, Type, Type))
1938+
"which requires that %2 %select{is exactly equal to|inherit from}3 %4",
1939+
(Type, Type, Type, unsigned, Type))
19401940

19411941
ERROR(cannot_use_nil_with_this_type,none,
19421942
"'nil' cannot be used in context expecting type %0", (Type))
@@ -4495,6 +4495,13 @@ ERROR(actor_inheritance,none,
44954495
ERROR(actor_protocol_illegal_inheritance,none,
44964496
"non-actor type %0 cannot conform to the 'Actor' protocol",
44974497
(DeclName))
4498+
ERROR(distributed_actor_conformance_missing_system_type,none,
4499+
"distributed actor %0 does not declare ActorSystem it can be used with.",
4500+
(DeclName))
4501+
NOTE(note_distributed_actor_system_can_be_defined_using_defaultdistributedactorsystem,none,
4502+
"you can provide a module-wide default actor system by declaring:\n"
4503+
"typealias DefaultDistributedActorSystem = <#ConcreteActorSystem#>\n",
4504+
())
44984505
ERROR(distributed_actor_protocol_illegal_inheritance,none,
44994506
"non-distributed actor type %0 cannot conform to the 'DistributedActor' protocol",
45004507
(DeclName))
@@ -4595,6 +4602,9 @@ NOTE(note_distributed_actor_isolated_method,none,
45954602
ERROR(distributed_actor_isolated_method,none,
45964603
"only 'distributed' instance methods can be called on a potentially remote distributed actor",
45974604
())
4605+
ERROR(distributed_local_cannot_be_used,none,
4606+
"'local' cannot be used in user-defined code currently",
4607+
())
45984608
ERROR(distributed_actor_func_param_not_codable,none,
45994609
"parameter '%0' of type %1 in %2 does not conform to serialization requirement '%3'",
46004610
(StringRef, Type, DescriptiveDeclKind, StringRef))

include/swift/AST/DistributedDecl.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ class DeclContext;
3131
class FuncDecl;
3232
class NominalTypeDecl;
3333

34+
/// Determine the concrete type of 'ActorSystem' as seen from the member.
35+
/// E.g. when in a protocol, and trying to determine what the actor system was
36+
/// constrained to.
37+
///
38+
/// \param member the member from which context the lookup should be performed,
39+
/// e.g. a function or computed property.
40+
/// \return the concrete type of the ActorSystem to be used by this member,
41+
/// or null if no concrete actor system was found.
42+
Type getConcreteReplacementForProtocolActorSystemType(ValueDecl *member);
43+
3444
/// Determine the `ActorSystem` type for the given actor.
3545
Type getDistributedActorSystemType(NominalTypeDecl *actor);
3646

@@ -43,14 +53,12 @@ Type getDistributedActorIDType(NominalTypeDecl *actor);
4353
Type getDistributedSerializationRequirementType(
4454
NominalTypeDecl *nominal, ProtocolDecl *protocol);
4555

46-
///// Determine the serialization requirement for the given actor, actor system
47-
///// or other type that has the SerializationRequirement associated type.
48-
//Type getDistributedSerializationRequirementType(
49-
// NominalTypeDecl *nominal, ProtocolDecl *protocol);
50-
51-
Type getDistributedActorSystemActorIDRequirementType(
52-
NominalTypeDecl *system);
56+
/// Get the specific 'InvocationEncoder' type of a specific distributed actor
57+
/// system.
58+
Type getDistributedActorSystemInvocationEncoderType(NominalTypeDecl *system);
5359

60+
/// Get the 'ActorID' type of a specific distributed actor system.
61+
Type getDistributedActorSystemActorIDRequirementType(NominalTypeDecl *system);
5462

5563
/// Get the specific protocols that the `SerializationRequirement` specifies,
5664
/// and all parameters / return types of distributed targets must conform to.

0 commit comments

Comments
 (0)