Skip to content

Commit 4a824a0

Browse files
authored
Merge pull request #2552 from swiftwasm/main
[pull] swiftwasm from main
2 parents 2bb1eed + 4988127 commit 4a824a0

File tree

189 files changed

+11153
-2957
lines changed

Some content is hidden

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

189 files changed

+11153
-2957
lines changed

docs/DynamicCasting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ Casting from a function type F1 to a function type F2 will succeed iff the follo
299299
* Corresponding arguments have identical types
300300
* The return types are identical
301301
* If F1 is a throwing function type, then F2 must be a throwing function type. If F1 is not throwing, then F2 may be a throwing or non-throwing function type.
302+
* F1 and F2 have the same calling convention.
302303

303304
Note that it is _not_ sufficient for argument and return types to be castable; they must actually be identical.
304305

docs/HowToGuides/GettingStarted.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ toolchain as a one-off, there are a couple of differences:
6060

6161
1. Create a directory for the whole project:
6262
```sh
63-
mkdir -p swift-project/swift
64-
cd swift-project/swift
63+
mkdir swift-project
64+
cd swift-project
6565
```
6666
2. Clone the sources:
6767
- Via SSH (recommended):

include/swift/ABI/Task.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ static_assert(alignof(Job) == 2 * alignof(void*),
9393
/// The current state of a task's status records.
9494
class ActiveTaskStatus {
9595
enum : uintptr_t {
96-
IsCancelled = 0x1,
96+
IsCanceled = 0x1,
9797
IsLocked = 0x2,
98-
RecordMask = ~uintptr_t(IsCancelled | IsLocked)
98+
RecordMask = ~uintptr_t(IsCanceled | IsLocked)
9999
};
100100

101101
uintptr_t Value;
@@ -106,10 +106,10 @@ class ActiveTaskStatus {
106106
bool cancelled, bool locked)
107107
: Value(reinterpret_cast<uintptr_t>(innermostRecord)
108108
+ (locked ? IsLocked : 0)
109-
+ (cancelled ? IsCancelled : 0)) {}
109+
+ (cancelled ? IsCanceled : 0)) {}
110110

111111
/// Is the task currently cancelled?
112-
bool isCancelled() const { return Value & IsCancelled; }
112+
bool isCanceled() const { return Value & IsCanceled; }
113113

114114
/// Is there an active lock on the cancellation information?
115115
bool isLocked() const { return Value & IsLocked; }
@@ -178,8 +178,8 @@ class AsyncTask : public HeapObject, public Job {
178178

179179
/// Check whether this task has been cancelled.
180180
/// Checking this is, of course, inherently race-prone on its own.
181-
bool isCancelled() const {
182-
return Status.load(std::memory_order_relaxed).isCancelled();
181+
bool isCanceled() const {
182+
return Status.load(std::memory_order_relaxed).isCanceled();
183183
}
184184

185185
/// A fragment of an async task structure that happens to be a child task.

include/swift/AST/Decl.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class alignas(1 << DeclAlignInBits) Decl {
333333
NumElements : 32
334334
);
335335

336-
SWIFT_INLINE_BITFIELD(ValueDecl, Decl, 1+1+1,
336+
SWIFT_INLINE_BITFIELD(ValueDecl, Decl, 1+1+1+1,
337337
AlreadyInLookupTable : 1,
338338

339339
/// Whether we have already checked whether this declaration is a
@@ -342,7 +342,11 @@ class alignas(1 << DeclAlignInBits) Decl {
342342

343343
/// Whether the decl can be accessed by swift users; for instance,
344344
/// a.storage for lazy var a is a decl that cannot be accessed.
345-
IsUserAccessible : 1
345+
IsUserAccessible : 1,
346+
347+
/// Whether this member was synthesized as part of a derived
348+
/// protocol conformance.
349+
Synthesized : 1
346350
);
347351

348352
SWIFT_INLINE_BITFIELD(AbstractStorageDecl, ValueDecl, 1,
@@ -387,7 +391,7 @@ class alignas(1 << DeclAlignInBits) Decl {
387391
SWIFT_INLINE_BITFIELD(SubscriptDecl, VarDecl, 2,
388392
StaticSpelling : 2
389393
);
390-
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1+1,
394+
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1,
391395
/// \see AbstractFunctionDecl::BodyKind
392396
BodyKind : 3,
393397

@@ -406,10 +410,6 @@ class alignas(1 << DeclAlignInBits) Decl {
406410
/// Whether the function body throws.
407411
Throws : 1,
408412

409-
/// Whether this member was synthesized as part of a derived
410-
/// protocol conformance.
411-
Synthesized : 1,
412-
413413
/// Whether this member's body consists of a single expression.
414414
HasSingleExpressionBody : 1,
415415

@@ -2020,6 +2020,7 @@ class ValueDecl : public Decl {
20202020
Bits.ValueDecl.AlreadyInLookupTable = false;
20212021
Bits.ValueDecl.CheckedRedeclaration = false;
20222022
Bits.ValueDecl.IsUserAccessible = true;
2023+
Bits.ValueDecl.Synthesized = false;
20232024
}
20242025

20252026
// MemberLookupTable borrows a bit from this type
@@ -2057,6 +2058,14 @@ class ValueDecl : public Decl {
20572058
return Bits.ValueDecl.IsUserAccessible;
20582059
}
20592060

2061+
bool isSynthesized() const {
2062+
return Bits.ValueDecl.Synthesized;
2063+
}
2064+
2065+
void setSynthesized(bool value = true) {
2066+
Bits.ValueDecl.Synthesized = value;
2067+
}
2068+
20602069
bool hasName() const { return bool(Name); }
20612070
bool isOperator() const { return Name.isOperator(); }
20622071

@@ -3532,7 +3541,7 @@ class ClassDecl final : public NominalTypeDecl {
35323541

35333542
friend class SuperclassDeclRequest;
35343543
friend class SuperclassTypeRequest;
3535-
friend class SemanticMembersRequest;
3544+
friend class ABIMembersRequest;
35363545
friend class HasMissingDesignatedInitializersRequest;
35373546
friend class InheritsSuperclassInitializersRequest;
35383547

@@ -5577,7 +5586,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
55775586
Bits.AbstractFunctionDecl.Overridden = false;
55785587
Bits.AbstractFunctionDecl.Async = Async;
55795588
Bits.AbstractFunctionDecl.Throws = Throws;
5580-
Bits.AbstractFunctionDecl.Synthesized = false;
55815589
Bits.AbstractFunctionDecl.HasSingleExpressionBody = false;
55825590
Bits.AbstractFunctionDecl.HasNestedTypeDeclarations = false;
55835591
}
@@ -5784,14 +5792,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57845792
/// vtable.
57855793
bool needsNewVTableEntry() const;
57865794

5787-
bool isSynthesized() const {
5788-
return Bits.AbstractFunctionDecl.Synthesized;
5789-
}
5790-
5791-
void setSynthesized(bool value = true) {
5792-
Bits.AbstractFunctionDecl.Synthesized = value;
5793-
}
5794-
57955795
public:
57965796
/// Retrieve the source range of the function body.
57975797
SourceRange getBodySourceRange() const;

include/swift/AST/DeclContext.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,17 @@ class IterableDeclContext {
778778
/// the implementation.
779779
ArrayRef<Decl *> getParsedMembers() const;
780780

781-
/// Get all the members that are semantically within this context,
782-
/// including any implicitly-synthesized members.
781+
/// Get all of the members within this context that can affect ABI, including
782+
/// any implicitly-synthesized members.
783+
///
784+
/// The resulting list of members will be stable across translation units.
785+
ArrayRef<Decl *> getABIMembers() const;
786+
787+
/// Get all of the members within this context, including any
788+
/// implicitly-synthesized members.
789+
///
783790
/// The resulting list of members will be stable across translation units.
784-
ArrayRef<Decl *> getSemanticMembers() const;
791+
ArrayRef<Decl *> getAllMembers() const;
785792

786793
/// Retrieve the set of members in this context without loading any from the
787794
/// associated lazy loader; this should only be used as part of implementing

include/swift/AST/ExtInfo.h

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,45 @@ enum class SILFunctionTypeRepresentation : uint8_t {
169169
Closure,
170170
};
171171

172+
/// Returns true if the function with this convention doesn't carry a context.
173+
constexpr bool
174+
isThinRepresentation(FunctionTypeRepresentation rep) {
175+
switch (rep) {
176+
case FunctionTypeRepresentation::Swift:
177+
case FunctionTypeRepresentation::Block:
178+
return false;
179+
case FunctionTypeRepresentation::Thin:
180+
case FunctionTypeRepresentation::CFunctionPointer:
181+
return true;
182+
}
183+
llvm_unreachable("Unhandled FunctionTypeRepresentation in switch.");
184+
}
185+
186+
/// Returns true if the function with this convention doesn't carry a context.
187+
constexpr bool
188+
isThinRepresentation(SILFunctionTypeRepresentation rep) {
189+
switch (rep) {
190+
case SILFunctionTypeRepresentation::Thick:
191+
case SILFunctionTypeRepresentation::Block:
192+
return false;
193+
case SILFunctionTypeRepresentation::Thin:
194+
case SILFunctionTypeRepresentation::Method:
195+
case SILFunctionTypeRepresentation::ObjCMethod:
196+
case SILFunctionTypeRepresentation::WitnessMethod:
197+
case SILFunctionTypeRepresentation::CFunctionPointer:
198+
case SILFunctionTypeRepresentation::Closure:
199+
return true;
200+
}
201+
llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch.");
202+
}
203+
204+
/// Returns true if the function with this convention carries a context.
205+
template <typename Repr>
206+
constexpr bool
207+
isThickRepresentation(Repr repr) {
208+
return !isThinRepresentation(repr);
209+
}
210+
172211
constexpr SILFunctionTypeRepresentation
173212
convertRepresentation(FunctionTypeRepresentation rep) {
174213
switch (rep) {
@@ -350,19 +389,7 @@ class ASTExtInfoBuilder {
350389

351390
/// True if the function representation carries context.
352391
constexpr bool hasContext() const {
353-
switch (getSILRepresentation()) {
354-
case SILFunctionTypeRepresentation::Thick:
355-
case SILFunctionTypeRepresentation::Block:
356-
return true;
357-
case SILFunctionTypeRepresentation::Thin:
358-
case SILFunctionTypeRepresentation::Method:
359-
case SILFunctionTypeRepresentation::ObjCMethod:
360-
case SILFunctionTypeRepresentation::WitnessMethod:
361-
case SILFunctionTypeRepresentation::CFunctionPointer:
362-
case SILFunctionTypeRepresentation::Closure:
363-
return false;
364-
}
365-
llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch.");
392+
return isThickRepresentation(getSILRepresentation());
366393
}
367394

368395
// Note that we don't have setters. That is by design, use

include/swift/AST/Identifier.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ class Identifier {
110110
return isOperatorSlow();
111111
}
112112

113+
bool isArithmeticOperator() const {
114+
return is("+") || is("-") || is("*") || is("/") || is("%");
115+
}
116+
113117
// Returns whether this is a standard comparison operator,
114118
// such as '==', '>=' or '!=='.
115119
bool isStandardComparisonOperator() const {

include/swift/AST/ParseRequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ParseAbstractFunctionBodyRequest :
8787
struct SourceFileParsingResult {
8888
ArrayRef<Decl *> TopLevelDecls;
8989
Optional<ArrayRef<Token>> CollectedTokens;
90-
Optional<llvm::MD5> InterfaceHash;
90+
Optional<StableHasher> InterfaceHasher;
9191
Optional<syntax::SourceFileSyntax> SyntaxRoot;
9292
};
9393

include/swift/AST/PrintOptions.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ struct PrintOptions {
304304
/// such as _silgen_name, transparent, etc.
305305
bool PrintUserInaccessibleAttrs = true;
306306

307+
/// Whether to limit ourselves to printing only the "current" set of members
308+
/// in a nominal type or extension, which is semantically unstable but can
309+
/// prevent printing from doing "extra" work.
310+
bool PrintCurrentMembersOnly = false;
311+
307312
/// List of attribute kinds that should not be printed.
308313
std::vector<AnyAttrKind> ExcludeAttrList = {DAK_Transparent, DAK_Effects,
309314
DAK_FixedLayout,
@@ -517,6 +522,7 @@ struct PrintOptions {
517522
result.ShouldQualifyNestedDeclarations =
518523
QualifyNestedDeclarations::TypesOnly;
519524
result.PrintDocumentationComments = false;
525+
result.PrintCurrentMembersOnly = true;
520526
return result;
521527
}
522528

@@ -538,6 +544,7 @@ struct PrintOptions {
538544
result.SkipUnderscoredKeywords = true;
539545
result.EnumRawValues = EnumRawValueMode::PrintObjCOnly;
540546
result.MapCrossImportOverlaysToDeclaringModule = true;
547+
result.PrintCurrentMembersOnly = false;
541548
return result;
542549
}
543550

include/swift/AST/SourceFile.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ class SourceFile final : public FileUnit {
105105
SourceLoc MainDeclDiagLoc;
106106

107107
/// A hash of all interface-contributing tokens that have been lexed for
108-
/// this source file so far.
108+
/// this source file.
109+
///
109110
/// We only collect interface hash for primary input files.
110-
llvm::Optional<llvm::MD5> InterfaceHash;
111+
llvm::Optional<StableHasher> InterfaceHasher;
111112

112113
/// The ID for the memory buffer containing this file's source.
113114
///

0 commit comments

Comments
 (0)