Skip to content

Commit 0450382

Browse files
authored
Merge pull request #3876 from swiftwasm/main
[pull] swiftwasm from main
2 parents ef5952c + 7880972 commit 0450382

File tree

148 files changed

+18173
-2000
lines changed

Some content is hidden

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

148 files changed

+18173
-2000
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ function(add_libswift name)
798798
# Create a static libswift library containing all module object files.
799799
add_library(${name} STATIC ${all_obj_files})
800800
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
801+
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${name})
801802
endfunction()
802803
803804
macro(add_swift_tool_subdirectory name)

cmake/modules/SwiftConfig.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ set(SWIFT_LIBRARY_DIR "@SWIFT_LIBRARY_DIRS@")
1717
set(SWIFT_CMAKE_DIR "@SWIFT_CMAKE_DIR@")
1818
set(SWIFT_BINARY_DIR "@SWIFT_BINARY_DIR@")
1919

20+
set(LIBSWIFT_BUILD_MODE "@LIBSWIFT_BUILD_MODE@")
21+
2022
set(CMARK_TARGETS_FILE @SWIFT_PATH_TO_CMARK_BUILD@/src/cmarkTargets.cmake)
2123
if(NOT TARGET libcmark_static AND EXISTS ${CMARK_TARGETS_FILE})
2224
include(${CMARK_TARGETS_FILE})

docs/SIL.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3985,13 +3985,41 @@ bind_memory
39853985

39863986
sil-instruction ::= 'bind_memory' sil-operand ',' sil-operand 'to' sil-type
39873987

3988-
bind_memory %0 : $Builtin.RawPointer, %1 : $Builtin.Word to $T
3988+
%token = bind_memory %0 : $Builtin.RawPointer, %1 : $Builtin.Word to $T
39893989
// %0 must be of $Builtin.RawPointer type
39903990
// %1 must be of $Builtin.Word type
3991+
// %token is an opaque $Builtin.Word representing the previously bound types
3992+
// for this memory region.
39913993

39923994
Binds memory at ``Builtin.RawPointer`` value ``%0`` to type ``$T`` with enough
39933995
capacity to hold ``%1`` values. See SE-0107: UnsafeRawPointer.
39943996

