Skip to content

Commit e1ca212

Browse files
committed
bring back dispatch thunks, evolution works; tbd validation fails
1 parent bb9fdab commit e1ca212

File tree

3 files changed

+66
-18
lines changed

3 files changed

+66
-18
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,8 @@ namespace {
10011001
// Emit the dispatch thunk.
10021002
auto shouldEmitDispatchThunk =
10031003
(Resilient || IGM.getOptions().WitnessMethodElimination) &&
1004-
(!func.isDistributed() || !func.isDistributedThunk());
1004+
// (!func.isDistributed() || !func.isDistributedThunk());
1005+
(!func.isDistributed());
10051006
if (shouldEmitDispatchThunk) {
10061007
IGM.emitDispatchThunk(func);
10071008
}
@@ -1078,18 +1079,35 @@ namespace {
10781079
}
10791080

10801081
if (Resilient) {
1082+
// if (entry.isFunction() &&
1083+
// entry.getFunction().isDistributedThunk()) {
1084+
// continue;
1085+
// }
1086+
10811087
if (entry.isFunction()) {
10821088
// Define the method descriptor.
10831089
SILDeclRef func(entry.getFunction());
10841090

1091+
fprintf(stderr, "[swift][%s:%d](%s) add requirement \n", __FILE__, __LINE__,
1092+
__FUNCTION__);
1093+
func.dump();
1094+
fprintf(stderr, "[swift][%s:%d](%s) func is distributed %d\n", __FILE__, __LINE__,
1095+
__FUNCTION__, func.isDistributed());
1096+
fprintf(stderr, "[swift][%s:%d](%s) func is distributed thunk %d\n", __FILE__, __LINE__,
1097+
__FUNCTION__, func.isDistributedThunk());
1098+
fprintf(stderr, "[swift][%s:%d](%s) \n", __FILE__, __LINE__,
1099+
__FUNCTION__);
10851100
/// Distributed thunks don't need method descriptors
1086-
if (!func.isDistributedThunk()) {
1101+
// if (!func.isDistributedThunk()) {
10871102
auto *descriptor =
10881103
B.getAddrOfCurrentPosition(
10891104
IGM.ProtocolRequirementStructTy);
10901105
IGM.defineMethodDescriptor(func, Proto, descriptor,
10911106
IGM.ProtocolRequirementStructTy);
1092-
}
1107+
// } else {
1108+
// fprintf(stderr, "[swift][%s:%d](%s) SKIPPED REQUIREMENT\n", __FILE__, __LINE__,
1109+
// __FUNCTION__);
1110+
// }
10931111
}
10941112
}
10951113

@@ -1115,6 +1133,10 @@ namespace {
11151133
}
11161134

11171135
if (entry.isBase()) {
1136+
1137+
fprintf(stderr, "[swift][%s:%d](%s) base \n", __FILE__, __LINE__,
1138+
__FUNCTION__);
1139+
entry.getBase()->dump();
11181140
// Define a base conformance descriptor, which is just an associated
11191141
// conformance descriptor for a base protocol.
11201142
BaseConformance conformance(Proto, entry.getBase());

lib/IRGen/GenProto.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,10 +2349,10 @@ namespace {
23492349
B.addRelativeAddress(baseConformanceDescriptor);
23502350
} else if (entry.getKind() == SILWitnessTable::Method) {
23512351
// distributed thunks don't need resilience
2352-
if (entry.getMethodWitness().Requirement.isDistributedThunk()) {
2353-
witnesses = witnesses.drop_back();
2354-
continue;
2355-
}
2352+
// if (entry.getMethodWitness().Requirement.isDistributedThunk()) {
2353+
// witnesses = witnesses.drop_back();
2354+
// continue;
2355+
// }
23562356

23572357
// Method descriptor.
23582358
auto declRef = entry.getMethodWitness().Requirement;

test/Distributed/Runtime/distributed_actor_library_evolution_da_protocol_use.swift

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,76 @@
55
// RUN: %empty-directory(%t)
66
// RUN: split-file %s %t
77

8-
// RUN: %target-build-swift -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library -emit-library -emit-module-path %t/Library.swiftmodule -module-name Library %t/library.swift -o %t/%target-library-name(Library)
9-
// RUN: %target-build-swift -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library -lLibrary -module-name main -I %t -L %t %t/main.swift -o %t/a.out
8+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library -emit-library -emit-module-path %t/Library.swiftmodule -module-name Library %t/library.swift -o %t/%target-library-name(Library)
9+
10+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-irgen -o /tmp/irgen-evo
11+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-ir -o /tmp/ir-evo
12+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-sil -o /tmp/sil-evo
13+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-silgen -o /tmp/silgen-evo
14+
15+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-irgen -o /tmp/irgen-noevo
16+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-ir -o /tmp/ir-noevo
17+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-sil -o /tmp/sil-noevo
18+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -target %target-cpu-apple-macosx13.0 -parse-as-library %t/library.swift -module-name Library -emit-silgen -o /tmp/silgen-noevo
19+
20+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -enable-library-evolution -target %target-cpu-apple-macosx13.0 -parse-as-library -lLibrary -module-name main -I %t -L %t %t/main.swift -emit-irgen -o /tmp/app-irgen-evo
21+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -target %target-cpu-apple-macosx13.0 -parse-as-library -lLibrary -module-name main -I %t -L %t %t/main.swift -emit-irgen -o /tmp/app-irgen-noevo
22+
23+
// RUN: %target-build-swift -Xfrontend -validate-tbd-against-ir=none -target %target-cpu-apple-macosx13.0 -parse-as-library -lLibrary -module-name main -I %t -L %t %t/main.swift -o %t/a.out
24+
25+
1026
// RUN: %target-codesign %t/a.out
1127
// RUN: %target-run %t/a.out
1228

1329
//--- library.swift
1430
import Distributed
1531

32+
//public protocol NormalProtocol {
33+
// func NORMAL() async -> Int
34+
//}
35+
1636
public protocol SimpleProtocol: DistributedActor
1737
where ActorSystem == LocalTestingDistributedActorSystem {
1838

39+
// nonisolated override var id: ID { get } // comes from DistributedActor
40+
1941
// Has to have a distributed method to fail
2042
distributed func test() -> Int
2143
}
2244

23-
2445
//--- main.swift
2546
import Distributed
2647
import Library
2748

49+
//actor NormalActor: NormalProtocol {
50+
// func NORMAL() async -> Int { 1 }
51+
//}
52+
2853
public distributed actor SimpleActor: SimpleProtocol {
29-
public distributed func test() -> Int {
30-
1
31-
}
54+
public distributed func test() -> Int { 1 }
3255
}
3356

3457
// Passes
35-
public func makeFromPass<Act>(_ act: Act) where Act: DistributedActor {
58+
public func makeFromPass<Act: DistributedActor>(_ act: Act) {
3659
print(act.id)
3760
}
3861

3962
// Fails
40-
public func makeFromFail<Act>(_ act: Act) where Act: SimpleProtocol {
63+
public func makeFromFail<Act: SimpleProtocol>(_ act: Act) async {
4164
print(act.id)
65+
try! await print(act.test())
4266
}
4367

4468
@main
4569
struct TestSwiftFrameworkTests {
46-
static func main() {
70+
static func main() async {
4771
let system = LocalTestingDistributedActorSystem()
4872

73+
// let norm = NormalActor()
74+
4975
let simpleActor = SimpleActor(actorSystem: system)
50-
makeFromPass(simpleActor)
76+
// makeFromPass(simpleActor)
5177

52-
makeFromFail(simpleActor)
78+
await makeFromFail(simpleActor)
5379
}
5480
}

0 commit comments

Comments
 (0)