Skip to content

Commit b2f0063

Browse files
Merge remote-tracking branch 'apple/release/5.5' into swiftwasm-release/5.5
2 parents 8dfa72f + ee315ec commit b2f0063

File tree

188 files changed

+2709
-945
lines changed

Some content is hidden

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

188 files changed

+2709
-945
lines changed

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ macro(configure_sdks_darwin)
108108
set(macosx_arch "x86_64" "arm64")
109109
set(iphoneos_arch "arm64" "arm64e" "armv7")
110110
set(appletvos_arch "arm64")
111-
set(watchos_arch "armv7k")
111+
set(watchos_arch "armv7k" "arm64_32")
112112

113113
set(macosx_ver "10.9")
114114
set(iphoneos_ver "8.0")

cmake/modules/DarwinSDKs.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ endif()
1212

1313
set(SUPPORTED_TVOS_ARCHS "arm64")
1414
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
15-
set(SUPPORTED_WATCHOS_ARCHS "armv7k")
16-
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
15+
set(SUPPORTED_WATCHOS_ARCHS "armv7k;arm64_32")
16+
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
1717
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")
1818

1919
is_sdk_requested(OSX swift_build_osx)

cmake/modules/SwiftSetIfArchBitness.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function(set_if_arch_bitness var_name)
1212
"${SIA_ARCH}" STREQUAL "armv6" OR
1313
"${SIA_ARCH}" STREQUAL "armv7" OR
1414
"${SIA_ARCH}" STREQUAL "armv7k" OR
15+
"${SIA_ARCH}" STREQUAL "arm64_32" OR
1516
"${SIA_ARCH}" STREQUAL "armv7s" OR
1617
"${SIA_ARCH}" STREQUAL "wasm32")
1718
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)

include/swift/ABI/Metadata.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4897,6 +4897,9 @@ struct DynamicReplacementKey {
48974897
uint16_t getExtraDiscriminator() const {
48984898
return flags & 0x0000FFFF;
48994899
}
4900+
bool isAsync() const {
4901+
return ((flags >> 16 ) & 0x1);
4902+
}
49004903
};
49014904

49024905
/// A record describing a dynamic function replacement.

include/swift/AST/Attr.def

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,16 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(_unsafeMainActor, UnsafeMainActor,
647647
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
648648
114)
649649

650+
SIMPLE_DECL_ATTR(_implicitSelfCapture, ImplicitSelfCapture,
651+
OnParam | UserInaccessible |
652+
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
653+
115)
654+
655+
SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
656+
OnParam | UserInaccessible |
657+
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
658+
116)
659+
650660
#undef TYPE_ATTR
651661
#undef DECL_ATTR_ALIAS
652662
#undef CONTEXTUAL_DECL_ATTR_ALIAS