3997+
Produces a opaque token representing the previous memory state. For
3998+
memory binding semantics, this state includes the type that the memory
3999+
was previously bound to. The token cannot, however, be used to
4000+
retrieve a metatype. It's value is only meaningful to the Swift
4001+
runtime for typed pointer verification.
4002+
4003+
rebind_memory
4004+
`````````````
4005+
4006+
::
4007+
4008+
sil-instruction ::= 'rebind_memory' sil-operand ' 'to' sil-value
4009+
4010+
%out_token = rebind_memory %0 : $Builtin.RawPointer to %in_token
4011+
// %0 must be of $Builtin.RawPointer type
4012+
// %in_token represents a cached set of bound types from a prior memory state.
4013+
// %out_token is an opaque $Builtin.Word representing the previously bound
4014+
// types for this memory region.
4015+
4016+
This instruction's semantics are identical to ``bind_memory``, except
4017+
that the types to which memory will be bound, and the extent of the
4018+
memory region is unknown at compile time. Instead, the bound-types are
4019+
represented by a token that was produced by a prior memory binding
4020+
operation. ``%in_token`` must be the result of bind_memory or
4021+
rebind_memory.
4022+
39954023
begin_access
39964024
````````````
39974025

include/swift/ABI/MetadataValues.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,12 @@ enum class JobPriority : size_t {
20222022
Unspecified = 0x00,
20232023
};
20242024

2025+
/// A tri-valued comparator which orders higher priorities first.
2026+
inline int descendingPriorityOrder(JobPriority lhs,
2027+
JobPriority rhs) {
2028+
return (lhs == rhs ? 0 : lhs > rhs ? -1 : 1);
2029+
}
2030+
20252031
/// Flags for task creation.
20262032
class TaskCreateFlags : public FlagSet<size_t> {
20272033
public:

include/swift/AST/ASTMangler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class ASTMangler : public Mangler {
5656
/// to fill these in.
5757
bool AllowSymbolicReferences = false;
5858

59+
/// If enabled, allows the use of standard substitutions for types in the
60+
/// standard library.
61+
bool AllowStandardSubstitutions = true;
62+
5963
/// If enabled, allows the use of standard substitutions for types in the
6064
/// concurrency library.
6165
bool AllowConcurrencyStandardSubstitutions = true;

include/swift/AST/Builtins.def

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,18 @@ BUILTIN_SIL_OPERATION(BeginCOWMutation_native, "beginCOWMutation_native", Specia
452452
/// inout argument. After calling this builtin, the buffer must not be mutated.
453453
BUILTIN_SIL_OPERATION(EndCOWMutation, "endCOWMutation", Special)
454454

455-
/// bindMemory : <T> (Builtin.RawPointer, Builtin.Word, T.Type) -> ()
455+
/// bindMemory : <T> (Builtin.RawPointer, Builtin.Word, T.Type) -> Builtin.Word
456+
///
457+
/// Binds memory to a statically known type. Returns an opaque token
458+
/// representing the memory region's previously bound types.
456459
BUILTIN_SIL_OPERATION(BindMemory, "bindMemory", Special)
457460

461+
/// rebindMemory : (Builtin.RawPointer, Builtin.Word) -> Builtin.Word
462+
///
463+
/// Binds memory to the types represented by an opaque token operand. Returns an
464+
/// opaque token representing the memory region's previously bound types.
465+
BUILTIN_SIL_OPERATION(RebindMemory, "rebindMemory", Special)
466+
458467
/// allocWithTailElems_<n>(C.Type,
459468
/// Builtin.Word, E1.Type, ... , Builtin.Word, En.Type) -> C\
460469
///

include/swift/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ enum class DescriptiveDeclKind : uint8_t {
169169
Method,
170170
StaticMethod,
171171
ClassMethod,
172+
DistributedMethod,
172173
Getter,
173174
Setter,
174175
Addressor,
@@ -5300,6 +5301,9 @@ class VarDecl : public AbstractStorageDecl {
53005301
/// Returns true if the name is the self identifier and is implicit.
53015302
bool isSelfParameter() const;
53025303

5304+
/// Check whether the variable is the "self" of an actor method.
5305+
bool isActorSelf() const;
5306+
53035307
/// Determine whether this property will be part of the implicit memberwise
53045308
/// initializer.
53055309
///

include/swift/AST/DiagnosticsSema.def

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,7 +4363,7 @@ NOTE(note_add_distributed_to_decl,none,
43634363
"add 'distributed' to %0 to make this %1 witness the protocol requirement",
43644364
(DeclName, DescriptiveDeclKind))
43654365
NOTE(note_distributed_requirement_defined_here,none,
4366-
"distributed function requirement %0 declared here",
4366+
"distributed instance method requirement %0 declared here",
43674367
(DeclName))
43684368
NOTE(note_add_globalactor_to_function,none,
43694369
"add '@%0' to make %1 %2 part of global actor %3",
@@ -4502,13 +4502,13 @@ NOTE(note_distributed_actor_isolated_method,none,
45024502
"distributed actor-isolated %0 %1 declared here",
45034503
(DescriptiveDeclKind, DeclName))
45044504
ERROR(distributed_actor_isolated_method,none,
4505-
"only 'distributed' functions can be called on a potentially remote distributed actor",
4505+
"only 'distributed' instance methods can be called on a potentially remote distributed actor",
45064506
())
45074507
ERROR(distributed_actor_func_param_not_codable,none,
4508-
"distributed function parameter '%0' of type %1 does not conform to 'Codable'",
4508+
"distributed instance method parameter '%0' of type %1 does not conform to 'Codable'",
45094509
(StringRef, Type))
45104510
ERROR(distributed_actor_func_result_not_codable,none,
4511-
"distributed function result type %0 does not conform to 'Codable'",
4511+
"distributed instance method result type %0 does not conform to 'Codable'",
45124512
(Type))
45134513
ERROR(distributed_actor_remote_func_implemented_manually,none,
45144514
"distributed function's %0 remote counterpart %1 cannot not be implemented manually.",
@@ -4519,6 +4519,9 @@ ERROR(nonisolated_distributed_actor_storage,none,
45194519
ERROR(distributed_actor_func_nonisolated, none,
45204520
"function %0 cannot be both 'nonisolated' and 'distributed'",
45214521
(DeclName))
4522+
ERROR(distributed_actor_func_private, none,
4523+
"%0 %1 cannot be 'private'",
4524+
(DescriptiveDeclKind, DeclName))
45224525
ERROR(distributed_actor_remote_func_is_not_static,none,
45234526
"remote function %0 must be static.",
45244527
(DeclName))
@@ -4628,7 +4631,7 @@ ERROR(actor_instance_property_wrapper,none,
46284631
(Identifier, Identifier))
46294632

46304633
ERROR(distributed_actor_func_defined_outside_of_distributed_actor,none,
4631-
"distributed function %0 is declared outside of an distributed actor",
4634+
"distributed instance method %0 is declared outside of an distributed actor",
46324635
(DeclName))
46334636
ERROR(distributed_actor_local_var,none,
46344637
"'distributed' can not be applied to local variables",
@@ -4648,7 +4651,7 @@ ERROR(distributed_actor_not_actor_func,none,
46484651
"'distributed' can only be applied to distributed actor async functions",
46494652
())
46504653
ERROR(distributed_actor_func_static,none,
4651-
"'distributed' functions cannot be 'static'",
4654+
"'distributed' method cannot be 'static'",
46524655
())
46534656
ERROR(distributed_actor_func_not_in_distributed_actor,none,
46544657
"'distributed' function can only be declared within 'distributed actor'",

include/swift/AST/Expr.h

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4367,7 +4367,7 @@ class ApplyExpr : public Expr {
43674367
/// Is this application _implicitly_ required to be a throwing call?
43684368
/// This can happen if the function is actually a proxy function invocation,
43694369
/// which may throw, regardless of the target function throwing, e.g.
4370-
/// a distributed function call on a 'remote' actor, may throw due to network
4370+
/// a distributed instance method call on a 'remote' actor, may throw due to network
43714371
/// issues reported by the transport, regardless if the actual target function
43724372
/// can throw.
43734373
bool implicitlyThrows() const {
@@ -5562,24 +5562,43 @@ class KeyPathExpr : public Expr {
55625562
private:
55635563
llvm::MutableArrayRef<Component> Components;
55645564

5565-
public:
5566-
/// Create a new #keyPath expression.
5567-
KeyPathExpr(ASTContext &C,
5568-
SourceLoc keywordLoc, SourceLoc lParenLoc,
5569-
ArrayRef<Component> components,
5570-
SourceLoc rParenLoc,
5571-
bool isImplicit = false);
5565+
KeyPathExpr(SourceLoc startLoc, Expr *parsedRoot, Expr *parsedPath,
5566+
SourceLoc endLoc, bool hasLeadingDot, bool isObjC,
5567+
bool isImplicit);
55725568

5569+
/// Create a key path with unresolved root and path expressions.
55735570
KeyPathExpr(SourceLoc backslashLoc, Expr *parsedRoot, Expr *parsedPath,
5574-
bool hasLeadingDot, bool isImplicit = false)
5575-
: Expr(ExprKind::KeyPath, isImplicit), StartLoc(backslashLoc),
5576-
EndLoc(parsedPath ? parsedPath->getEndLoc() : parsedRoot->getEndLoc()),
5577-
ParsedRoot(parsedRoot), ParsedPath(parsedPath),
5578-
HasLeadingDot(hasLeadingDot) {
5579-
assert((parsedRoot || parsedPath) &&
5580-
"keypath must have either root or path");
5581-
Bits.KeyPathExpr.IsObjC = false;
5582-
}
5571+
bool hasLeadingDot, bool isImplicit);
5572+
5573+
/// Create a key path with components.
5574+
KeyPathExpr(ASTContext &ctx, SourceLoc startLoc,
5575+
ArrayRef<Component> components, SourceLoc endLoc, bool isObjC,
5576+
bool isImplicit);
5577+
5578+
public:
5579+
/// Create a new parsed Swift key path expression.
5580+
static KeyPathExpr *createParsed(ASTContext &ctx, SourceLoc backslashLoc,
5581+
Expr *parsedRoot, Expr *parsedPath,
5582+
bool hasLeadingDot);
5583+
5584+
/// Create a new parsed #keyPath expression.
5585+
static KeyPathExpr *createParsedPoundKeyPath(ASTContext &ctx,
5586+
SourceLoc keywordLoc,
5587+
SourceLoc lParenLoc,
5588+
ArrayRef<Component> components,
5589+
SourceLoc rParenLoc);
5590+
5591+
/// Create an implicit Swift key path expression with a set of resolved
5592+
/// components.
5593+
static KeyPathExpr *createImplicit(ASTContext &ctx, SourceLoc backslashLoc,
5594+
ArrayRef<Component> components,
5595+
SourceLoc endLoc);
5596+
5597+
/// Create an implicit Swift key path expression with a root and path
5598+
/// expression to be resolved.
5599+
static KeyPathExpr *createImplicit(ASTContext &ctx, SourceLoc backslashLoc,
5600+
Expr *parsedRoot, Expr *parsedPath,
5601+
bool hasLeadingDot);
55835602

55845603
SourceLoc getLoc() const { return StartLoc; }
55855604
SourceRange getSourceRange() const { return SourceRange(StartLoc, EndLoc); }
@@ -5592,10 +5611,9 @@ class KeyPathExpr : public Expr {
55925611
return Components;
55935612
}
55945613

5595-
/// Resolve the components of an un-type-checked expr. This copies over the
5596-
/// components from the argument array.
5597-
void resolveComponents(ASTContext &C,
5598-
ArrayRef<Component> resolvedComponents);
5614+
/// Set the key path components. This copies over the components from the
5615+
/// argument array.
5616+
void setComponents(ASTContext &C, ArrayRef<Component> newComponents);
55995617

56005618
/// Indicates if the key path expression is composed by a single invalid
56015619
/// component. e.g. missing component `\Root`

include/swift/AST/IRGenOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ class IRGenOptions {
356356
/// Whether to disable using mangled names for accessing concrete type metadata.
357357
unsigned DisableConcreteTypeMetadataMangledNameAccessors : 1;
358358

359+
/// Whether to disable referencing stdlib symbols via mangled names in
360+
/// reflection mangling.
361+
unsigned DisableStandardSubstitutionsInReflectionMangling : 1;
362+
359363
unsigned EnableGlobalISel : 1;
360364

361365
unsigned VirtualFunctionElimination : 1;
@@ -425,6 +429,7 @@ class IRGenOptions {
425429
GenerateProfile(false), EnableDynamicReplacementChaining(false),
426430
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
427431
DisableConcreteTypeMetadataMangledNameAccessors(false),
432+
DisableStandardSubstitutionsInReflectionMangling(false),
428433
EnableGlobalISel(false), VirtualFunctionElimination(false),
429434
WitnessMethodElimination(false), ConditionalRuntimeRecords(false),
430435
InternalizeAtLink(false),

include/swift/AST/SILOptions.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030

3131
namespace swift {
3232

33+
enum class LexicalLifetimesOption : uint8_t {
34+
// Do not insert any lexical lifetimes.
35+
Off = 0,
36+
37+
// Insert lexical lifetimes and do not remove them until OSSA is lowered. This
38+
// is experimental.
39+
ExperimentalLate,
40+
};
41+
42+
class SILModule;
43+
3344
class SILOptions {
3445
public:
3546
/// Controls the aggressiveness of the performance inliner.
@@ -45,7 +56,7 @@ class SILOptions {
4556
bool RemoveRuntimeAsserts = false;
4657

4758
/// Enable experimental support for emitting defined borrow scopes.
48-
bool EnableExperimentalLexicalLifetimes = false;
59+
LexicalLifetimesOption LexicalLifetimes = LexicalLifetimesOption::Off;
4960

5061
/// Force-run SIL copy propagation to shorten object lifetime in whatever
5162
/// optimization pipeline is currently used.
@@ -226,6 +237,12 @@ class SILOptions {
226237
bool shouldOptimize() const {
227238
return OptMode > OptimizationMode::NoOptimization;
228239
}
240+
241+
/// Returns true if we support inserting lexical lifetimes given the current
242+
/// SIL stage.
243+
///
244+
/// Defined in SILModule.h.
245+
bool supportsLexicalLifetimes(const SILModule &mod) const;
229246
};
230247

231248
} // end namespace swift

0 commit comments

Comments
 (0)