@@ -70,6 +70,7 @@ static SILValue emitActorPropertyOrWitnessReference(
70
70
SILLocation loc, SILValue base,
71
71
NominalTypeDecl *selfTyDecl,
72
72
SILType propertyType, Identifier identifier) {
73
+ fprintf (stderr, " [%s:%d] (%s) emitActorPropertyOrWitnessReference !!!\n " , __FILE__, __LINE__, __FUNCTION__);
73
74
// / If we're a class, just get the local property VarDecl and refer to it
74
75
if (auto clazz = dyn_cast<ClassDecl>(selfTyDecl)) {
75
76
return emitActorPropertyReference (
@@ -127,9 +128,8 @@ static SILValue emitActorPropertyOrWitnessReference(
127
128
128
129
// === Make a reference to the getter
129
130
// --- buffer for the system to be stored
130
- Optional<SILValue> temporaryResultBuffer;
131
131
auto buf = B.createAllocStack (loc, propertyType, None);
132
- temporaryResultBuffer = SILValue (buf);
132
+ SILValue temporaryResultBuffer = SILValue (buf);
133
133
134
134
// %5 = witness_method $Self, #DistributedActor.actorSystem!getter : <Self where Self : DistributedActor> (Self) -> () -> Self.ActorSystem : $@convention(witness_method: DistributedActor) <τ_0_0 where τ_0_0 : DistributedActor> (@in_guaranteed τ_0_0) -> @out τ_0_0.ActorSystem
135
135
auto witnessMethod = B.createWitnessMethod (
@@ -163,27 +163,35 @@ static SILValue emitActorPropertyOrWitnessReference(
163
163
subs = SubstitutionMap::get (genericSig, subTypes, subConformances);
164
164
}
165
165
166
- SmallVector<SILValue, 2 > allArgs;
167
- if (temporaryResultBuffer.hasValue ()) {
168
- allArgs.push_back (temporaryResultBuffer.getValue ());
169
- }
170
- allArgs.push_back (base); // self
166
+ SmallVector<SILValue, 2 > allArgs = {
167
+ temporaryResultBuffer, // buffer for the property to be read into
168
+ base, // self
169
+ };
171
170
172
171
// --- Apply the getter
173
172
// %6 = apply %5<Self>(%4, %2) : $@convention(witness_method: DistributedActor) <τ_0_0 where τ_0_0 : DistributedActor> (@in_guaranteed τ_0_0) -> @out τ_0_0.ActorSystem
174
173
auto apply = B.createApply ( loc, witnessMethod, subs, allArgs);
175
174
apply->dump ();
176
175
176
+
177
+
178
+ auto loadedProperty = B.emitLoadValueOperation (loc, temporaryResultBuffer, LoadOwnershipQualifier::Take);
179
+ fprintf (stderr, " [%s:%d] (%s) THE LOAD TAKE\n " , __FILE__, __LINE__, __FUNCTION__);
180
+ loadedProperty->dump ();
181
+
182
+ // SGF.enterDestroyCleanup(loadedProperty);
183
+ SGF.enterDeallocStackCleanup (temporaryResultBuffer);
184
+
177
185
// --- Cleanup base buffer
178
- if (temporaryResultBuffer) {
179
- auto value = B.emitLoadValueOperation (
180
- loc, *temporaryResultBuffer, LoadOwnershipQualifier::Take);
181
- B.emitDestroyValueOperation (loc, value);
182
- B.createDeallocStack (loc, *temporaryResultBuffer);
183
- }
186
+ // if (temporaryResultBuffer) {
187
+ // auto value = B.emitLoadValueOperation(
188
+ // loc, *temporaryResultBuffer, LoadOwnershipQualifier::Take);
189
+ // B.emitDestroyValueOperation(loc, value);
190
+ // B.createDeallocStack(loc, *temporaryResultBuffer);
191
+ // }
184
192
185
193
// %7 = load [trivial] %4 : $*SYSTEM_IMPL
186
- return B. emitLoadValueOperation (loc, *temporaryResultBuffer, LoadOwnershipQualifier::Take) ;
194
+ return loadedProperty ;
187
195
}
188
196
189
197
llvm_unreachable (" Unsupported self type decl!" );
@@ -956,29 +964,31 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
956
964
// %4 = alloc_stack $SYSTEM_IMPL // users: %9, %7, %6
957
965
// %5 = witness_method $Self, #DistributedActor.actorSystem!getter : <Self where Self : DistributedActor> (Self) -> () -> Self.ActorSystem : $@convention(witness_method: DistributedActor) <τ_0_0 where τ_0_0 : DistributedActor> (@in_guaranteed τ_0_0) -> @out τ_0_0.ActorSystem // user: %6
958
966
// %6 = apply %5<Self>(%4, %2) : $@convention(witness_method: DistributedActor) <τ_0_0 where τ_0_0 : DistributedActor> (@in_guaranteed τ_0_0) -> @out τ_0_0.ActorSystem
967
+ fprintf (stderr, " [%s:%d] (%s) GET PROP FOR MAKE INVOCATIOn\n " , __FILE__, __LINE__, __FUNCTION__);
959
968
auto systemRef = emitActorPropertyOrWitnessReference (
960
969
*this , B, loc,
961
970
selfValue.getValue (), selfTyDecl,
962
971
systemSILTy, ctx.Id_actorSystem );
963
972
assert (systemRef && " Could not find actorSystem property or requirement" );
964
-
973
+ fprintf (stderr, " [%s:%d] (%s) SYSTEM REF\n " , __FILE__, __LINE__, __FUNCTION__);
974
+ systemRef->dump ();
965
975
auto actorSystemTy = systemRef->getType ();
966
976
967
977
// FIXME: this is wrong for struct with values, and classes?
968
978
// %17 = load %16 : $*FakeActorSystem // users: %21, %20, %18
969
- SILValue systemLoaded;
970
- if (actorSystemTy.isAddressOnly (F)) {
971
- assert (false && " isAddressOnly" );
972
- } else {
973
- if (actorSystemTy.isAddress ()) {
974
- systemLoaded = B.createTrivialLoadOr (
975
- loc, systemRef, LoadOwnershipQualifier::Copy);
976
- } else {
977
- systemLoaded = B.emitCopyValueOperation (loc, systemRef);
978
- // actorSystemTy.dump();
979
- // llvm_unreachable("Cannot support non address actor system here?");
980
- }
981
- }
979
+ // SILValue systemLoaded;
980
+ // if (actorSystemTy.isAddressOnly(F)) {
981
+ // assert(false && "isAddressOnly");
982
+ // } else {
983
+ // if (actorSystemTy.isAddress()) {
984
+ // systemLoaded = B.createTrivialLoadOr(
985
+ // loc, systemRef, LoadOwnershipQualifier::Copy);
986
+ // } else {
987
+ // systemLoaded = B.emitCopyValueOperation(loc, systemRef);
988
+ // // actorSystemTy.dump();
989
+ // // llvm_unreachable("Cannot support non address actor system here?");
990
+ // }
991
+ // }
982
992
983
993
// function_ref FakeActorSystem.makeInvocationEncoder()
984
994
// %19 = function_ref @$s27FakeDistributedActorSystems0aC6SystemV21makeInvocationEncoderAA0aG0VyF : $@convention(method) (@guaranteed FakeActorSystem) -> FakeInvocation // user: %20
@@ -991,11 +1001,18 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
991
1001
ApplyInst *invocationEncoderValue = B.createApply (
992
1002
loc, makeInvocationEncoderFn,
993
1003
/* subs=*/ SubstitutionMap (),
994
- /* args=*/ {systemLoaded});
1004
+ // /*args=*/{systemLoaded});
1005
+ /* args=*/ {systemRef});
1006
+
1007
+ // if (!systemLoaded->getType().isTrivial(F) ||
1008
+ // ((!actorSystemTy.isAddressOnly(F)) && (!actorSystemTy.isAddress()))) {
1009
+ // fprintf(stderr, "[%s:%d] (%s) DESTROY\n", __FILE__, __LINE__, __FUNCTION__);
1010
+ // B.createDestroyValue(loc, systemLoaded);
1011
+ // // B.createEndLifetime(loc, systemLoaded);
1012
+ // }
995
1013
996
- if (!systemLoaded->getType ().isTrivial (F))
997
- B.createDestroyValue (loc, systemLoaded);
998
- // B.createEndLifetime(loc, systemLoaded);
1014
+ B.emitDestroyValueOperation (loc, systemRef);
1015
+ // B.createDeallocStack(loc, systemRef);
999
1016
1000
1017
// FIXME(distributed): cannot deal with class yet
1001
1018
// TODO(distributed): make into "emit apropriate store"
@@ -1529,12 +1546,12 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
1529
1546
// auto systemRef = emitActorPropertyReference(
1530
1547
// *this, loc, selfValue.getValue(),
1531
1548
// lookupProperty(selfTyDecl, ctx.Id_actorSystem));
1549
+ fprintf (stderr, " [%s:%d] (%s) GET PROP FOR REMOTE CALL\n " , __FILE__, __LINE__, __FUNCTION__);
1532
1550
systemRef = emitActorPropertyOrWitnessReference (
1533
1551
*this , B, loc,
1534
1552
selfValue.getValue (), selfTyDecl,
1535
1553
systemSILTy, ctx.Id_actorSystem );
1536
1554
assert (systemRef);
1537
- F.dump ();
1538
1555
// remoteCallSystemSelf = B.createTrivialLoadOr(loc, systemRef, LoadOwnershipQualifier::Copy);
1539
1556
1540
1557
// --- Prepare 'throwing' type, Error or Never depending on throws of the target
@@ -1672,6 +1689,7 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
1672
1689
// B.createDestroyValue(loc, remoteCallSystemSelf);
1673
1690
// if (remoteCallSystemSelf->getType().isAddress())
1674
1691
// B.createEndLifetime(loc, remoteCallSystemSelf);
1692
+ B.emitDestroyValueOperation (loc, systemRef);
1675
1693
1676
1694
B.createEndAccess (loc, invocationEncoderAccess, /* aborted=*/ false );
1677
1695
Cleanups.emitCleanupsForReturn (CleanupLocation (loc), NotForUnwind);
@@ -1695,6 +1713,7 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
1695
1713
// B.createDestroyValue(loc, remoteCallSystemSelf);
1696
1714
// if (remoteCallSystemSelf->getType().isAddress())
1697
1715
// B.createEndLifetime(loc, remoteCallSystemSelf);
1716
+ B.emitDestroyValueOperation (loc, systemRef);
1698
1717
1699
1718
Cleanups.emitCleanupsForReturn (CleanupLocation (loc), IsForUnwind);
1700
1719
0 commit comments