include/swift/AST/DiagnosticsSema.def

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4253,17 +4253,17 @@ WARNING(no_throw_in_do_with_catch,none,
42534253
//------------------------------------------------------------------------------
42544254
// MARK: Concurrency
42554255
//------------------------------------------------------------------------------
4256-
ERROR(async_call_without_await,none,
4257-
"call is 'async' but is not marked with 'await'", ())
4258-
ERROR(async_call_without_await_in_autoclosure,none,
4259-
"call is 'async' in an autoclosure argument that is not marked with 'await'", ())
4260-
ERROR(async_call_without_await_in_async_let,none,
4261-
"call is 'async' in an 'async let' initializer that is not marked "
4262-
"with 'await'", ())
4263-
ERROR(async_prop_access_without_await,none,
4264-
"property access is 'async' but is not marked with 'await'", ())
4265-
ERROR(async_subscript_access_without_await,none,
4266-
"subscript access is 'async' but is not marked with 'await'", ())
4256+
ERROR(async_expr_without_await,none,
4257+
"expression is 'async' but is not marked with 'await'", ())
4258+
4259+
NOTE(async_access_without_await,none,
4260+
"%select{call|property access|subscript access|}0 is 'async'", (unsigned))
4261+
4262+
NOTE(async_call_without_await_in_autoclosure,none,
4263+
"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", ())
4266+
42674267
WARNING(no_async_in_await,none,
42684268
"no 'async' operations occur within 'await' expression", ())
42694269
ERROR(async_call_in_illegal_context,none,
@@ -4310,8 +4310,8 @@ ERROR(async_let_not_initialized,none,
43104310
"'async let' binding requires an initializer expression", ())
43114311
ERROR(async_let_no_variables,none,
43124312
"'async let' requires at least one named variable", ())
4313-
ERROR(async_let_without_await,none,
4314-
"reference to async let %0 is not marked with 'await'", (DeclName))
4313+
NOTE(async_let_without_await,none,
4314+
"reference to async let %0 is 'async'", (DeclName))
43154315
ERROR(async_let_in_illegal_context,none,
43164316
"async let %0 cannot be referenced in "
43174317
"%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",
@@ -4426,6 +4426,9 @@ NOTE(actor_isolated_sync_func,none,
44264426
NOTE(actor_mutable_state,none,
44274427
"mutation of this %0 is only permitted within the actor",
44284428
(DescriptiveDeclKind))
4429+
NOTE(actor_isolated_let,none,
4430+
"use `nonisolated` to allow synchronous access to 'let' from outside "
4431+
"the actor", ())
44294432
WARNING(shared_mutable_state_access,none,
44304433
"reference to %0 %1 is not concurrency-safe because it involves "
44314434
"shared mutable state", (DescriptiveDeclKind, DeclName))
@@ -4458,13 +4461,12 @@ WARNING(non_concurrent_property_type,none,
44584461
WARNING(non_concurrent_keypath_capture,none,
44594462
"cannot form key path that captures non-sendable type %0",
44604463
(Type))
4461-
WARNING(non_concurrent_keypath_access,none,
4462-
"cannot form key path that accesses non-sendable type %0",
4463-
(Type))
44644464
ERROR(non_concurrent_type_member,none,
44654465
"%select{stored property %1|associated value %1}0 of "
44664466
"'Sendable'-conforming %2 %3 has non-sendable type %4",
44674467
(bool, DeclName, DescriptiveDeclKind, DeclName, Type))
4468+
ERROR(non_sendable_nonisolated_let,none,
4469+
"non-isolated let property %0 has non-Sendable type %1", (DeclName, Type))
44684470
ERROR(concurrent_value_class_mutable_property,none,
44694471
"stored property %0 of 'Sendable'-conforming %1 %2 is mutable",
44704472
(DeclName, DescriptiveDeclKind, DeclName))
@@ -4480,21 +4482,13 @@ ERROR(concurrent_value_inherit,none,
44804482
"%select{| other than 'NSObject'}0",
44814483
(bool, DeclName))
44824484

4483-
ERROR(actorindependent_let,none,
4484-
"'@actorIndependent' is meaningless on 'let' declarations because "
4485-
"they are immutable",
4486-
())
44874485
ERROR(actorindependent_mutable_storage,none,
44884486
"'@actorIndependent' can not be applied to stored properties",
44894487
())
44904488
ERROR(actorindependent_local_var,none,
44914489
"'@actorIndependent' can not be applied to local variables",
44924490
())
44934491

4494-
ERROR(nonisolated_let,none,
4495-
"'nonisolated' is meaningless on 'let' declarations because "
4496-
"they are immutable",
4497-
())
44984492
ERROR(nonisolated_mutable_storage,none,
44994493
"nonisolated' can not be applied to stored properties",
45004494
())

include/swift/AST/Expr.h

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,18 @@ class alignas(8) Expr {
292292
Kind : 2
293293
);
294294

295-
SWIFT_INLINE_BITFIELD(ClosureExpr, AbstractClosureExpr, 1,
295+
SWIFT_INLINE_BITFIELD(ClosureExpr, AbstractClosureExpr, 1+1+1,
296296
/// True if closure parameters were synthesized from anonymous closure
297297
/// variables.
298-
HasAnonymousClosureVars : 1
298+
HasAnonymousClosureVars : 1,
299+
300+
/// True if "self" can be captured implicitly without requiring "self."
301+
/// on each member reference.
302+
ImplicitSelfCapture : 1,
303+
304+
/// True if this @Sendable async closure parameter should implicitly
305+
/// inherit the actor context from where it was formed.
306+
InheritActorContext : 1
299307
);
300308

301309
SWIFT_INLINE_BITFIELD_FULL(BindOptionalExpr, Expr, 16,
@@ -3871,6 +3879,8 @@ class ClosureExpr : public AbstractClosureExpr {
38713879
Body(nullptr) {
38723880
setParameterList(params);
38733881
Bits.ClosureExpr.HasAnonymousClosureVars = false;
3882+
Bits.ClosureExpr.ImplicitSelfCapture = false;
3883+
Bits.ClosureExpr.InheritActorContext = false;
38743884
}
38753885

38763886
SourceRange getSourceRange() const;
@@ -3898,7 +3908,27 @@ class ClosureExpr : public AbstractClosureExpr {
38983908
void setHasAnonymousClosureVars() {
38993909
Bits.ClosureExpr.HasAnonymousClosureVars = true;
39003910
}
3901-
3911+
3912+
/// Whether this closure allows "self" to be implicitly captured without
3913+
/// required "self." on each reference.
3914+
bool allowsImplicitSelfCapture() const {
3915+
return Bits.ClosureExpr.ImplicitSelfCapture;
3916+
}
3917+
3918+
void setAllowsImplicitSelfCapture(bool value = true) {
3919+
Bits.ClosureExpr.ImplicitSelfCapture = value;
3920+
}
3921+
3922+
/// Whether this closure should implicitly inherit the actor context from
3923+
/// where it was formed. This only affects @Sendable async closures.
3924+
bool inheritsActorContext() const {
3925+
return Bits.ClosureExpr.InheritActorContext;
3926+
}
3927+
3928+
void setInheritsActorContext(bool value = true) {
3929+
Bits.ClosureExpr.InheritActorContext = value;
3930+
}
3931+
39023932
/// Determine whether this closure expression has an
39033933
/// explicitly-specified result type.
39043934
bool hasExplicitResultType() const { return ArrowLoc.isValid(); }

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class SILOptions {
6565
/// It is turned off by default.
6666
bool EnableSpeculativeDevirtualization = false;
6767

68+
/// Controls whether to emit actor data-race checks.
69+
bool EnableActorDataRaceChecks = false;
70+
6871
/// Should we run any SIL performance optimizations
6972
///
7073
/// Useful when you want to enable -O LLVM opts but not -O SIL opts.

include/swift/AST/Stmt.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,16 @@ class SwitchStmt final : public LabeledStmt,
11351135
SourceLoc RBraceLoc,
11361136
SourceLoc EndLoc,
11371137
ASTContext &C);
1138-
1138+
1139+
static SwitchStmt *createImplicit(LabeledStmtInfo LabelInfo,
1140+
Expr *SubjectExpr, ArrayRef<ASTNode> Cases,
1141+
ASTContext &C) {
1142+
return SwitchStmt::create(LabelInfo, /*SwitchLoc=*/SourceLoc(), SubjectExpr,
1143+
/*LBraceLoc=*/SourceLoc(), Cases,
1144+
/*RBraceLoc=*/SourceLoc(), /*EndLoc=*/SourceLoc(),
1145+
C);
1146+
}
1147+
11391148
/// Get the source location of the 'switch' keyword.
11401149
SourceLoc getSwitchLoc() const { return SwitchLoc; }
11411150
/// Get the source location of the opening brace.

include/swift/AST/Types.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,6 +3382,8 @@ struct ParameterListInfo {
33823382
SmallBitVector propertyWrappers;
33833383
SmallBitVector unsafeSendable;
33843384
SmallBitVector unsafeMainActor;
3385+
SmallBitVector implicitSelfCapture;
3386+
SmallBitVector inheritActorContext;
33853387

33863388
public:
33873389
ParameterListInfo() { }
@@ -3410,6 +3412,17 @@ struct ParameterListInfo {
34103412
/// part of the type system.
34113413
bool isUnsafeMainActor(unsigned paramIdx) const;
34123414

3415+
/// Whether the given parameter is a closure that should allow capture of
3416+
/// 'self' to be implicit, without requiring "self.".
3417+
bool isImplicitSelfCapture(unsigned paramIdx) const;
3418+
3419+
/// Whether the given parameter is a closure that should inherit the
3420+
/// actor context from the context in which it was created.
3421+
bool inheritsActorContext(unsigned paramIdx) const;
3422+
3423+
/// Whether there is any contextual information set on this parameter list.
3424+
bool anyContextualInfo() const;
3425+
34133426
/// Retrieve the number of non-defaulted parameters.
34143427
unsigned numNonDefaultedParameters() const {
34153428
return defaultArguments.count();

0 commit comments

Comments
 (0)