Skip to content

Commit 2b3e505

Browse files
authored
Merge pull request #3048 from swiftwasm/main
[pull] swiftwasm from main
2 parents 8271cf9 + 7be0429 commit 2b3e505

File tree

109 files changed

+1969
-803
lines changed

Some content is hidden

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

109 files changed

+1969
-803
lines changed

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/ASTContext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace swift {
7373
class DerivativeAttr;
7474
class DifferentiableAttr;
7575
class ExtensionDecl;
76+
struct ExternalSourceLocs;
7677
class ForeignRepresentationInfo;
7778
class FuncDecl;
7879
class GenericContext;
@@ -1184,6 +1185,10 @@ class ASTContext final {
11841185

11851186
private:
11861187
friend Decl;
1188+
1189+
Optional<ExternalSourceLocs *> getExternalSourceLocs(const Decl *D);
1190+
void setExternalSourceLocs(const Decl *D, ExternalSourceLocs *Locs);
1191+
11871192
Optional<std::pair<RawComment, bool>> getRawComment(const Decl *D);
11881193
void setRawComment(const Decl *D, RawComment RC, bool FromSerialized);
11891194

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ SIMPLE_DECL_ATTR(reasync, AtReasync,
625625
110)
626626

627627
DECL_ATTR(completionHandlerAsync, CompletionHandlerAsync,
628-
OnAbstractFunction | ConcurrencyOnly | LongAttribute |
628+
OnAbstractFunction | ConcurrencyOnly | LongAttribute | UserInaccessible |
629629
ABIStableToAdd | ABIStableToRemove |
630630
APIStableToAdd | APIStableToRemove,
631631
111)

include/swift/AST/Decl.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace swift {
6262
class DynamicSelfType;
6363
class Type;
6464
class Expr;
65+
struct ExternalSourceLocs;
6566
class CaptureListExpr;
6667
class DeclRefExpr;
6768
class ForeignAsyncConvention;
@@ -688,14 +689,12 @@ class alignas(1 << DeclAlignInBits) Decl {
688689
void operator=(const Decl&) = delete;
689690
SourceLoc getLocFromSource() const;
690691

691-
struct CachedExternalSourceLocs {
692-
SourceLoc Loc;
693-
SourceLoc StartLoc;
694-
SourceLoc EndLoc;
695-
SmallVector<CharSourceRange, 4> DocRanges;
696-
};
697-
mutable CachedExternalSourceLocs const *CachedSerializedLocs = nullptr;
698-
const CachedExternalSourceLocs *getSerializedLocs() const;
692+
/// Returns the serialized locations of this declaration from the
693+
/// corresponding .swiftsourceinfo file. "Empty" (ie. \c BufferID of 0, an
694+
/// invalid \c Loc, and empty \c DocRanges) if either there is no
695+
/// .swiftsourceinfo or the buffer could not be created, eg. if the file
696+
/// no longer exists.
697+
const ExternalSourceLocs *getSerializedLocs() const;
699698

700699
/// Directly set the invalid bit
701700
void setInvalidBit();

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5606,6 +5606,11 @@ ERROR(property_wrapper_dynamic_self_type, none,
56065606
"property wrapper %select{wrapped value|projected value}0 cannot have "
56075607
"dynamic Self type", (bool))
56085608

5609+
ERROR(property_wrapper_var_must_be_static, none,
5610+
"property %0, must be static because property wrapper %1 can only "
5611+
"be applied to static properties",
5612+
(Identifier, Type))
5613+
56095614
ERROR(property_wrapper_attribute_not_on_property, none,
56105615
"property wrapper attribute %0 can only be applied to a property",
56115616
(Identifier))

include/swift/AST/FileUnit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ class FileUnit : public DeclContext {
164164
return None;
165165
}
166166

167-
virtual Optional<BasicDeclLocs> getBasicLocsForDecl(const Decl *D) const {
167+
virtual Optional<ExternalSourceLocs::RawLocs>
168+
getExternalRawLocsForDecl(const Decl *D) const {
168169
return None;
169170
}
170171

include/swift/AST/KnownSDKTypes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ KNOWN_SDK_TYPE_DECL(ObjectiveC, ObjCBool, StructDecl, 0)
4040
KNOWN_SDK_TYPE_DECL(Concurrency, UnsafeContinuation, NominalTypeDecl, 2)
4141
KNOWN_SDK_TYPE_DECL(Concurrency, MainActor, NominalTypeDecl, 0)
4242

43+
KNOWN_SDK_TYPE_DECL(Concurrency, TaskLocal, ClassDecl, 1)
44+
4345
#undef KNOWN_SDK_TYPE_DECL

include/swift/AST/PropertyWrappers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ struct PropertyWrapperTypeInfo {
8888
/// ability to reason about the enclosing "self".
8989
SubscriptDecl *enclosingInstanceProjectedSubscript = nullptr;
9090

91+
/// Forces that the property wrapper must be declared on a static, or
92+
/// global–once supported–property.
93+
bool requireNoEnclosingInstance = false;
94+
9195
///
9296
/// Whether this is a valid property wrapper.
9397
bool isValid() const {

0 commit comments

Comments
 (0)