Skip to content

Commit a14f05e

Browse files
authored
Merge pull request swiftlang#59927 from DougGregor/sink-actor-hop-for-get-access-5.7
2 parents f5eff1a + 4af5105 commit a14f05e

File tree

4 files changed

+86
-92
lines changed

4 files changed

+86
-92
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5780,13 +5780,15 @@ SILDeclRef SILGenModule::getAccessorDeclRef(AccessorDecl *accessor) {
57805780
}
57815781

57825782
/// Emit a call to a getter.
5783-
RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
5784-
SubstitutionMap substitutions,
5785-
ArgumentSource &&selfValue, bool isSuper,
5786-
bool isDirectUse,
5787-
PreparedArguments &&subscriptIndices,
5788-
SGFContext c,
5789-
bool isOnSelfParameter) {
5783+
RValue SILGenFunction::emitGetAccessor(
5784+
SILLocation loc, SILDeclRef get,
5785+
SubstitutionMap substitutions,
5786+
ArgumentSource &&selfValue, bool isSuper,
5787+
bool isDirectUse,
5788+
PreparedArguments &&subscriptIndices,
5789+
SGFContext c,
5790+
bool isOnSelfParameter,
5791+
Optional<ImplicitActorHopTarget> implicitActorHopTarget) {
57905792
// Scope any further writeback just within this operation.
57915793
FormalEvaluationScope writebackScope(*this);
57925794

@@ -5797,6 +5799,9 @@ RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
57975799
CanAnyFunctionType accessType = getter.getSubstFormalType();
57985800

57995801
CallEmission emission(*this, std::move(getter), std::move(writebackScope));
5802+
if (implicitActorHopTarget)
5803+
emission.setImplicitlyAsync(implicitActorHopTarget);
5804+
58005805
// Self ->
58015806
if (hasSelf) {
58025807
emission.addSelfParam(loc, std::move(selfValue),

lib/SILGen/SILGenFunction.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,12 +1440,14 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
14401440
CanType baseFormalType,
14411441
SILDeclRef accessor);
14421442

1443-
RValue emitGetAccessor(SILLocation loc, SILDeclRef getter,
1444-
SubstitutionMap substitutions,
1445-
ArgumentSource &&optionalSelfValue, bool isSuper,
1446-
bool isDirectAccessorUse,
1447-
PreparedArguments &&optionalSubscripts, SGFContext C,
1448-
bool isOnSelfParameter);
1443+
RValue emitGetAccessor(
1444+
SILLocation loc, SILDeclRef getter,
1445+
SubstitutionMap substitutions,
1446+
ArgumentSource &&optionalSelfValue, bool isSuper,
1447+
bool isDirectAccessorUse,
1448+
PreparedArguments &&optionalSubscripts, SGFContext C,
1449+
bool isOnSelfParameter,
1450+
Optional<ImplicitActorHopTarget> implicitActorHopTarget = None);
14491451

14501452
void emitSetAccessor(SILLocation loc, SILDeclRef setter,
14511453
SubstitutionMap substitutions,

lib/SILGen/SILGenLValue.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,26 +1641,26 @@ namespace {
16411641
assert(getAccessorDecl()->isGetter());
16421642

16431643
SILDeclRef getter = Accessor;
1644-
ExecutorBreadcrumb prevExecutor;
16451644
RValue rvalue;
1646-
{
1647-
FormalEvaluationScope scope(SGF);
1648-
1649-
// If the 'get' is in the context of the target's actor, do a hop first.
1650-
prevExecutor = SGF.emitHopToTargetActor(loc, ActorIso, base);
1651-
1652-
auto args =
1653-
std::move(*this).prepareAccessorArgs(SGF, loc, base, getter);
1645+
FormalEvaluationScope scope(SGF);
16541646

1655-
rvalue = SGF.emitGetAccessor(
1656-
loc, getter, Substitutions, std::move(args.base), IsSuper,
1657-
IsDirectAccessorUse, std::move(args.Indices), c,
1658-
IsOnSelfParameter);
1647+
// FIXME: This somewhat silly, because the original expression should
1648+
// already have one of these.
1649+
Optional<ImplicitActorHopTarget> implicitActorHopTarget;
1650+
if (ActorIso) {
1651+
implicitActorHopTarget = ActorIso->isGlobalActor()
1652+
? ImplicitActorHopTarget::forGlobalActor(
1653+
ActorIso->getGlobalActor())
1654+
: ImplicitActorHopTarget::forInstanceSelf();
1655+
}
16591656

1660-
} // End the evaluation scope before any hop back to the current executor.
1657+
auto args =
1658+
std::move(*this).prepareAccessorArgs(SGF, loc, base, getter);
16611659

1662-
// If we hopped to the target's executor, then we need to hop back.
1663-
prevExecutor.emit(SGF, loc);
1660+
rvalue = SGF.emitGetAccessor(
1661+
loc, getter, Substitutions, std::move(args.base), IsSuper,
1662+
IsDirectAccessorUse, std::move(args.Indices), c,
1663+
IsOnSelfParameter, implicitActorHopTarget);
16641664

16651665
return rvalue;
16661666
}

0 commit comments

Comments
 (0)