Skip to content

[Distributed] Use distributed thunk witnesses for DA protocol extensions #60809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/SILGen/SILGenType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,6 @@ SILFunction *SILGenModule::emitProtocolWitness(
!requirement.getFuncDecl()->isDistributed() &&
witnessRef.hasDecl() && witnessRef.getFuncDecl() &&
witnessRef.getFuncDecl()->isDistributed());
// We only need to use thunks when we go cross-actor:
shouldUseDistributedThunkWitness = shouldUseDistributedThunkWitness &&
getActorIsolation(requirement.getDecl()) !=
getActorIsolation(witness.getDecl());
if (shouldUseDistributedThunkWitness) {
auto thunkDeclRef = SILDeclRef(
witnessRef.getFuncDecl()->getDistributedThunk(),
Expand Down
26 changes: 26 additions & 0 deletions test/SILGen/distributed_thunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,29 @@ distributed actor DA4: ServerProto {
// CHECK: function_ref @$s17distributed_thunk3DA4C11doSomethingyyYaKFTE
distributed func doSomething() throws { }
}

protocol Server2: DistributedActor {
distributed func sayHello()
}

extension Server2 where ActorSystem == LocalTestingDistributedActorSystem {
// CHECK-LABEL: sil hidden [thunk] [distributed] [ref_adhoc_requirement_witness "$s11Distributed29LocalTestingInvocationDecoderC18decodeNextArgumentxyKSeRzSERzlF"] [ossa] @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyYaKFTE
// CHECK-NOT: return
// CHECK: function_ref @swift_distributed_actor_is_remote
distributed func sayHello() { /* default impl */ }

// CHECK-LABEL: sil hidden [distributed] [ossa] @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyF
// CHECK-NOT: swift_distributed_actor_is_remote
// CHECK: return
}

distributed actor DA5: Server2 {
typealias ActorSystem = LocalTestingDistributedActorSystem
// uses default impl

// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s17distributed_thunk3DA5CAA7Server2A2aDP8sayHelloyyFTW
// CHECK: function_ref @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyF

// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s17distributed_thunk3DA5CAA7Server2A2aDP8sayHelloyyFTWTE
// CHECK: function_ref @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyYaKFTE
}