Skip to content

Commit 043d492

Browse files
authored
Merge branch 'main' into 73992299-1
2 parents fe5c7ef + 25c366d commit 043d492

File tree

115 files changed

+2314
-870
lines changed

Some content is hidden

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

115 files changed

+2314
-870
lines changed

include/swift/ABI/Metadata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,6 +4290,10 @@ class TargetClassDescriptor final
42904290
return FieldOffsetVectorOffset;
42914291
}
42924292

4293+
bool isActor() const {
4294+
return this->getTypeContextDescriptorFlags().class_isActor();
4295+
}
4296+
42934297
bool isDefaultActor() const {
42944298
return this->getTypeContextDescriptorFlags().class_isDefaultActor();
42954299
}

include/swift/ABI/MetadataValues.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,11 @@ class TypeContextDescriptorFlags : public FlagSet<uint16_t> {
13951395

13961396
// Type-specific flags:
13971397

1398+
/// Set if the class is an actor.
1399+
///
1400+
/// Only meaningful for class descriptors.
1401+
Class_IsActor = 7,
1402+
13981403
/// Set if the class is a default actor class. Note that this is
13991404
/// based on the best knowledge available to the class; actor
14001405
/// classes with resilient superclassess might be default actors
@@ -1485,6 +1490,9 @@ class TypeContextDescriptorFlags : public FlagSet<uint16_t> {
14851490
FLAGSET_DEFINE_FLAG_ACCESSORS(Class_IsDefaultActor,
14861491
class_isDefaultActor,
14871492
class_setIsDefaultActor)
1493+
FLAGSET_DEFINE_FLAG_ACCESSORS(Class_IsActor,
1494+
class_isActor,
1495+
class_setIsActor)
14881496

14891497
FLAGSET_DEFINE_FIELD_ACCESSORS(Class_ResilientSuperclassReferenceKind,
14901498
Class_ResilientSuperclassReferenceKind_width,
@@ -2007,6 +2015,7 @@ class JobFlags : public FlagSet<size_t> {
20072015
Task_IsChildTask = 24,
20082016
Task_IsFuture = 25,
20092017
Task_IsGroupChildTask = 26,
2018+
Task_IsContinuingAsyncTask = 27,
20102019
};
20112020

20122021
explicit JobFlags(size_t bits) : FlagSet(bits) {}
@@ -2036,6 +2045,9 @@ class JobFlags : public FlagSet<size_t> {
20362045
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsGroupChildTask,
20372046
task_isGroupChildTask,
20382047
task_setIsGroupChildTask)
2048+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsContinuingAsyncTask,
2049+
task_isContinuingAsyncTask,
2050+
task_setIsContinuingAsyncTask)
20392051
};
20402052

20412053
/// Kinds of task status record.

include/swift/ABI/Task.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class alignas(2 * alignof(void*)) Job :
5050
NextWaitingTaskIndex = 0,
5151

5252
// The Dispatch object header is one pointer and two ints, which is
53-
// equvialent to three pointers on 32-bit and two pointers 64-bit. Set the
53+
// equivalent to three pointers on 32-bit and two pointers 64-bit. Set the
5454
// indexes accordingly so that DispatchLinkageIndex points to where Dispatch
5555
// expects.
5656
DispatchHasLongObjectHeader = sizeof(void *) == sizeof(int),
@@ -243,14 +243,13 @@ class AsyncTask : public Job {
243243

244244
// ==== Task Local Values ----------------------------------------------------
245245

246-
void localValuePush(const Metadata *keyType,
246+
void localValuePush(const HeapObject *key,
247247
/* +1 */ OpaqueValue *value, const Metadata *valueType) {
248-
Local.pushValue(this, keyType, value, valueType);
248+
Local.pushValue(this, key, value, valueType);
249249
}
250250

251-
OpaqueValue* localValueGet(const Metadata *keyType,
252-
TaskLocal::TaskLocalInheritance inherit) {
253-
return Local.getValue(this, keyType, inherit);
251+
OpaqueValue* localValueGet(const HeapObject *key) {
252+
return Local.getValue(this, key);
254253
}
255254

256255
void localValuePop() {

include/swift/ABI/TaskLocal.h

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,73 +34,50 @@ class TaskLocal {
3434
public:
3535
/// Type of the pointed at `next` task local item.
3636
enum class NextLinkType : uintptr_t {
37-
/// This task is known to be a "terminal" node in the lookup of task locals.
38-
/// In other words, even if it had a parent, the parent (and its parents)
39-
/// are known to not contain any any more task locals, and thus any further
40-
/// search beyond this task.
41-
IsTerminal = 0b00,
4237
/// The storage pointer points at the next TaskLocal::Item in this task.
43-
IsNext = 0b01,
38+
IsNext = 0b00,
4439
/// The storage pointer points at a item stored by another AsyncTask.
4540
///
4641
/// Note that this may not necessarily be the same as the task's parent
4742
/// task -- we may point to a super-parent if we know / that the parent
4843
/// does not "contribute" any task local values. This is to speed up
4944
/// lookups by skipping empty parent tasks during get(), and explained
5045
/// in depth in `createParentLink`.
51-
IsParent = 0b11
52-
};
53-
54-
/// Values must match `TaskLocalInheritance` declared in `TaskLocal.swift`.
55-
enum class TaskLocalInheritance : uint8_t {
56-
/// Default task local value behavior
57-
///
58-
/// Values declared with a default-inherited key are accessible from:
59-
/// - the current task that has bound the value,
60-
/// - any child task of the current task (e.g. created by async let or groups)
61-
///
62-
/// Such values are *not* carried through detached tasks.
63-
Default = 0,
64-
65-
/// Special semantics which confine a task's local value to *only* the current
66-
/// task. In other words, they ave never inherited by any child task created
67-
/// by the current task.
68-
///
69-
/// Values declared with a never-inherited key only accessible:
70-
/// - specifically from the current task itself
71-
///
72-
/// Such values are *not* accessible from child tasks or detached tasks.
73-
Never = 1
46+
IsParent = 0b01,
7447
};
7548

7649
class Item {
7750
private:
7851
/// Mask used for the low status bits in a task local chain item.
7952
static const uintptr_t statusMask = 0x03;
8053

81-
/// Pointer to the next task local item; be it in this task or in a parent.
82-
/// Low bits encode `NextLinkType`.
83-
/// Item *next = nullptr;
54+
/// Pointer to one of the following:
55+
/// - next task local item as OpaqueValue* if it is task-local allocated
56+
/// - next task local item as HeapObject* if it is heap allocated "heavy"
57+
/// - the parent task's TaskLocal::Storage
58+
///
59+
/// Low bits encode `NextLinkType`, based on which the type of the pointer
60+
/// is determined.
8461
uintptr_t next;
8562

8663
public:
8764
/// The type of the key with which this value is associated.
88-
const Metadata *keyType;
65+
const HeapObject *key;
8966
/// The type of the value stored by this item.
9067
const Metadata *valueType;
9168

9269
// Trailing storage for the value itself. The storage will be
9370
// uninitialized or contain an instance of \c valueType.
9471

95-
private:
72+
protected:
9673
explicit Item()
9774
: next(0),
98-
keyType(nullptr),
75+
key(nullptr),
9976
valueType(nullptr) {}
10077

101-
explicit Item(const Metadata *keyType, const Metadata *valueType)
78+
explicit Item(const HeapObject *key, const Metadata *valueType)
10279
: next(0),
103-
keyType(keyType),
80+
key(key),
10481
valueType(valueType) {}
10582

10683
public:
@@ -116,7 +93,7 @@ class TaskLocal {
11693
static Item *createParentLink(AsyncTask *task, AsyncTask *parent);
11794

11895
static Item *createLink(AsyncTask *task,
119-
const Metadata *keyType,
96+
const HeapObject *key,
12097
const Metadata *valueType);
12198

12299
void destroy(AsyncTask *task);
@@ -125,13 +102,13 @@ class TaskLocal {
125102
return reinterpret_cast<Item *>(next & ~statusMask);
126103
}
127104

128-
NextLinkType getNextLinkType() {
105+
NextLinkType getNextLinkType() const {
129106
return static_cast<NextLinkType>(next & statusMask);
130107
}
131108

132109
/// Item does not contain any actual value, and is only used to point at
133110
/// a specific parent item.
134-
bool isEmpty() {
111+
bool isEmpty() const {
135112
return !valueType;
136113
}
137114

@@ -144,6 +121,7 @@ class TaskLocal {
144121
/// Compute the offset of the storage from the base of the item.
145122
static size_t storageOffset(const Metadata *valueType) {
146123
size_t offset = sizeof(Item);
124+
147125
if (valueType) {
148126
size_t alignment = valueType->vw_alignment();
149127
return (offset + alignment - 1) & ~(alignment - 1);
@@ -162,7 +140,6 @@ class TaskLocal {
162140
}
163141
};
164142

165-
166143
class Storage {
167144
friend class TaskLocal::Item;
168145
private:
@@ -202,12 +179,10 @@ class TaskLocal {
202179
void initializeLinkParent(AsyncTask *task, AsyncTask *parent);
203180

204181
void pushValue(AsyncTask *task,
205-
const Metadata *keyType,
182+
const HeapObject *key,
206183
/* +1 */ OpaqueValue *value, const Metadata *valueType);
207184

208-
OpaqueValue* getValue(AsyncTask *task,
209-
const Metadata *keyType,
210-
TaskLocalInheritance inheritance);
185+
OpaqueValue* getValue(AsyncTask *task, const HeapObject *key);
211186

212187
void popValue(AsyncTask *task);
213188

include/swift/AST/Attr.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,12 @@ SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
657657
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
658658
116)
659659

660+
CONTEXTUAL_SIMPLE_DECL_ATTR(spawn, Spawn,
661+
DeclModifier | OnVar | ConcurrencyOnly |
662+
ABIBreakingToAdd | ABIBreakingToRemove |
663+
APIBreakingToAdd | APIBreakingToRemove,
664+
117)
665+
660666
#undef TYPE_ATTR
661667
#undef DECL_ATTR_ALIAS
662668
#undef CONTEXTUAL_DECL_ATTR_ALIAS

include/swift/AST/Attr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,9 +2077,10 @@ class CompletionHandlerAsyncAttr final : public DeclAttribute {
20772077
CompletionHandlerAsyncAttr(AbstractFunctionDecl &asyncFunctionDecl,
20782078
size_t completionHandlerIndex,
20792079
SourceLoc completionHandlerIndexLoc,
2080-
SourceLoc atLoc, SourceRange range)
2080+
SourceLoc atLoc, SourceRange range,
2081+
bool implicit)
20812082
: DeclAttribute(DAK_CompletionHandlerAsync, atLoc, range,
2082-
/*implicit*/ false),
2083+
implicit),
20832084
AsyncFunctionDecl(&asyncFunctionDecl) ,
20842085
CompletionHandlerIndex(completionHandlerIndex),
20852086
CompletionHandlerIndexLoc(completionHandlerIndexLoc) {}

include/swift/AST/Decl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ class PatternBindingDecl final : public Decl,
18621862
bool isComputingPatternBindingEntry(const VarDecl *vd) const;
18631863

18641864
/// Is this an "async let" declaration?
1865-
bool isAsyncLet() const;
1865+
bool isSpawnLet() const;
18661866

18671867
/// Gets the text of the initializer expression for the pattern entry at the
18681868
/// given index, stripping out inactive branches of any #ifs inside the
@@ -4942,7 +4942,7 @@ class VarDecl : public AbstractStorageDecl {
49424942
bool isLet() const { return getIntroducer() == Introducer::Let; }
49434943

49444944
/// Is this an "async let" property?
4945-
bool isAsyncLet() const;
4945+
bool isSpawnLet() const;
49464946

49474947
Introducer getIntroducer() const {
49484948
return Introducer(Bits.VarDecl.Introducer);

include/swift/AST/DiagnosticsParse.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,8 @@ ERROR(statement_begins_with_closure,none,
966966
"top-level statement cannot begin with a closure expression", ())
967967
ERROR(statement_same_line_without_semi,none,
968968
"consecutive statements on a line must be separated by ';'", ())
969+
ERROR(statement_same_line_without_newline,none,
970+
"consecutive statements on a line must be separated by a newline", ())
969971
ERROR(invalid_label_on_stmt,none,
970972
"labels are only valid on loops, if, and switch statements", ())
971973
ERROR(labeled_block_needs_do,none,
@@ -1330,6 +1332,7 @@ ERROR(expr_selector_expected_rparen,PointsToFirstBadToken,
13301332
ERROR(expr_dynamictype_deprecated,PointsToFirstBadToken,
13311333
"'.dynamicType' is deprecated. Use 'type(of: ...)' instead", ())
13321334

1335+
// '#assert'
13331336
ERROR(pound_assert_disabled,PointsToFirstBadToken,
13341337
"#assert is an experimental feature that is currently disabled", ())
13351338
ERROR(pound_assert_expected_lparen,PointsToFirstBadToken,
@@ -1341,6 +1344,10 @@ ERROR(pound_assert_expected_expression,PointsToFirstBadToken,
13411344
ERROR(pound_assert_expected_string_literal,PointsToFirstBadToken,
13421345
"expected a string literal", ())
13431346

1347+
// Postfix '#if' expressions.
1348+
ERROR(expr_postfix_ifconfig_unexpectedtoken,none,
1349+
"unexpected tokens in '#if' expression body", ())
1350+
13441351
//------------------------------------------------------------------------------
13451352
// MARK: Attribute-parsing diagnostics
13461353
//------------------------------------------------------------------------------

include/swift/AST/DiagnosticsSema.def

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,8 +4231,8 @@ ERROR(throwing_interpolation_without_try,none,
42314231
"interpolation can throw but is not marked with 'try'", ())
42324232
ERROR(throwing_call_without_try,none,
42334233
"call can throw but is not marked with 'try'", ())
4234-
ERROR(throwing_async_let_without_try,none,
4235-
"reading 'async let' can throw but is not marked with 'try'", ())
4234+
ERROR(throwing_spawn_let_without_try,none,
4235+
"reading 'spawn let' can throw but is not marked with 'try'", ())
42364236
ERROR(throwing_prop_access_without_try,none,
42374237
"property access can throw but is not marked with 'try'", ())
42384238
ERROR(throwing_subscript_access_without_try,none,
@@ -4261,8 +4261,8 @@ NOTE(async_access_without_await,none,
42614261

42624262
NOTE(async_call_without_await_in_autoclosure,none,
42634263
"call is 'async' in an autoclosure argument", ())
4264-
NOTE(async_call_without_await_in_async_let,none,
4265-
"call is 'async' in an 'async let' initializer", ())
4264+
NOTE(async_call_without_await_in_spawn_let,none,
4265+
"call is 'async' in an 'spawn let' initializer", ())
42664266

42674267
WARNING(no_async_in_await,none,
42684268
"no 'async' operations occur within 'await' expression", ())
@@ -4275,7 +4275,7 @@ ERROR(await_in_illegal_context,none,
42754275
"%select{<<ERROR>>|a default argument|a property wrapper initializer|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}0",
42764276
(unsigned))
42774277
ERROR(async_in_nonasync_function,none,
4278-
"%select{'async'|'async' call|'await'|'async let'|'async' property access|'async' subscript access}0 in "
4278+
"%select{'async'|'async' call|'await'|'spawn let'|'async' property access|'async' subscript access}0 in "
42794279
"%select{a function|an autoclosure}1 that does not support concurrency",
42804280
(unsigned, bool))
42814281
NOTE(note_add_async_to_function,none,
@@ -4302,18 +4302,21 @@ NOTE(protocol_witness_async_conflict,none,
43024302
ERROR(async_autoclosure_nonasync_function,none,
43034303
"'async' autoclosure parameter in a non-'async' function", ())
43044304

4305-
ERROR(async_not_let,none,
4306-
"'async' can only be used with 'let' declarations", ())
4307-
ERROR(async_let_not_local,none,
4308-
"'async let' can only be used on local declarations", ())
4309-
ERROR(async_let_not_initialized,none,
4310-
"'async let' binding requires an initializer expression", ())
4311-
ERROR(async_let_no_variables,none,
4312-
"'async let' requires at least one named variable", ())
4313-
NOTE(async_let_without_await,none,
4314-
"reference to async let %0 is 'async'", (DeclName))
4315-
ERROR(async_let_in_illegal_context,none,
4316-
"async let %0 cannot be referenced in "
4305+
WARNING(async_let_is_spawn_let,none,
4306+
"'async let' is now 'spawn let'", ())
4307+
4308+
ERROR(spawn_not_let,none,
4309+
"'spawn' can only be used with 'let' declarations", ())
4310+
ERROR(spawn_let_not_local,none,
4311+
"'spawn let' can only be used on local declarations", ())
4312+
ERROR(spawn_let_not_initialized,none,
4313+
"'spawn let' binding requires an initializer expression", ())
4314+
ERROR(spawn_let_no_variables,none,
4315+
"'spawn let' requires at least one named variable", ())
4316+
NOTE(spawn_let_without_await,none,
4317+
"reference to spawn let %0 is 'async'", (DeclName))
4318+
ERROR(spawn_let_in_illegal_context,none,
4319+
"spawn let %0 cannot be referenced in "
43174320
"%select{<<ERROR>>|a default argument|a property wrapper initializer|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}1",
43184321
(DeclName, unsigned))
43194322

@@ -4403,8 +4406,8 @@ ERROR(actor_isolated_from_concurrent_closure,none,
44034406
ERROR(actor_isolated_from_concurrent_function,none,
44044407
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from a concurrent function",
44054408
(DescriptiveDeclKind, DeclName, unsigned))
4406-
ERROR(actor_isolated_from_async_let,none,
4407-
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'async let' initializer",
4409+
ERROR(actor_isolated_from_spawn_let,none,
4410+
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'spawn let' initializer",
44084411
(DescriptiveDeclKind, DeclName, unsigned))
44094412
ERROR(actor_isolated_keypath_component,none,
44104413
"cannot form key path to actor-isolated %0 %1",
@@ -5606,6 +5609,11 @@ ERROR(property_wrapper_dynamic_self_type, none,
56065609
"property wrapper %select{wrapped value|projected value}0 cannot have "
56075610
"dynamic Self type", (bool))
56085611

5612+
ERROR(property_wrapper_var_must_be_static, none,
5613+
"property %0, must be static because property wrapper %1 can only "
5614+
"be applied to static properties",
5615+
(Identifier, Type))
5616+
56095617
ERROR(property_wrapper_attribute_not_on_property, none,
56105618
"property wrapper attribute %0 can only be applied to a property",
56115619
(Identifier))

0 commit comments

Comments
 (0)