mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Distributed] unlock distributed_actor_deinit test again
This commit is contained in:
@@ -266,6 +266,5 @@ void swift::addImplicitDistributedActorMembersToClass(ClassDecl *decl) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
addFactoryResolveFunction(decl);
|
addFactoryResolveFunction(decl);
|
||||||
// addImplicitDistributedActorStoredProperties(decl);
|
|
||||||
addImplicitRemoteActorFunctions(decl);
|
addImplicitRemoteActorFunctions(decl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6412,7 +6412,6 @@ ValueDecl *TypeChecker::deriveProtocolRequirement(DeclContext *DC,
|
|||||||
return derived.deriveDifferentiable(Requirement);
|
return derived.deriveDifferentiable(Requirement);
|
||||||
|
|
||||||
case KnownDerivableProtocolKind::DistributedActor:
|
case KnownDerivableProtocolKind::DistributedActor:
|
||||||
fprintf(stderr, "[%s:%d] (%s) DERIVE DistributedActor \n", __FILE__, __LINE__, __FUNCTION__);
|
|
||||||
return derived.deriveDistributedActor(Requirement);
|
return derived.deriveDistributedActor(Requirement);
|
||||||
|
|
||||||
case KnownDerivableProtocolKind::OptionSet:
|
case KnownDerivableProtocolKind::OptionSet:
|
||||||
|
|||||||
@@ -7,24 +7,33 @@
|
|||||||
// UNSUPPORTED: use_os_stdlib
|
// UNSUPPORTED: use_os_stdlib
|
||||||
// UNSUPPORTED: back_deployment_runtime
|
// UNSUPPORTED: back_deployment_runtime
|
||||||
|
|
||||||
// REQUIRES: rdar78290608
|
|
||||||
|
|
||||||
import _Distributed
|
import _Distributed
|
||||||
|
|
||||||
@available(SwiftStdlib 5.5, *)
|
@available(SwiftStdlib 5.5, *)
|
||||||
actor A {}
|
actor A {}
|
||||||
|
|
||||||
@available(SwiftStdlib 5.5, *)
|
@available(SwiftStdlib 5.5, *)
|
||||||
distributed actor DA {
|
distributed actor DA {
|
||||||
|
init(transport: ActorTransport) {
|
||||||
|
defer { transport.actorReady(self) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(SwiftStdlib 5.5, *)
|
@available(SwiftStdlib 5.5, *)
|
||||||
distributed actor DA_userDefined {
|
distributed actor DA_userDefined {
|
||||||
|
init(transport: ActorTransport) {
|
||||||
|
defer { transport.actorReady(self) }
|
||||||
|
}
|
||||||
|
|
||||||
deinit {}
|
deinit {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(SwiftStdlib 5.5, *)
|
@available(SwiftStdlib 5.5, *)
|
||||||
distributed actor DA_userDefined2 {
|
distributed actor DA_userDefined2 {
|
||||||
|
init(transport: ActorTransport) {
|
||||||
|
defer { transport.actorReady(self) }
|
||||||
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
print("Deinitializing \(self.id)")
|
print("Deinitializing \(self.id)")
|
||||||
return
|
return
|
||||||
@@ -36,6 +45,10 @@ distributed actor DA_state {
|
|||||||
var name = "Hello"
|
var name = "Hello"
|
||||||
var age = 42
|
var age = 42
|
||||||
|
|
||||||
|
init(transport: ActorTransport) {
|
||||||
|
defer { transport.actorReady(self) }
|
||||||
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
print("Deinitializing \(self.id)")
|
print("Deinitializing \(self.id)")
|
||||||
return
|
return
|
||||||
@@ -59,7 +72,7 @@ struct FakeTransport: ActorTransport {
|
|||||||
fatalError("not implemented \(#function)")
|
fatalError("not implemented \(#function)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolve<Act>(_ identity: Act.ID, as actorType: Act.Type) throws -> Act?
|
func resolve<Act>(_ identity: AnyActorIdentity, as actorType: Act.Type) throws -> Act?
|
||||||
where Act: DistributedActor {
|
where Act: DistributedActor {
|
||||||
print("resolve type:\(actorType), address:\(identity)")
|
print("resolve type:\(actorType), address:\(identity)")
|
||||||
return nil
|
return nil
|
||||||
@@ -121,9 +134,10 @@ func test() {
|
|||||||
|
|
||||||
// a remote actor should not resign it's address, it was never "assigned" it
|
// a remote actor should not resign it's address, it was never "assigned" it
|
||||||
print("before")
|
print("before")
|
||||||
_ = try! DA_userDefined2(resolve: .init(address), using: transport)
|
_ = try! DA_userDefined2.resolve(.init(address), using: transport)
|
||||||
print("done")
|
print("done")
|
||||||
// CHECK: before
|
// CHECK: before
|
||||||
|
// CHECK-NEXT: resolve type:DA_userDefined2, address:AnyActorIdentity(ActorAddress(address: "xxx"))
|
||||||
// CHECK-NEXT: Deinitializing
|
// CHECK-NEXT: Deinitializing
|
||||||
// CHECK-NEXT: done
|
// CHECK-NEXT: done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,28 +6,31 @@ import _Distributed
|
|||||||
distributed actor SimpleEmptyDistributedActor {
|
distributed actor SimpleEmptyDistributedActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the default (synthesized) constructor:
|
|
||||||
// CHECK: // SimpleEmptyDistributedActor.init(transport:)
|
// CHECK: // SimpleEmptyDistributedActor.init(transport:)
|
||||||
// sil hidden [available 12.0] @$s34distributed_actor_default_init_sil27SimpleEmptyDistributedActorC9transportAC01_H00I9Transport_p_tcfc : $@convention(method) (@in ActorTransport, @owned SimpleEmptyDistributedActor) -> @owned SimpleEmptyDistributedActor {
|
// CHECK: sil hidden{{.*}} @$s34distributed_actor_default_init_sil27SimpleEmptyDistributedActorC9transportAC01_H00I9Transport_p_tcfc : $@convention(method) (@in ActorTransport, @owned SimpleEmptyDistributedActor) -> @owned SimpleEmptyDistributedActor {
|
||||||
// CHECK: [[TRANSPORT:%[0-9]+]] "transport"
|
// CHECK: // %0 "transport" // users: %15, %7, %6, %2
|
||||||
// CHECK: [[SELF:%[0-9]+]] "self"
|
// CHECK: // %1 "self" // users: %5, %12, %4, %16, %3
|
||||||
// CHECK: bb0([[TRANSPORT]] : $*ActorTransport, [[SELF]] : $SimpleEmptyDistributedActor):
|
// CHECK: bb0(%0 : $*ActorTransport, %1 : $SimpleEmptyDistributedActor):
|
||||||
// debug_value_addr [[TRANSPORT]] : $*ActorTransport, let, name "transport", argno 1
|
// CHECK: debug_value_addr %0 : $*ActorTransport, let, name "transport", argno 1, implicit // id: %2
|
||||||
// debug_value [[SELF]] : $SimpleEmptyDistributedActor, let, name "self", argno 2
|
// CHECK: debug_value %1 : $SimpleEmptyDistributedActor, let, name "self", argno 2, implicit // id: %3
|
||||||
// CHECK: [[DEFAULT_ACTOR_INIT:%[0-9]+]] = builtin "initializeDefaultActor"([[SELF]] : $SimpleEmptyDistributedActor) : $()
|
// CHECK: %4 = builtin "initializeDefaultActor"(%1 : $SimpleEmptyDistributedActor) : $()
|
||||||
// CHECK: [[OPEN_TRANSPORT_EXISTENTIAL:%[0-9]+]] = open_existential_addr immutable_access [[TRANSPORT]] : $*ActorTransport to $*@opened({{.*}}) ActorTransport
|
|
||||||
// CHECK: [[SELF_METATYPE:%[0-9]+]] = metatype $@thick SimpleEmptyDistributedActor.Type
|
|
||||||
// CHECK: [[ASSIGN_WITNESS_METHOD:%[0-9]+]] = witness_method $@opened({{.*}}) ActorTransport, #ActorTransport.assignIdentity : <Self where Self : ActorTransport><Act where Act : DistributedActor> (Self) -> (Act.Type) -> AnyActorIdentity, [[OPEN_TRANSPORT_EXISTENTIAL]] : $*@opened({{.*}}) ActorTransport : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity
|
|
||||||
// CHECK: [[IDENTITY_STACK_TMP:%[0-9]+]] = alloc_stack $AnyActorIdentity
|
|
||||||
// CHECK: [[IDENTITY_RETURNED:%[0-9]+]] = apply [[ASSIGN_WITNESS_METHOD]]<@opened({{.*}}) ActorTransport, SimpleEmptyDistributedActor>([[IDENTITY_STACK_TMP]], [[SELF_METATYPE]], [[OPEN_TRANSPORT_EXISTENTIAL]]) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity
|
|
||||||
// CHECK: [[IDENTITY_PROPERTY:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.id
|
|
||||||
// Store the identity
|
|
||||||
// CHECK: copy_addr [take] [[IDENTITY_STACK_TMP]] to [initialization] [[IDENTITY_PROPERTY]] : $*AnyActorIdentity
|
|
||||||
// CHECK: [[TRANSPORT_PROPERTY:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.actorTransport
|
|
||||||
// Store the transport
|
// Store the transport
|
||||||
// CHECK: copy_addr [[TRANSPORT]] to [initialization] [[TRANSPORT_PROPERTY]] : $*ActorTransport
|
// CHECK: %5 = ref_element_addr %1 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.actorTransport // user: %6
|
||||||
// CHECK: dealloc_stack [[IDENTITY_STACK_TMP]] : $*AnyActorIdentity
|
// CHECK: copy_addr %0 to [initialization] %5 : $*ActorTransport // id: %6
|
||||||
// CHECK: destroy_addr [[TRANSPORT]] : $*ActorTransport
|
|
||||||
// // While in AST the return was "return null" after SILGen we properly return the self
|
// Assign an identity
|
||||||
// CHECK: return [[SELF]] : $SimpleEmptyDistributedActor
|
// CHECK: %7 = open_existential_addr immutable_access %0 : $*ActorTransport to $*@opened("{{.*}}") ActorTransport // users: %11, %11, %9
|
||||||
// } // end sil function '$s34distributed_actor_default_init_sil27SimpleEmptyDistributedActorC9transportAC01_H00I9Transport_p_tcfc'
|
// CHECK: %8 = metatype $@thick SimpleEmptyDistributedActor.Type // user: %11
|
||||||
|
// CHECK: %9 = witness_method $@opened("{{.*}}") ActorTransport, #ActorTransport.assignIdentity : <Self where Self : ActorTransport><Act where Act : DistributedActor> (Self) -> (Act.Type) -> AnyActorIdentity, %7 : $*@opened("{{.*}}") ActorTransport : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity // type-defs: %7; user: %11
|
||||||
|
// CHECK: %10 = alloc_stack $AnyActorIdentity // users: %14, %13, %11
|
||||||
|
// CHECK: %11 = apply %9<@opened("{{.*}}") ActorTransport, SimpleEmptyDistributedActor>(%10, %8, %7) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity // type-defs: %7
|
||||||
|
|
||||||
|
// Store the identity
|
||||||
|
// CHECK: %12 = ref_element_addr %1 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.id // user: %13
|
||||||
|
// CHECK: copy_addr [take] %10 to [initialization] %12 : $*AnyActorIdentity // id: %13
|
||||||
|
|
||||||
|
// CHECK: dealloc_stack %10 : $*AnyActorIdentity // id: %14
|
||||||
|
// CHECK: destroy_addr %0 : $*ActorTransport // id: %15
|
||||||
|
// CHECK: return %1 : $SimpleEmptyDistributedActor // id: %16
|
||||||
|
// CHECK: } // end sil function '$s34distributed_actor_default_init_sil27SimpleEmptyDistributedActorC9transportAC01_H00I9Transport_p_tcfc'
|
||||||
|
|||||||
@@ -4,15 +4,6 @@ import _Distributed
|
|||||||
|
|
||||||
class SomeClass {}
|
class SomeClass {}
|
||||||
|
|
||||||
@available(SwiftStdlib 5.5, *)
|
|
||||||
actor SimpleActor {
|
|
||||||
let someFieldInLocalActor: SomeClass
|
|
||||||
init(field: SomeClass) {
|
|
||||||
self.someFieldInLocalActor = field
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@available(SwiftStdlib 5.5, *)
|
@available(SwiftStdlib 5.5, *)
|
||||||
distributed actor SimpleEmptyDistributedActor {
|
distributed actor SimpleEmptyDistributedActor {
|
||||||
let localOnlyField: SomeClass
|
let localOnlyField: SomeClass
|
||||||
@@ -25,73 +16,52 @@ distributed actor SimpleEmptyDistributedActor {
|
|||||||
// ==== ------------------------------------------------------------------------
|
// ==== ------------------------------------------------------------------------
|
||||||
// ==== Check that a normal local only actor is left unchanged
|
// ==== Check that a normal local only actor is left unchanged
|
||||||
|
|
||||||
// CHECK: // SimpleActor.deinit
|
|
||||||
// CHECK: sil hidden{{.*}} @$s35distributed_actor_remote_deinit_sil11SimpleActorCfd : $@convention(method) (@guaranteed SimpleActor) -> @owned Builtin.NativeObject {
|
|
||||||
// CHECK: // %0 "self" // users: %6, %5, %2, %1
|
|
||||||
// CHECK: bb0(%0 : $SimpleActor):
|
|
||||||
// CHECK: debug_value %0 : $SimpleActor, let, name "self", argno 1, implicit // id: %1
|
|
||||||
// CHECK: %2 = ref_element_addr %0 : $SimpleActor, #SimpleActor.someFieldInLocalActor // user: %3
|
|
||||||
// CHECK: %3 = load %2 : $*SomeClass // user: %4
|
|
||||||
// CHECK: strong_release %3 : $SomeClass // id: %4
|
|
||||||
// CHECK: %5 = builtin "destroyDefaultActor"(%0 : $SimpleActor) : $()
|
|
||||||
// CHECK: %6 = unchecked_ref_cast %0 : $SimpleActor to $Builtin.NativeObject // user: %7
|
|
||||||
// CHECK: return %6 : $Builtin.NativeObject // id: %7
|
|
||||||
// CHECK: } // end sil function '$s35distributed_actor_remote_deinit_sil11SimpleActorCfd'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==== deinit must have the extra "if remote..." path emitted for the
|
// ==== deinit must have the extra "if remote..." path emitted for the
|
||||||
// distributed actor only. That path will not attempt deallocating the
|
// distributed actor only. That path will not attempt deallocating the
|
||||||
// `localOnly...` fields, since they were never initialized and have no storage.
|
// `localOnly...` fields, since they were never initialized and have no storage.
|
||||||
|
|
||||||
// CHECK: // SimpleEmptyDistributedActor.deinit
|
// CHECK: // SimpleEmptyDistributedActor.deinit
|
||||||
// sil hidden [available 12.0] @$s35distributed_actor_remote_deinit_sil27SimpleEmptyDistributedActorCfd : $@convention(method) (@guaranteed SimpleEmptyDistributedActor) -> @owned Builtin.NativeObject {
|
// CHECK: sil hidden{{.*}} @$s35distributed_actor_remote_deinit_sil27SimpleEmptyDistributedActorCfd : $@convention(method) (@guaranteed SimpleEmptyDistributedActor) -> @owned Builtin.NativeObject {
|
||||||
// CHECK: // [[SELF:%[0-9]+]] "self"
|
// CHECK: // [[SELF:%[0-9]+]] "self"
|
||||||
// CHECK: bb0(%0 : $SimpleEmptyDistributedActor):
|
// CHECK: bb0(%0 : $SimpleEmptyDistributedActor):
|
||||||
// CHECK: debug_value [[SELF]] : $SimpleEmptyDistributedActor, let, name "self", argno 1, implicit
|
// CHECK-NEXT: debug_value [[SELF]] : $SimpleEmptyDistributedActor, let, name "self", argno 1, implicit
|
||||||
// CHECK: [[IDENTITY_ADDR:%[0-9]+]] = ref_element_addr %0 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.id // users: %13, %24
|
// CHECK-NEXT: [[IDENTITY_ADDR:%[0-9]+]] = ref_element_addr %0 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.id
|
||||||
// CHECK: [[TRANSPORT_ADDR:%[0-9]+]] = ref_element_addr %0 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.actorTransport
|
// CHECK-NEXT: [[TRANSPORT_ADDR:%[0-9]+]] = ref_element_addr %0 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.actorTransport
|
||||||
// CHECK: [[SELF_1:%[0-9]+]] = init_existential_ref %0 : $SimpleEmptyDistributedActor : $SimpleEmptyDistributedActor, $AnyObject
|
// CHECK: [[SELF_1:%[0-9]+]] = init_existential_ref %0 : $SimpleEmptyDistributedActor : $SimpleEmptyDistributedActor, $AnyObject
|
||||||
// CHECK: // function_ref swift_distributed_actor_is_remote
|
// CHECK: // function_ref swift_distributed_actor_is_remote
|
||||||
// CHECK: [[IS_REMOTE_FN_1:%[0-9]+]] = function_ref @swift_distributed_actor_is_remote : $@convention(thin) (@guaranteed AnyObject) -> Bool
|
// CHECK: [[IS_REMOTE_FN_1:%[0-9]+]] = function_ref @swift_distributed_actor_is_remote : $@convention(thin) (@guaranteed AnyObject) -> Bool
|
||||||
// CHECK: [[IS_REMOTE_FN_RES_1:%[0-9]+]] = apply [[IS_REMOTE_FN_1]]([[SELF_1]]) : $@convention(thin) (@guaranteed AnyObject) -> Bool
|
// CHECK: [[IS_REMOTE_FN_RES_1:%[0-9]+]] = apply [[IS_REMOTE_FN_1]]([[SELF_1]]) : $@convention(thin) (@guaranteed AnyObject) -> Bool
|
||||||
// CHECK: [[IS_REMOTE_BOOL_1:%[0-9]+]] = struct_extract [[IS_REMOTE_FN_RES_1]] : $Bool, #Bool._value
|
// CHECK: [[IS_REMOTE_BOOL_1:%[0-9]+]] = struct_extract [[IS_REMOTE_FN_RES_1]] : $Bool, #Bool._value
|
||||||
// CHECK: cond_br [[IS_REMOTE_BOOL_1]], [[BB_CONT_1:bb[0-9]+]], [[BB_RESIGN_DIST_IDENTITY:bb[0-9]+]]
|
// CHECK: cond_br [[IS_REMOTE_BOOL_1]], bb2, bb1
|
||||||
|
|
||||||
// CHECK: [[BB_CONT_1]]:
|
// CHECK: bb1: // Preds: bb0
|
||||||
// CHECK: br [[BB_CHECK_REMOTE_OR_LOCAL_MEMBER_DEINIT_TYPE:bb[0-9]+]]
|
// CHECK: %9 = open_existential_addr immutable_access %3 : $*ActorTransport to $*@opened("{{.*}}") ActorTransport // users: %11, %11, %10
|
||||||
|
// CHECK: %10 = witness_method $@opened("{{.*}}") ActorTransport, #ActorTransport.resignIdentity : <Self where Self : ActorTransport> (Self) -> (AnyActorIdentity) -> (), %9 : $*@opened("{{.*}}") ActorTransport : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport> (@in_guaranteed AnyActorIdentity, @in_guaranteed τ_0_0) -> () // type-defs: %9; user: %11
|
||||||
|
// CHECK: %11 = apply %10<@opened("{{.*}}") ActorTransport>(%2, %9) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport> (@in_guaranteed AnyActorIdentity, @in_guaranteed τ_0_0) -> () // type-defs: %9
|
||||||
|
// CHECK: br bb3 // id: %12
|
||||||
|
|
||||||
// It was a local actor, so we resign the address:
|
// CHECK: bb2: // Preds: bb0
|
||||||
// CHECK: [[BB_RESIGN_DIST_IDENTITY]]:
|
// CHECK: br bb3 // id: %13
|
||||||
// %11 = open_existential_addr immutable_access %4 : $*ActorTransport to $*@opened({{.*}}) ActorTransport // users: %13, %13, %12
|
|
||||||
// CHECK: [[RESIGN_FN:%[0-9]+]] = witness_method $@opened({{.*}}) ActorTransport, #ActorTransport.resignIdentity
|
|
||||||
// CHECK: [[RESIGNED:%[0-9]+]] = apply [[RESIGN_FN]]<@opened({{.*}}) ActorTransport>(%3, %11) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport> (@in_guaranteed AnyActorIdentity, @in_guaranteed τ_0_0) -> ()
|
|
||||||
// CHECK: br [[BB_CHECK_REMOTE_OR_LOCAL_MEMBER_DEINIT_TYPE]]
|
|
||||||
|
|
||||||
// Check if we must skip destroying local storage because actor was remote
|
// CHECK: bb3: // Preds: bb1 bb2
|
||||||
// CHECK: [[BB_CHECK_REMOTE_OR_LOCAL_MEMBER_DEINIT_TYPE]]:
|
// CHECK: %14 = init_existential_ref %0 : $SimpleEmptyDistributedActor : $SimpleEmptyDistributedActor, $AnyObject // user: %15
|
||||||
// CHECK: %15 = init_existential_ref %0 : $SimpleEmptyDistributedActor : $SimpleEmptyDistributedActor, $AnyObject
|
// CHECK: %15 = apply %5(%14) : $@convention(thin) (@guaranteed AnyObject) -> Bool // user: %16
|
||||||
// CHECK: %16 = apply %6(%15) : $@convention(thin) (@guaranteed AnyObject) -> Bool
|
// CHECK: %16 = struct_extract %15 : $Bool, #Bool._value // user: %17
|
||||||
// CHECK: %17 = struct_extract %16 : $Bool, #Bool._value // user: %18
|
// CHECK: cond_br %16, bb4, bb5 // id: %17
|
||||||
// CHECK: cond_br %17, [[BB_CONT_REMOTE_DONT_DESTROY_LOCAL_MEMBERS:bb[0-9]+]], [[BB_CONT_DESTROY_LOCAL_THEN_INDEPENDENT_MEMBERS:bb[0-9]+]]
|
|
||||||
|
|
||||||
// CHECK: [[BB_CONT_REMOTE_DONT_DESTROY_LOCAL_MEMBERS]]:
|
// CHECK: bb4: // Preds: bb3
|
||||||
// CHECK: br [[BB_DESTROY_INDEPENDENT_MEMBERS:bb[0-9]+]]
|
// CHECK: br bb6 // id: %18
|
||||||
|
|
||||||
// We were a local instance after all, and thus must destroy local properties
|
// CHECK: bb5: // Preds: bb3
|
||||||
// CHECK: [[BB_CONT_DESTROY_LOCAL_THEN_INDEPENDENT_MEMBERS]]:
|
// CHECK: %19 = ref_element_addr %0 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.localOnlyField // user: %20
|
||||||
// CHECK: [[FIELD_ADDR:%[0-9]+]] = ref_element_addr %0 : $SimpleEmptyDistributedActor, #SimpleEmptyDistributedActor.localOnlyField
|
// CHECK: %20 = load %19 : $*SomeClass // user: %21
|
||||||
// CHECK: [[LOAD_FIELD_ADDR:%[0-9]+]] = load [[FIELD_ADDR]] : $*SomeClass
|
// CHECK: strong_release %20 : $SomeClass // id: %21
|
||||||
// CHECK: strong_release [[LOAD_FIELD_ADDR]] : $SomeClass
|
// CHECK: br bb6 // id: %22
|
||||||
// CHECK: br [[BB_DESTROY_INDEPENDENT_MEMBERS]]
|
|
||||||
|
|
||||||
// Destroy "distributed nonisolated" fields and the actor itself
|
// CHECK: bb6: // Preds: bb5 bb4
|
||||||
// CHECK: [[BB_DESTROY_INDEPENDENT_MEMBERS]]:
|
// CHECK: destroy_addr %3 : $*ActorTransport // id: %23
|
||||||
// CHECK: destroy_addr [[IDENTITY_ADDR]] : $*AnyActorIdentity
|
// CHECK: destroy_addr %2 : $*AnyActorIdentity // id: %24
|
||||||
// CHECK: destroy_addr [[TRANSPORT_ADDR]] : $*ActorTransport
|
// CHECK: %25 = builtin "destroyDefaultActor"(%0 : $SimpleEmptyDistributedActor) : $()
|
||||||
// CHECK: {{.*}} = builtin "destroyDefaultActor"(%0 : $SimpleEmptyDistributedActor) : $()
|
// CHECK: %26 = unchecked_ref_cast %0 : $SimpleEmptyDistributedActor to $Builtin.NativeObject // user: %27
|
||||||
// CHECK: dealloc_ref [[SELF]] : $SimpleEmptyDistributedActor
|
// CHECK: return %26 : $Builtin.NativeObject // id: %27
|
||||||
// CHECK: [[EMPTY:%[0-9]+]] = tuple ()
|
// CHECK: } // end sil function '$s35distributed_actor_remote_deinit_sil27SimpleEmptyDistributedActorCfd'
|
||||||
// CHECK: return [[EMPTY]] : $()
|
|
||||||
// } // end sil function '$s35distributed_actor_remote_deinit_sil27SimpleEmptyDistributedActorCfD'
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// RUN: %target-swift-frontend -O -primary-file %s -emit-sil -enable-experimental-distributed | %FileCheck %s --dump-input=fail
|
||||||
|
|
||||||
|
import _Distributed
|
||||||
|
|
||||||
|
class SomeClass {}
|
||||||
|
|
||||||
|
@available(SwiftStdlib 5.5, *)
|
||||||
|
actor SimpleActor {
|
||||||
|
let someFieldInLocalActor: SomeClass
|
||||||
|
init(field: SomeClass) {
|
||||||
|
self.someFieldInLocalActor = field
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==== ------------------------------------------------------------------------
|
||||||
|
// ==== Check that a normal local only actor is left unchanged
|
||||||
|
|
||||||
|
// CHECK: // SimpleActor.deinit
|
||||||
|
// CHECK: sil hidden{{.*}} @$s42distributed_actor_remote_deinit_sil_normal11SimpleActorCfd : $@convention(method) (@guaranteed SimpleActor) -> @owned Builtin.NativeObject {
|
||||||
|
// CHECK: // %0 "self" // users: %6, %5, %2, %1
|
||||||
|
// CHECK: bb0(%0 : $SimpleActor):
|
||||||
|
// CHECK: debug_value %0 : $SimpleActor, let, name "self", argno 1, implicit
|
||||||
|
// CHECK: %2 = ref_element_addr %0 : $SimpleActor, #SimpleActor.someFieldInLocalActor
|
||||||
|
// CHECK: %3 = load %2 : $*SomeClass // user: %4
|
||||||
|
// CHECK: strong_release %3 : $SomeClass // id: %4
|
||||||
|
// CHECK: %5 = builtin "destroyDefaultActor"(%0 : $SimpleActor) : $()
|
||||||
|
// CHECK: %6 = unchecked_ref_cast %0 : $SimpleActor to $Builtin.NativeObject // user: %7
|
||||||
|
// CHECK: return %6 : $Builtin.NativeObject // id: %7
|
||||||
|
// CHECK: } // end sil function '$s42distributed_actor_remote_deinit_sil_normal11SimpleActorCfd'
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// RUN: %target-swift-frontend -O -primary-file %s -emit-sil -enable-experimental-distributed | %FileCheck %s
|
// RUN: %target-swift-frontend -O -primary-file %s -emit-sil -enable-experimental-distributed | %FileCheck %s --dump-input=fail
|
||||||
|
|
||||||
import _Distributed
|
import _Distributed
|
||||||
|
|
||||||
@@ -9,49 +9,65 @@ distributed actor SimpleUserDefinedInitDistributedActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: // SimpleUserDefinedInitDistributedActor.init(kappa:other:)
|
// CHECK: // SimpleUserDefinedInitDistributedActor.init(kappa:other:)
|
||||||
// CHECK: [[TRANSPORT:%[0-9]+]] "transport"
|
// CHECK: sil hidden{{.*}} @$s41distributed_actor_user_transport_init_sil37SimpleUserDefinedInitDistributedActorC5kappa5otherAC01_K00L9Transport_p_Sitcfc : $@convention(method) (@in ActorTransport, Int, @owned SimpleUserDefinedInitDistributedActor) -> @owned SimpleUserDefinedInitDistributedActor {
|
||||||
// CHECK: [[OTHER:%[0-9]+]] "other"
|
// CHECK: // %0 "transport" // users: %17, %9, %8, %3
|
||||||
// CHECK: [[SELF:%[0-9]+]] "self"
|
// CHECK: // %1 "other" // user: %4
|
||||||
// CHECK: bb0([[TRANSPORT]] : $*ActorTransport, [[OTHER]] : $Int, [[SELF]] : $SimpleUserDefinedInitDistributedActor):
|
// CHECK: // %2 "self" // users: %7, %14, %6, %18, %5
|
||||||
// CHECK: [[DEFAULT_ACTOR_INIT:%[0-9]+]] = builtin "initializeDefaultActor"([[SELF]] : $SimpleUserDefinedInitDistributedActor) : $()
|
// CHECK: bb0(%0 : $*ActorTransport, %1 : $Int, %2 : $SimpleUserDefinedInitDistributedActor):
|
||||||
// CHECK: [[OPEN_TRANSPORT_EXISTENTIAL:%[0-9]+]] = open_existential_addr immutable_access [[TRANSPORT]] : $*ActorTransport to $*@opened({{.*}}) ActorTransport
|
// CHECK: debug_value_addr %0 : $*ActorTransport, let, name "transport", argno 1 // id: %3
|
||||||
// CHECK: [[SELF_METATYPE:%[0-9]+]] = metatype $@thick SimpleUserDefinedInitDistributedActor.Type
|
// CHECK: debug_value %1 : $Int, let, name "other", argno 2 // id: %4
|
||||||
// CHECK: [[ASSIGN_WITNESS_METHOD:%[0-9]+]] = witness_method $@opened({{.*}}) ActorTransport, #ActorTransport.assignIdentity
|
// CHECK: debug_value %2 : $SimpleUserDefinedInitDistributedActor, let, name "self", argno 3, implicit // id: %5
|
||||||
// CHECK: [[IDENTITY_STACK_TMP:%[0-9]+]] = alloc_stack $AnyActorIdentity
|
// CHECK: %6 = builtin "initializeDefaultActor"(%2 : $SimpleUserDefinedInitDistributedActor) : $()
|
||||||
// CHECK: [[IDENTITY_RETURNED:%[0-9]+]] = apply [[ASSIGN_WITNESS_METHOD]]<@opened({{.*}}) ActorTransport, SimpleUserDefinedInitDistributedActor>([[IDENTITY_STACK_TMP]], [[SELF_METATYPE]], [[OPEN_TRANSPORT_EXISTENTIAL]]) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity
|
|
||||||
// CHECK: [[IDENTITY_PROPERTY:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.id
|
|
||||||
// Store the identity
|
|
||||||
// CHECK: copy_addr [take] [[IDENTITY_STACK_TMP]] to [initialization] [[IDENTITY_PROPERTY]] : $*AnyActorIdentity
|
|
||||||
// CHECK: [[TRANSPORT_PROPERTY:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.actorTransport
|
|
||||||
// Store the transport
|
// Store the transport
|
||||||
// CHECK: copy_addr [[TRANSPORT]] to [initialization] [[TRANSPORT_PROPERTY]] : $*ActorTransport
|
// CHECK: %7 = ref_element_addr %2 : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.actorTransport // user: %8
|
||||||
// CHECK: dealloc_stack [[IDENTITY_STACK_TMP]] : $*AnyActorIdentity
|
// CHECK: copy_addr %0 to [initialization] %7 : $*ActorTransport // id: %8
|
||||||
// CHECK: destroy_addr [[TRANSPORT]] : $*ActorTransport
|
|
||||||
// // While in AST the return was "return null" after SILGen we properly return the self
|
// Assign the identity
|
||||||
// CHECK: return [[SELF]] : $SimpleUserDefinedInitDistributedActor
|
// CHECK: %9 = open_existential_addr immutable_access %0 : $*ActorTransport to $*@opened("{{.*}}") ActorTransport // users: %13, %13, %11
|
||||||
// CHECK: }
|
// CHECK: %10 = metatype $@thick SimpleUserDefinedInitDistributedActor.Type // user: %13
|
||||||
|
// CHECK: %11 = witness_method $@opened("{{.*}}") ActorTransport, #ActorTransport.assignIdentity : <Self where Self : ActorTransport><Act where Act : DistributedActor> (Self) -> (Act.Type) -> AnyActorIdentity, %9 : $*@opened("{{.*}}") ActorTransport : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity // type-defs: %9; user: %13
|
||||||
|
// CHECK: %12 = alloc_stack $AnyActorIdentity // users: %16, %15, %13
|
||||||
|
// CHECK: %13 = apply %11<@opened("{{.*}}") ActorTransport, SimpleUserDefinedInitDistributedActor>(%12, %10, %9) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity // type-defs: %9
|
||||||
|
|
||||||
|
// Store the identity
|
||||||
|
// CHECK: %14 = ref_element_addr %2 : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.id // user: %15
|
||||||
|
// CHECK: copy_addr [take] %12 to [initialization] %14 : $*AnyActorIdentity // id: %15
|
||||||
|
// CHECK: dealloc_stack %12 : $*AnyActorIdentity // id: %16
|
||||||
|
// CHECK: destroy_addr %0 : $*ActorTransport // id: %17
|
||||||
|
// CHECK: return %2 : $SimpleUserDefinedInitDistributedActor // id: %18
|
||||||
|
// CHECK: } // end sil function '$s41distributed_actor_user_transport_init_sil37SimpleUserDefinedInitDistributedActorC5kappa5otherAC01_K00L9Transport_p_Sitcfc'
|
||||||
|
|
||||||
|
|
||||||
// Even if the transport is in another position, we still locate it by the type
|
// Even if the transport is in another position, we still locate it by the type
|
||||||
// CHECK: // SimpleUserDefinedInitDistributedActor.init(other:theTransport:)
|
// CHECK: // SimpleUserDefinedInitDistributedActor.init(other:theTransport:)
|
||||||
// CHECK: [[OTHER:%[0-9]+]] "other"
|
// CHECK: sil hidden{{.*}} @$s41distributed_actor_user_transport_init_sil37SimpleUserDefinedInitDistributedActorC5other12theTransportACSi_01_K00lO0_ptcfc : $@convention(method) (Int, @in ActorTransport, @owned SimpleUserDefinedInitDistributedActor) -> @owned SimpleUserDefinedInitDistributedActor {
|
||||||
// CHECK: [[TRANSPORT:%[0-9]+]] "theTransport"
|
// CHECK: // %0 "other" // user: %3
|
||||||
// CHECK: [[SELF:%[0-9]+]] "self"
|
// CHECK: // %1 "theTransport" // users: %17, %9, %8, %4
|
||||||
// CHECK: bb0([[OTHER]] : $Int, [[TRANSPORT]] : $*ActorTransport, [[SELF]] : $SimpleUserDefinedInitDistributedActor):
|
// CHECK: // %2 "self" // users: %7, %14, %6, %18, %5
|
||||||
// CHECK: [[DEFAULT_ACTOR_INIT:%[0-9]+]] = builtin "initializeDefaultActor"([[SELF]] : $SimpleUserDefinedInitDistributedActor) : $()
|
// CHECK: bb0(%0 : $Int, %1 : $*ActorTransport, %2 : $SimpleUserDefinedInitDistributedActor):
|
||||||
// CHECK: [[OPEN_TRANSPORT_EXISTENTIAL:%[0-9]+]] = open_existential_addr immutable_access [[TRANSPORT]] : $*ActorTransport to $*@opened({{.*}}) ActorTransport
|
// CHECK: debug_value %0 : $Int, let, name "other", argno 1 // id: %3
|
||||||
// CHECK: [[SELF_METATYPE:%[0-9]+]] = metatype $@thick SimpleUserDefinedInitDistributedActor.Type
|
// CHECK: debug_value_addr %1 : $*ActorTransport, let, name "theTransport", argno 2 // id: %4
|
||||||
// CHECK: [[ASSIGN_WITNESS_METHOD:%[0-9]+]] = witness_method $@opened({{.*}}) ActorTransport, #ActorTransport.assignIdentity
|
// CHECK: debug_value %2 : $SimpleUserDefinedInitDistributedActor, let, name "self", argno 3, implicit // id: %5
|
||||||
// CHECK: [[IDENTITY_STACK_TMP:%[0-9]+]] = alloc_stack $AnyActorIdentity
|
// CHECK: %6 = builtin "initializeDefaultActor"(%2 : $SimpleUserDefinedInitDistributedActor) : $()
|
||||||
// CHECK: [[IDENTITY_RETURNED:%[0-9]+]] = apply [[ASSIGN_WITNESS_METHOD]]<@opened({{.*}}) ActorTransport, SimpleUserDefinedInitDistributedActor>([[IDENTITY_STACK_TMP]], [[SELF_METATYPE]], [[OPEN_TRANSPORT_EXISTENTIAL]]) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity
|
|
||||||
// CHECK: [[IDENTITY_PROPERTY:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.id
|
|
||||||
// Store the identity
|
|
||||||
// CHECK: copy_addr [take] [[IDENTITY_STACK_TMP]] to [initialization] [[IDENTITY_PROPERTY]] : $*AnyActorIdentity
|
|
||||||
// CHECK: [[TRANSPORT_PROPERTY:%[0-9]+]] = ref_element_addr [[SELF]] : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.actorTransport
|
|
||||||
// Store the transport
|
|
||||||
// CHECK: copy_addr [[TRANSPORT]] to [initialization] [[TRANSPORT_PROPERTY]] : $*ActorTransport
|
|
||||||
// CHECK: dealloc_stack [[IDENTITY_STACK_TMP]] : $*AnyActorIdentity
|
|
||||||
// CHECK: destroy_addr [[TRANSPORT]] : $*ActorTransport
|
|
||||||
// // While in AST the return was "return null" after SILGen we properly return the self
|
|
||||||
// CHECK: return [[SELF]] : $SimpleUserDefinedInitDistributedActor
|
|
||||||
// CHECK: }
|
|
||||||
|
|
||||||
|
// Store the transport
|
||||||
|
// CHECK: %7 = ref_element_addr %2 : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.actorTransport // user: %8
|
||||||
|
// CHECK: copy_addr %1 to [initialization] %7 : $*ActorTransport // id: %8
|
||||||
|
|
||||||
|
// Assign an identity
|
||||||
|
// CHECK: %9 = open_existential_addr immutable_access %1 : $*ActorTransport to $*@opened("{{.*}}") ActorTransport // users: %13, %13, %11
|
||||||
|
// CHECK: %10 = metatype $@thick SimpleUserDefinedInitDistributedActor.Type // user: %13
|
||||||
|
// CHECK: %11 = witness_method $@opened("{{.*}}") ActorTransport, #ActorTransport.assignIdentity : <Self where Self : ActorTransport><Act where Act : DistributedActor> (Self) -> (Act.Type) -> AnyActorIdentity, %9 : $*@opened("{{.*}}") ActorTransport : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity // type-defs: %9; user: %13
|
||||||
|
// CHECK: %12 = alloc_stack $AnyActorIdentity // users: %16, %15, %13
|
||||||
|
// CHECK: %13 = apply %11<@opened("{{.*}}") ActorTransport, SimpleUserDefinedInitDistributedActor>(%12, %10, %9) : $@convention(witness_method: ActorTransport) <τ_0_0 where τ_0_0 : ActorTransport><τ_1_0 where τ_1_0 : DistributedActor> (@thick τ_1_0.Type, @in_guaranteed τ_0_0) -> @out AnyActorIdentity // type-defs: %9
|
||||||
|
|
||||||
|
// Store the identity
|
||||||
|
// CHECK: %14 = ref_element_addr %2 : $SimpleUserDefinedInitDistributedActor, #SimpleUserDefinedInitDistributedActor.id // user: %15
|
||||||
|
// CHECK: copy_addr [take] %12 to [initialization] %14 : $*AnyActorIdentity // id: %15
|
||||||
|
// CHECK: dealloc_stack %12 : $*AnyActorIdentity // id: %16
|
||||||
|
// CHECK: destroy_addr %1 : $*ActorTransport // id: %17
|
||||||
|
|
||||||
|
// While in AST the return was "return null" after SILGen we properly return the self
|
||||||
|
// CHECK: return %2 : $SimpleUserDefinedInitDistributedActor // id: %18
|
||||||
|
// CHECK: } // end sil function '$s41distributed_actor_user_transport_init_sil37SimpleUserDefinedInitDistributedActorC5other12theTransportACSi_01_K00lO0_ptcfc'
|
||||||
|
|||||||
Reference in New Issue
Block a user