Skip to content

Commit 98e1d85

Browse files
Merge pull request #2859 from swiftwasm/katei/merge-main-2021-03-14
Merge main 2021-03-14
2 parents 09a91d8 + 3c3b19d commit 98e1d85

File tree

245 files changed

+5345
-1992
lines changed

Some content is hidden

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

245 files changed

+5345
-1992
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
| Version | Released | Toolchain |
88
| :--------------------- | :--------- | :---------- |
9+
| [Swift 5.5](#swift-55) | | |
910
| [Swift 5.4](#swift-54) | | |
1011
| [Swift 5.3](#swift-53) | 2020-09-16 | Xcode 12.0 |
1112
| [Swift 5.2](#swift-52) | 2020-03-24 | Xcode 11.4 |
@@ -25,8 +26,8 @@ CHANGELOG
2526

2627
</details>
2728

28-
Swift Next
29-
----------
29+
Swift 5.5
30+
---------
3031

3132
* [SE-0299][]:
3233

@@ -8383,6 +8384,7 @@ Swift 1.0
83838384
[SE-0296]: <https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md>
83848385
[SE-0297]: <https://github.com/apple/swift-evolution/blob/main/proposals/0297-concurrency-objc.md>
83858386
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
8387+
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
83868388

83878389
[SR-75]: <https://bugs.swift.org/browse/SR-75>
83888390
[SR-106]: <https://bugs.swift.org/browse/SR-106>

docs/SIL.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3466,7 +3466,7 @@ debug_value
34663466

34673467
::
34683468

3469-
sil-instruction ::= debug_value sil-operand (',' debug-var-attr)*
3469+
sil-instruction ::= debug_value '[poison]'? sil-operand (',' debug-var-attr)*
34703470

34713471
debug_value %1 : $Int
34723472

@@ -3488,6 +3488,15 @@ variable that is being described, including the name of the
34883488
variable. For function and closure arguments ``argno`` is the number
34893489
of the function argument starting with 1.
34903490

3491+
If the '[poison]' flag is set, then all references within this debug
3492+
value will be overwritten with a sentinel at this point in the
3493+
program. This is used in debug builds when shortening non-trivial
3494+
value lifetimes to ensure the debugger cannot inspect invalid
3495+
memory. `debug_value` instructions with the poison flag are not
3496+
generated until OSSA islowered. They are not expected to be serialized
3497+
within the module, and the pipeline is not expected to do any
3498+
significant code motion after lowering.
3499+
34913500
debug_value_addr
34923501
````````````````
34933502

include/swift/ABI/Metadata.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,26 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
13331333
};
13341334
using ClassMetadata = TargetClassMetadata<InProcess>;
13351335

1336+
/// The structure of class metadata that's compatible with dispatch objects.
1337+
/// This includes Swift heap metadata, followed by the vtable entries that
1338+
/// dispatch expects to see, with padding to place them at the expected offsets.
1339+
template <typename Runtime>
1340+
struct TargetDispatchClassMetadata : public TargetHeapMetadata<Runtime> {
1341+
using DummyVTableCall = void (*)(void);
1342+
1343+
TargetDispatchClassMetadata(MetadataKind Kind,
1344+
DummyVTableCall DummyVTableEntry)
1345+
: TargetHeapMetadata<Runtime>(Kind), DummyVTableEntry(DummyVTableEntry) {}
1346+
1347+
TargetPointer<Runtime, void> Opaque;
1348+
#if SWIFT_OBJC_INTEROP
1349+
TargetPointer<Runtime, void> OpaqueObjC[3];
1350+
#endif
1351+
1352+
TargetSignedPointer<Runtime, DummyVTableCall> DummyVTableEntry;
1353+
};
1354+
using DispatchClassMetadata = TargetDispatchClassMetadata<InProcess>;
1355+
13361356
/// The structure of metadata for heap-allocated local variables.
13371357
/// This is non-type metadata.
13381358
template <typename Runtime>

include/swift/ABI/MetadataKind.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ METADATAKIND(ErrorObject,
8989
METADATAKIND(Task,
9090
2 | MetadataKindIsNonType | MetadataKindIsRuntimePrivate)
9191

92+
/// A non-task async job.
93+
METADATAKIND(Job,
94+
3 | MetadataKindIsNonType | MetadataKindIsRuntimePrivate)
95+
9296
// getEnumeratedMetadataKind assumes that all the enumerated values here
9397
// will be <= LastEnumeratedMetadataKind.
9498

include/swift/ABI/Task.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ struct SwiftError;
3636
class TaskStatusRecord;
3737
class TaskGroup;
3838

39+
extern FullMetadata<DispatchClassMetadata> jobHeapMetadata;
40+
3941
/// A schedulable job.
40-
class alignas(2 * alignof(void*)) Job {
42+
class alignas(2 * alignof(void*)) Job : public HeapObject {
4143
protected:
4244
// Indices into SchedulerPrivate, for use by the runtime.
4345
enum {
@@ -62,13 +64,15 @@ class alignas(2 * alignof(void*)) Job {
6264
TaskContinuationFunction * __ptrauth_swift_task_resume_function ResumeTask;
6365
};
6466

65-
Job(JobFlags flags, JobInvokeFunction *invoke)
66-
: Flags(flags), RunJob(invoke) {
67+
Job(JobFlags flags, JobInvokeFunction *invoke,
68+
const HeapMetadata *metadata = &jobHeapMetadata)
69+
: HeapObject(metadata), Flags(flags), RunJob(invoke) {
6770
assert(!isAsyncTask() && "wrong constructor for a task");
6871
}
6972

70-
Job(JobFlags flags, TaskContinuationFunction *invoke)
71-
: Flags(flags), ResumeTask(invoke) {
73+
Job(JobFlags flags, TaskContinuationFunction *invoke,
74+
const HeapMetadata *metadata = &jobHeapMetadata)
75+
: HeapObject(metadata), Flags(flags), ResumeTask(invoke) {
7276
assert(isAsyncTask() && "wrong constructor for a non-task job");
7377
}
7478

@@ -94,7 +98,7 @@ class alignas(2 * alignof(void*)) Job {
9498
};
9599

96100
// The compiler will eventually assume these.
97-
static_assert(sizeof(Job) == 4 * sizeof(void*),
101+
static_assert(sizeof(Job) == 6 * sizeof(void*),
98102
"Job size is wrong");
99103
static_assert(alignof(Job) == 2 * alignof(void*),
100104
"Job alignment is wrong");
@@ -154,7 +158,7 @@ class ActiveTaskStatus {
154158
///
155159
/// * The future fragment is dynamic in size, based on the future result type
156160
/// it can hold, and thus must be the *last* fragment.
157-
class AsyncTask : public HeapObject, public Job {
161+
class AsyncTask : public Job {
158162
public:
159163
/// The context for resuming the job. When a task is scheduled
160164
/// as a job, the next continuation should be installed as the
@@ -178,7 +182,7 @@ class AsyncTask : public HeapObject, public Job {
178182
AsyncTask(const HeapMetadata *metadata, JobFlags flags,
179183
TaskContinuationFunction *run,
180184
AsyncContext *initialContext)
181-
: HeapObject(metadata), Job(flags, run),
185+
: Job(flags, run, metadata),
182186
ResumeContext(initialContext),
183187
Status(ActiveTaskStatus()),
184188
Local(TaskLocal::Storage()) {
@@ -444,7 +448,6 @@ class AsyncTask : public HeapObject, public Job {
444448
return reinterpret_cast<AsyncTask *&>(
445449
SchedulerPrivate[NextWaitingTaskIndex]);
446450
}
447-
448451
};
449452

450453
// The compiler will eventually assume these.

include/swift/AST/ASTPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace swift {
3737
class NominalTypeDecl;
3838
class ValueDecl;
3939
class SourceLoc;
40-
enum class tok;
40+
enum class tok : uint8_t;
4141
enum class AccessorKind;
4242

4343
/// Describes the context in which a name is being printed, which

include/swift/AST/ActorIsolation.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ class ActorIsolation {
6565
private:
6666
Kind kind;
6767
union {
68-
ClassDecl *actor;
68+
NominalTypeDecl *actor;
6969
Type globalActor;
7070
void *pointer;
7171
};
7272

73-
ActorIsolation(Kind kind, ClassDecl *actor) : kind(kind), actor(actor) { }
73+
ActorIsolation(Kind kind, NominalTypeDecl *actor)
74+
: kind(kind), actor(actor) { }
75+
7476
ActorIsolation(Kind kind, Type globalActor)
7577
: kind(kind), globalActor(globalActor) { }
7678

@@ -93,7 +95,7 @@ class ActorIsolation {
9395
return ActorIsolation(isoKind, nullptr);
9496
}
9597

96-
static ActorIsolation forActorInstance(ClassDecl *actor) {
98+
static ActorIsolation forActorInstance(NominalTypeDecl *actor) {
9799
return ActorIsolation(ActorInstance, actor);
98100
}
99101

@@ -108,7 +110,7 @@ class ActorIsolation {
108110

109111
bool isUnspecified() const { return kind == Unspecified; }
110112

111-
ClassDecl *getActor() const {
113+
NominalTypeDecl *getActor() const {
112114
assert(getKind() == ActorInstance);
113115
return actor;
114116
}

include/swift/AST/Decl.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,6 +3159,11 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
31593159
/// with placeholders for unimportable stored properties.
31603160
ArrayRef<Decl *> getStoredPropertiesAndMissingMemberPlaceholders() const;
31613161

3162+
/// Whether this nominal type qualifies as an actor, meaning that it is
3163+
/// either an actor type or a protocol whose `Self` type conforms to the
3164+
/// `Actor` protocol.
3165+
bool isActor() const;
3166+
31623167
/// Return the range of semantics attributes attached to this NominalTypeDecl.
31633168
auto getSemanticsAttrs() const
31643169
-> decltype(getAttrs().getSemanticsAttrs()) {
@@ -3699,9 +3704,6 @@ class ClassDecl final : public NominalTypeDecl {
36993704
return getForeignClassKind() != ForeignKind::Normal;
37003705
}
37013706

3702-
/// Whether the class is an actor.
3703-
bool isActor() const;
3704-
37053707
/// Whether the class is (known to be) a default actor.
37063708
bool isDefaultActor() const;
37073709

@@ -6975,6 +6977,11 @@ class PrecedenceGroupDecl : public Decl {
69756977
return HigherThanLoc;
69766978
}
69776979

6980+
/// Retrieve the array of \c Relation objects containing those precedence
6981+
/// groups with higher precedence than this precedence group.
6982+
///
6983+
/// The elements of this array may be invalid, in which case they will have
6984+
/// null \c PrecedenceGroupDecl elements.
69786985
ArrayRef<Relation> getHigherThan() const {
69796986
return { getHigherThanBuffer(), NumHigherThan };
69806987
}
@@ -6992,6 +6999,11 @@ class PrecedenceGroupDecl : public Decl {
69926999
return LowerThanLoc;
69937000
}
69947001

7002+
/// Retrieve the array of \c Relation objects containing those precedence
7003+
/// groups with lower precedence than this precedence group.
7004+
///
7005+
/// The elements of this array may be invalid, in which case they will have
7006+
/// null \c PrecedenceGroupDecl elements.
69957007
ArrayRef<Relation> getLowerThan() const {
69967008
return { getLowerThanBuffer(), NumLowerThan };
69977009
}

include/swift/AST/DiagnosticsSema.def

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2964,7 +2964,7 @@ ERROR(dynamic_self_non_method,none,
29642964
"%select{global|local}0 function cannot return 'Self'", (bool))
29652965

29662966
ERROR(dynamic_self_invalid,none,
2967-
"covariant 'Self' can only appear as the possibly optional type of a "
2967+
"covariant 'Self' or 'Self?' can only appear as the type of a "
29682968
"property, subscript or method result; did you mean '%0'?", (StringRef))
29692969
ERROR(dynamic_self_in_mutable_property,none,
29702970
"mutable property cannot have covariant 'Self' type", ())
@@ -2973,11 +2973,14 @@ ERROR(dynamic_self_in_stored_property,none,
29732973
ERROR(dynamic_self_in_mutable_subscript,none,
29742974
"mutable subscript cannot have covariant 'Self' type", ())
29752975
ERROR(dynamic_self_invalid_property,none,
2976-
"covariant 'Self' can only appear at the top level of property type", ())
2976+
"covariant 'Self' or 'Self?' can only appear at the top level of "
2977+
"property type", ())
29772978
ERROR(dynamic_self_invalid_subscript,none,
2978-
"covariant 'Self' can only appear at the top level of subscript element type", ())
2979+
"covariant 'Self' or 'Self?' can only appear at the top level of "
2980+
"subscript element type", ())
29792981
ERROR(dynamic_self_invalid_method,none,
2980-
"covariant 'Self' can only appear at the top level of method result type", ())
2982+
"covariant 'Self' or 'Self?' can only appear at the top level of "
2983+
"method result type", ())
29812984
ERROR(dynamic_self_stored_property_init,none,
29822985
"covariant 'Self' type cannot be referenced from a stored property initializer", ())
29832986
ERROR(dynamic_self_default_arg,none,
@@ -4331,6 +4334,9 @@ ERROR(actor_isolated_from_async_let,none,
43314334
ERROR(actor_isolated_from_escaping_closure,none,
43324335
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from an '@escaping' closure",
43334336
(DescriptiveDeclKind, DeclName, unsigned))
4337+
ERROR(actor_isolated_keypath_component,none,
4338+
"cannot form key path to actor-isolated %0 %1",
4339+
(DescriptiveDeclKind, DeclName))
43344340
ERROR(local_function_executed_concurrently,none,
43354341
"concurrently-executed %0 %1 must be marked as '@concurrent'",
43364342
(DescriptiveDeclKind, DeclName))
@@ -4377,6 +4383,9 @@ WARNING(non_concurrent_property_type,none,
43774383
WARNING(non_concurrent_keypath_capture,none,
43784384
"cannot form key path that captures non-concurrent-value type %0",
43794385
(Type))
4386+
WARNING(non_concurrent_keypath_access,none,
4387+
"cannot form key path that accesses non-concurrent-value type %0",
4388+
(Type))
43804389
ERROR(non_concurrent_type_member,none,
43814390
"%select{stored property %1|associated value %1}0 of "
43824391
"'ConcurrentValue'-conforming %2 %3 has non-concurrent-value type %4",

include/swift/AST/Expr.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,6 +5654,26 @@ class KeyPathExpr : public Expr {
56545654
llvm_unreachable("unhandled kind");
56555655
}
56565656

5657+
bool hasDeclRef() const {
5658+
switch (getKind()) {
5659+
case Kind::Property:
5660+
case Kind::Subscript:
5661+
return true;
5662+
5663+
case Kind::Invalid:
5664+
case Kind::UnresolvedProperty:
5665+
case Kind::UnresolvedSubscript:
5666+
case Kind::OptionalChain:
5667+
case Kind::OptionalWrap:
5668+
case Kind::OptionalForce:
5669+
case Kind::Identity:
5670+
case Kind::TupleElement:
5671+
case Kind::DictionaryKey:
5672+
return false;
5673+
}
5674+
llvm_unreachable("unhandled kind");
5675+
}
5676+
56575677
ConcreteDeclRef getDeclRef() const {
56585678
switch (getKind()) {
56595679
case Kind::Property:

include/swift/AST/GenericSignature.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class CanGenericSignature : public GenericSignature {
175175
/// requirements, first canonicalizing the types.
176176
static CanGenericSignature
177177
getCanonical(TypeArrayView<GenericTypeParamType> params,
178-
ArrayRef<Requirement> requirements, bool skipValidation = false);
178+
ArrayRef<Requirement> requirements);
179179

180180
public:
181181
CanGenericSignature(std::nullptr_t) : GenericSignature(nullptr) {}
@@ -342,6 +342,8 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
342342
///
343343
/// The type parameters must be known to not be concrete within the context.
344344
bool areSameTypeParameterInContext(Type type1, Type type2) const;
345+
bool areSameTypeParameterInContext(Type type1, Type type2,
346+
GenericSignatureBuilder &builder) const;
345347

346348
/// Determine if \c sig can prove \c requirement, meaning that it can deduce
347349
/// T: Foo or T == U (etc.) with the information it knows. This includes
@@ -360,12 +362,10 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
360362
/// Return the canonical version of the given type under this generic
361363
/// signature.
362364
CanType getCanonicalTypeInContext(Type type) const;
363-
bool isCanonicalTypeInContext(Type type) const;
364-
365-
/// Return the canonical version of the given type under this generic
366-
/// signature.
367365
CanType getCanonicalTypeInContext(Type type,
368366
GenericSignatureBuilder &builder) const;
367+
368+
bool isCanonicalTypeInContext(Type type) const;
369369
bool isCanonicalTypeInContext(Type type,
370370
GenericSignatureBuilder &builder) const;
371371

include/swift/AST/Module.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ class ModuleDecl : public DeclContext, public TypeDecl {
166166
friend class DirectOperatorLookupRequest;
167167
friend class DirectPrecedenceGroupLookupRequest;
168168

169+
/// The ABI name of the module, if it differs from the module name.
170+
mutable Identifier ModuleABIName;
171+
169172
public:
170173
/// Produces the components of a given module's full name in reverse order.
171174
///
@@ -343,6 +346,15 @@ class ModuleDecl : public DeclContext, public TypeDecl {
343346
void getDeclaredCrossImportBystanders(
344347
SmallVectorImpl<Identifier> &bystanderNames);
345348

349+
/// Retrieve the ABI name of the module, which is used for metadata and
350+
/// mangling.
351+
Identifier getABIName() const;
352+
353+
/// Set the ABI name of the module;
354+
void setABIName(Identifier name) {
355+
ModuleABIName = name;
356+
}
357+
346358
private:
347359
/// A cache of this module's underlying module and required bystander if it's
348360
/// an underscored cross-import overlay.

0 commit comments

Comments
 (0)