Skip to content

Commit 3e99145

Browse files
authored
Merge pull request #4255 from swiftwasm/main
2 parents 9929926 + 28fb3db commit 3e99145

File tree

115 files changed

+5462
-4300
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

+5462
-4300
lines changed

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,3 +825,8 @@ also locks.
825825
Marks a synchronous API as being unavailable from asynchronous contexts. Direct
826826
usage of annotated API from asynchronous contexts will result in a warning from
827827
the compiler.
828+
829+
## `@_unsafeInheritExecutor`
830+
831+
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.
832+

docs/SIL.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3178,7 +3178,7 @@ alloc_stack
31783178
```````````
31793179
::
31803180

3181-
sil-instruction ::= 'alloc_stack' '[dynamic_lifetime]'? '[lexical]'? sil-type (',' debug-var-attr)*
3181+
sil-instruction ::= 'alloc_stack' '[dynamic_lifetime]'? '[lexical]'? '[moved]'? sil-type (',' debug-var-attr)*
31823182

31833183
%1 = alloc_stack $T
31843184
// %1 has type $*T
@@ -3204,6 +3204,12 @@ This is the case, e.g. for conditionally initialized objects.
32043204
The optional ``lexical`` attribute specifies that the storage corresponds to a
32053205
local variable in the Swift source.
32063206

3207+
The optional ``moved`` attribute specifies that at the source level, the
3208+
variable associated with this alloc_stack was moved and furthermore that at the
3209+
SIL level it passed move operator checking. This means that one can not assume
3210+
that the value in the alloc_stack can be semantically valid over the entire
3211+
function frame when emitting debug info.
3212+
32073213
The memory is not retainable. To allocate a retainable box for a value
32083214
type, use ``alloc_box``.
32093215

@@ -3548,7 +3554,7 @@ debug_value
35483554

35493555
::
35503556

3551-
sil-instruction ::= debug_value '[poison]'? sil-operand (',' debug-var-attr)* advanced-debug-var-attr* (',' 'expr' debug-info-expr)?
3557+
sil-instruction ::= debug_value '[poison]'? '[moved]'? sil-operand (',' debug-var-attr)* advanced-debug-var-attr* (',' 'expr' debug-info-expr)?
35523558

35533559
debug_value %1 : $Int
35543560

@@ -3557,6 +3563,11 @@ specified operand. The declaration in question is identified by either the
35573563
SILLocation attached to the debug_value instruction or the SILLocation specified
35583564
in the advanced debug variable attributes.
35593565

3566+
If the '[moved]' flag is set, then one knows that the debug_value's operand is
3567+
moved at some point of the program, so one can not model the debug_value using
3568+
constructs that assume that the value is live for the entire function (e.x.:
3569+
llvm.dbg.declare).
3570+
35603571
::
35613572

35623573
debug-var-attr ::= 'var'

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ namespace api {
6363
///
6464
/// When the json format changes in a way that requires version-specific handling, this number should be incremented.
6565
/// This ensures we could have backward compatibility so that version changes in the format won't stop the checker from working.
66-
const uint8_t DIGESTER_JSON_VERSION = 6; // Add initkind for constructors
66+
const uint8_t DIGESTER_JSON_VERSION = 7; // push SDKNodeRoot to lower-level
6767
const uint8_t DIGESTER_JSON_DEFAULT_VERSION = 0; // Use this version number for files before we have a version number in json.
68+
const StringRef ABIRootKey = "ABIRoot";
6869

6970
class SDKNode;
7071
typedef SDKNode* NodePtr;
@@ -827,4 +828,13 @@ void nodeSetDifference(ArrayRef<SDKNode*> Left, ArrayRef<SDKNode*> Right,
827828
} // end of ide namespace
828829
} // end of Swift namespace
829830

831+
namespace swift {
832+
namespace json {
833+
template <> struct ObjectTraits<ide::api::SDKNodeRoot> {
834+
static void mapping(Output &out, ide::api::SDKNodeRoot &contents) {
835+
contents.jsonize(out);
836+
}
837+
};
838+
}}
839+
830840
#endif

include/swift/AST/Attr.def

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,11 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(nonisolated, Nonisolated,
636636
112)
637637

638638
// 113 was experimental _unsafeSendable and is now unused
639-
// 114 was experimental _unsafeMainActor and is now unused
639+
640+
SIMPLE_DECL_ATTR(_unsafeInheritExecutor, UnsafeInheritExecutor,
641+
OnFunc | UserInaccessible |
642+
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
643+
114) // previously experimental _unsafeMainActor
640644

641645
SIMPLE_DECL_ATTR(_implicitSelfCapture, ImplicitSelfCapture,
642646
OnParam | UserInaccessible |

include/swift/AST/Decl.h

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "swift/AST/IfConfigClause.h"
3030
#include "swift/AST/LayoutConstraint.h"
3131
#include "swift/AST/ReferenceCounting.h"
32+
#include "swift/AST/RequirementSignature.h"
3233
#include "swift/AST/StorageImpl.h"
3334
#include "swift/AST/TypeAlignments.h"
3435
#include "swift/AST/TypeWalker.h"
@@ -525,7 +526,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
525526
IsComputingSemanticMembers : 1
526527
);
527528

528-
SWIFT_INLINE_BITFIELD_FULL(ProtocolDecl, NominalTypeDecl, 1+1+1+1+1+1+1+1+1+1+1+8+16,
529+
SWIFT_INLINE_BITFIELD_FULL(ProtocolDecl, NominalTypeDecl, 1+1+1+1+1+1+1+1+1+1+1+8,
529530
/// Whether the \c RequiresClass bit is valid.
530531
RequiresClassValid : 1,
531532

@@ -564,10 +565,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
564565

565566
/// If this is a compiler-known protocol, this will be a KnownProtocolKind
566567
/// value, plus one. Otherwise, it will be 0.
567-
KnownProtocol : 8, // '8' for speed. This only needs 6.
568-
569-
/// The number of requirements in the requirement signature.
570-
NumRequirementsInSignature : 16
568+
KnownProtocol : 8 // '8' for speed. This only needs 6.
571569
);
572570

573571
SWIFT_INLINE_BITFIELD(ClassDecl, NominalTypeDecl, 1+1+2+1+1+1+1+1+1,
@@ -4313,7 +4311,7 @@ class ProtocolDecl final : public NominalTypeDecl {
43134311

43144312
/// The generic signature representing exactly the new requirements introduced
43154313
/// by this protocol.
4316-
const Requirement *RequirementSignature = nullptr;
4314+
Optional<RequirementSignature> RequirementSig;
43174315

43184316
/// Returns the cached result of \c requiresClass or \c None if it hasn't yet
43194317
/// been computed.
@@ -4574,34 +4572,26 @@ class ProtocolDecl final : public NominalTypeDecl {
45744572
/// requirements. Computed from the structural requirements, above.
45754573
ArrayRef<ProtocolDecl *> getProtocolDependencies() const;
45764574

4577-
/// Retrieve the requirements that describe this protocol.
4578-
///
4579-
/// These are the requirements including any inherited protocols
4580-
/// and conformances for associated types that are introduced in this
4581-
/// protocol. Requirements implied via any other protocol (e.g., inherited
4582-
/// protocols of the inherited protocols) are not mentioned. The conformance
4583-
/// requirements listed here become entries in the witness table.
4584-
ArrayRef<Requirement> getRequirementSignature() const;
4575+
/// Retrieve the requirements that describe this protocol from the point of
4576+
/// view of the generic system; see RequirementSignature.h for details.
4577+
RequirementSignature getRequirementSignature() const;
45854578

45864579
/// Is the requirement signature currently being computed?
45874580
bool isComputingRequirementSignature() const;
45884581

45894582
/// Has the requirement signature been computed yet?
45904583
bool isRequirementSignatureComputed() const {
4591-
return RequirementSignature != nullptr;
4584+
return RequirementSig.hasValue();
45924585
}
45934586

4594-
void setRequirementSignature(ArrayRef<Requirement> requirements);
4587+
void setRequirementSignature(RequirementSignature requirementSig);
45954588

45964589
void setLazyRequirementSignature(LazyMemberLoader *lazyLoader,
45974590
uint64_t requirementSignatureData);
45984591

45994592
void setLazyAssociatedTypeMembers(LazyMemberLoader *lazyLoader,
46004593
uint64_t associatedTypesData);
46014594

4602-
private:
4603-
ArrayRef<Requirement> getCachedRequirementSignature() const;
4604-
46054595
public:
46064596
// Implement isa/cast/dyncast/etc.
46074597
static bool classof(const Decl *D) {

include/swift/AST/DeclContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ struct FragileFunctionKind {
201201
AlwaysEmitIntoClient,
202202
DefaultArgument,
203203
PropertyInitializer,
204+
BackDeploy,
204205
None
205206
};
206207

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,6 +3164,9 @@ ERROR(override_reasync_with_non_reasync,none,
31643164
ERROR(reasync_without_async_parameter,none,
31653165
"'reasync' function must take an 'async' function argument", ())
31663166

3167+
ERROR(inherits_executor_without_async,none,
3168+
"non-async functions cannot inherit an executor", ())
3169+
31673170
ERROR(autoclosure_function_type,none,
31683171
"@autoclosure attribute only applies to function types",
31693172
())

include/swift/AST/LazyResolver.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#ifndef SWIFT_AST_LAZYRESOLVER_H
1818
#define SWIFT_AST_LAZYRESOLVER_H
1919

20-
#include "swift/AST/ProtocolConformanceRef.h"
2120
#include "llvm/ADT/PointerEmbeddedInt.h"
2221

2322
namespace swift {
@@ -32,6 +31,7 @@ class NominalTypeDecl;
3231
class NormalProtocolConformance;
3332
class ProtocolConformance;
3433
class ProtocolDecl;
34+
class ProtocolTypeAlias;
3535
class TypeDecl;
3636
class ValueDecl;
3737
class VarDecl;
@@ -99,7 +99,8 @@ class alignas(void*) LazyMemberLoader {
9999
/// Loads the requirement signature for a protocol.
100100
virtual void
101101
loadRequirementSignature(const ProtocolDecl *proto, uint64_t contextData,
102-
SmallVectorImpl<Requirement> &requirements) = 0;
102+
SmallVectorImpl<Requirement> &requirements,
103+
SmallVectorImpl<ProtocolTypeAlias> &typeAliases) = 0;
103104

104105
/// Loads the associated types of a protocol.
105106
virtual void
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//===--- RequirementSignature.h - Requirement Signature AST -----*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines the RequirementSignature class.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_AST_REQUIREMENT_SIGNATURE_H
18+
#define SWIFT_AST_REQUIREMENT_SIGNATURE_H
19+
20+
#include "swift/AST/Type.h"
21+
22+
namespace swift {
23+
24+
/// A description of a typealias defined in a protocol.
25+
class ProtocolTypeAlias final {
26+
Identifier Name;
27+
Type UnderlyingType;
28+
29+
public:
30+
ProtocolTypeAlias(Identifier name, Type underlyingType)
31+
: Name(name), UnderlyingType(underlyingType) {}
32+
33+
/// Returns the name of the typealias.
34+
Identifier getName() const { return Name; }
35+
36+
/// Returns the underlying type of the typealias.
37+
Type getUnderlyingType() const { return UnderlyingType; }
38+
};
39+
40+
/// The requirements that describe a protocol from the viewpoint of the
41+
/// generics system.
42+
class RequirementSignature final {
43+
ArrayRef<Requirement> Requirements;
44+
ArrayRef<ProtocolTypeAlias> TypeAliases;
45+
46+
public:
47+
RequirementSignature() = default;
48+
49+
RequirementSignature(ArrayRef<Requirement> requirements,
50+
ArrayRef<ProtocolTypeAlias> typeAliases)
51+
: Requirements(requirements), TypeAliases(typeAliases) {}
52+
53+
/// The requirements including any inherited protocols and conformances for
54+
/// associated types that are introduced in this protocol.
55+
///
56+
/// Requirements implied via any other protocol (e.g., inherited protocols
57+
/// of the inherited protocols) are not mentioned.
58+
///
59+
/// The conformance requirements listed here become entries in witness tables
60+
/// for conformances to this protocol.
61+
ArrayRef<Requirement> getRequirements() const {
62+
return Requirements;
63+
}
64+
65+
ArrayRef<ProtocolTypeAlias> getTypeAliases() const {
66+
return TypeAliases;
67+
}
68+
};
69+
70+
} // end namespace swift
71+
72+
#endif // SWIFT_AST_REQUIREMENT_SIGNATURE_H

include/swift/AST/TypeCheckRequests.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ class ProtocolDependenciesRequest :
476476
/// be folded into RequirementSignatureRequest.
477477
class RequirementSignatureRequestRQM :
478478
public SimpleRequest<RequirementSignatureRequestRQM,
479-
ArrayRef<Requirement>(ProtocolDecl *),
479+
RequirementSignature(ProtocolDecl *),
480480
RequestFlags::Cached> {
481481
public:
482482
using SimpleRequest::SimpleRequest;
@@ -485,7 +485,7 @@ class RequirementSignatureRequestRQM :
485485
friend SimpleRequest;
486486

487487
// Evaluation.
488-
ArrayRef<Requirement>
488+
RequirementSignature
489489
evaluate(Evaluator &evaluator, ProtocolDecl *proto) const;
490490

491491
public:
@@ -495,7 +495,7 @@ class RequirementSignatureRequestRQM :
495495
/// Compute the requirements that describe a protocol.
496496
class RequirementSignatureRequest :
497497
public SimpleRequest<RequirementSignatureRequest,
498-
ArrayRef<Requirement>(ProtocolDecl *),
498+
RequirementSignature(ProtocolDecl *),
499499
RequestFlags::SeparatelyCached> {
500500
public:
501501
using SimpleRequest::SimpleRequest;
@@ -504,14 +504,14 @@ class RequirementSignatureRequest :
504504
friend SimpleRequest;
505505

506506
// Evaluation.
507-
ArrayRef<Requirement>
507+
RequirementSignature
508508
evaluate(Evaluator &evaluator, ProtocolDecl *proto) const;
509509

510510
public:
511511
// Separate caching.
512512
bool isCached() const { return true; }
513-
Optional<ArrayRef<Requirement>> getCachedResult() const;
514-
void cacheResult(ArrayRef<Requirement> value) const;
513+
Optional<RequirementSignature> getCachedResult() const;
514+
void cacheResult(RequirementSignature value) const;
515515
};
516516

517517
/// Compute the default definition type of an associated type.

0 commit comments

Comments
 (0)