Skip to content

Commit 0d4afc8

Browse files
committed
towards distributed getters
1 parent 2747a8b commit 0d4afc8

File tree

11 files changed

+268
-138
lines changed

11 files changed

+268
-138
lines changed

include/swift/AST/StorageImpl.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ class AccessStrategy {
111111
/// a Write access back into the storage.
112112
MaterializeToTemporary,
113113

114-
/// The access is to a computed distributed property, and thus the
115-
/// get-accessor is a distributed thunk which may perform a remote call.
116-
DirectToDistributedThunkAccessor,
114+
// /// The access is to a computed distributed property, and thus the
115+
// /// get-accessor is a distributed thunk which may perform a remote call.
116+
// DirectToDistributedThunkAccessor,
117117
};
118118

119119
private:
@@ -153,10 +153,10 @@ class AccessStrategy {
153153
return { dispatched ? DispatchToAccessor : DirectToAccessor, accessor };
154154
}
155155

156-
static AccessStrategy getDistributedGetAccessor(AccessorKind accessor) {
157-
assert(accessor == AccessorKind::Get);
158-
return { DirectToDistributedThunkAccessor, accessor };
159-
}
156+
// static AccessStrategy getDistributedGetAccessor(AccessorKind accessor) {
157+
// assert(accessor == AccessorKind::Get);
158+
// return { DirectToDistributedThunkAccessor, accessor };
159+
// }
160160
static AccessStrategy getMaterializeToTemporary(AccessStrategy read,
161161
AccessStrategy write) {
162162
return { read, write };

lib/AST/Decl.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,16 +2138,16 @@ getDirectReadAccessStrategy(const AbstractStorageDecl *storage) {
21382138
llvm_unreachable("bad impl kind");
21392139
}
21402140

2141-
static AccessStrategy
2142-
getDirectToDistributedThunkAccessorStrategy(const AbstractStorageDecl *storage) {
2143-
switch (storage->getReadImpl()) {
2144-
case ReadImplKind::Get:
2145-
return AccessStrategy::getDistributedGetAccessor(AccessorKind::Get);
2146-
default:
2147-
llvm_unreachable("bad impl kind for distributed property accessor");
2148-
}
2149-
llvm_unreachable("bad impl kind for distributed property accessor");
2150-
}
2141+
//static AccessStrategy
2142+
//getDirectToDistributedThunkAccessorStrategy(const AbstractStorageDecl *storage) {
2143+
// switch (storage->getReadImpl()) {
2144+
// case ReadImplKind::Get:
2145+
// return AccessStrategy::getDistributedGetAccessor(AccessorKind::Get);
2146+
// default:
2147+
// llvm_unreachable("bad impl kind for distributed property accessor");
2148+
// }
2149+
// llvm_unreachable("bad impl kind for distributed property accessor");
2150+
//}
21512151

21522152
static AccessStrategy
21532153
getDirectWriteAccessStrategy(const AbstractStorageDecl *storage) {
@@ -2282,13 +2282,13 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
22822282
if (shouldUseNativeDynamicDispatch())
22832283
return getOpaqueAccessStrategy(this, accessKind, /*dispatch*/ false);
22842284

2285-
if (auto var = dyn_cast<VarDecl>(this)) {
2286-
if (var->isDistributed()) {
2287-
fprintf(stderr, "[%s:%d] (%s) DIST STRATEGY!!\n", __FILE__, __LINE__, __FUNCTION__);
2288-
var->dump();
2289-
return getDirectToDistributedThunkAccessorStrategy(this);
2290-
}
2291-
}
2285+
// if (auto var = dyn_cast<VarDecl>(this)) {
2286+
// if (var->isDistributed()) {
2287+
// fprintf(stderr, "[%s:%d] (%s) DIST STRATEGY!!\n", __FILE__, __LINE__, __FUNCTION__);
2288+
// var->dump();
2289+
// return getDirectToDistributedThunkAccessorStrategy(this);
2290+
// }
2291+
// }
22922292

22932293
// If the storage is resilient from the given module and resilience
22942294
// expansion, we cannot use direct access.

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ SILGenModule::canStorageUseStoredKeyPathComponent(AbstractStorageDecl *decl,
18351835
case AccessStrategy::DirectToAccessor:
18361836
case AccessStrategy::DispatchToAccessor:
18371837
case AccessStrategy::MaterializeToTemporary:
1838-
case AccessStrategy::DirectToDistributedThunkAccessor:
1838+
// case AccessStrategy::DirectToDistributedThunkAccessor:
18391839
return false;
18401840
}
18411841
llvm_unreachable("unhandled strategy");

lib/SILGen/SILGenApply.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5368,6 +5368,7 @@ static Callee getBaseAccessorFunctionRef(SILGenFunction &SGF,
53685368
ArgumentSource &selfValue,
53695369
bool isSuper,
53705370
bool isDirectUse,
5371+
bool isDistributed,
53715372
SubstitutionMap subs,
53725373
bool isOnSelfParameter) {
53735374
auto *decl = cast<AbstractFunctionDecl>(constant.getDecl());
@@ -5447,12 +5448,13 @@ emitSpecializedAccessorFunctionRef(SILGenFunction &SGF,
54475448
ArgumentSource &selfValue,
54485449
bool isSuper,
54495450
bool isDirectUse,
5451+
bool isDistributed,
54505452
bool isOnSelfParameter)
54515453
{
54525454
// Get the accessor function. The type will be a polymorphic function if
54535455
// the Self type is generic.
54545456
Callee callee = getBaseAccessorFunctionRef(SGF, loc, constant, selfValue,
5455-
isSuper, isDirectUse,
5457+
isSuper, isDirectUse, isDistributed,
54565458
substitutions, isOnSelfParameter);
54575459

54585460
// Collect captures if the accessor has them.
@@ -5764,23 +5766,23 @@ SILDeclRef SILGenModule::getAccessorDeclRef(AccessorDecl *accessor) {
57645766
RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
57655767
SubstitutionMap substitutions,
57665768
ArgumentSource &&selfValue, bool isSuper,
5767-
bool isDirectUse,
5769+
bool isDirectUse, bool isDistributed,
57685770
PreparedArguments &&subscriptIndices,
57695771
SGFContext c,
5770-
bool isOnSelfParameter,
5771-
bool shouldUseDistributedThunk) {
5772+
bool isOnSelfParameter) {
57725773
// Scope any further writeback just within this operation.
57735774
FormalEvaluationScope writebackScope(*this);
57745775

57755776
auto constant = get;
5776-
if (shouldUseDistributedThunk) {
5777-
get.dump();
5778-
assert(false && "should use dist thunk");
5779-
}
5777+
5778+
// if (isDistributed) {
5779+
// get.dump();
5780+
// assert(false && "should use dist thunk");
5781+
// }
57805782

57815783
Callee getter = emitSpecializedAccessorFunctionRef(
57825784
*this, loc, constant, substitutions, selfValue, isSuper, isDirectUse,
5783-
isOnSelfParameter);
5785+
isDistributed, isOnSelfParameter);
57845786
bool hasSelf = (bool)selfValue;
57855787
CanAnyFunctionType accessType = getter.getSubstFormalType();
57865788

@@ -5813,7 +5815,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58135815

58145816
Callee setter = emitSpecializedAccessorFunctionRef(
58155817
*this, loc, set, substitutions, selfValue, isSuper, isDirectUse,
5816-
isOnSelfParameter);
5818+
/*isDistributed=*/false, isOnSelfParameter);
58175819
bool hasSelf = (bool)selfValue;
58185820
CanAnyFunctionType accessType = setter.getSubstFormalType();
58195821

@@ -5848,14 +5850,14 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58485850
ManagedValue SILGenFunction::emitAddressorAccessor(
58495851
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
58505852
ArgumentSource &&selfValue, bool isSuper, bool isDirectUse,
5851-
PreparedArguments &&subscriptIndices, SILType addressType,
5852-
bool isOnSelfParameter) {
5853+
bool isDistributed, PreparedArguments &&subscriptIndices,
5854+
SILType addressType, bool isOnSelfParameter) {
58535855
// Scope any further writeback just within this operation.
58545856
FormalEvaluationScope writebackScope(*this);
58555857

58565858
Callee callee = emitSpecializedAccessorFunctionRef(
58575859
*this, loc, addressor, substitutions, selfValue, isSuper, isDirectUse,
5858-
isOnSelfParameter);
5860+
isDistributed, isOnSelfParameter);
58595861
bool hasSelf = (bool)selfValue;
58605862
CanAnyFunctionType accessType = callee.getSubstFormalType();
58615863

@@ -5910,7 +5912,9 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
59105912
Callee callee =
59115913
emitSpecializedAccessorFunctionRef(*this, loc, accessor,
59125914
substitutions, selfValue,
5913-
isSuper, isDirectUse, isOnSelfParameter);
5915+
isSuper, isDirectUse,
5916+
/*isDistributed=*/false,
5917+
isOnSelfParameter);
59145918

59155919
// We're already in a full formal-evaluation scope.
59165920
// Make a dead writeback scope; applyCoroutine won't try to pop this.

lib/SILGen/SILGenExpr.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,23 +3501,23 @@ getIdForKeyPathComponentComputedProperty(SILGenModule &SGM,
35013501
// stable identifier.
35023502
return SGM.getFunction(getterRef, NotForDefinition);
35033503
}
3504-
case AccessStrategy::DirectToDistributedThunkAccessor: {
3505-
assert(false && "dont need this");
3506-
// Locate the distributed thunk for the getter of this property
3507-
fprintf(stderr, "[%s:%d] (%s) CHECKING.... DirectToDistributedThunkAccessor\n", __FILE__, __LINE__, __FUNCTION__);
3508-
auto representativeDecl = getRepresentativeAccessorForKeyPath(storage);
3509-
assert(representativeDecl->isDistributed());
3510-
fprintf(stderr, "[%s:%d] (%s) OK, representative is DIST\n", __FILE__, __LINE__, __FUNCTION__);
3511-
3512-
auto getterThunkRef = SILDeclRef(representativeDecl->getDistributedThunk(),
3513-
SILDeclRef::Kind::Func,
3514-
/*isForeign=*/false,
3515-
/*isDistributed=*/true);
3516-
fprintf(stderr, "[%s:%d] (%s) THUNK\n", __FILE__, __LINE__, __FUNCTION__);
3517-
getterThunkRef.dump();
3518-
3519-
return SGM.getFunction(getterThunkRef, NotForDefinition);
3520-
}
3504+
// case AccessStrategy::DirectToDistributedThunkAccessor: {
3505+
// assert(false && "dont need this");
3506+
// // Locate the distributed thunk for the getter of this property
3507+
// fprintf(stderr, "[%s:%d] (%s) CHECKING.... DirectToDistributedThunkAccessor\n", __FILE__, __LINE__, __FUNCTION__);
3508+
// auto representativeDecl = getRepresentativeAccessorForKeyPath(storage);
3509+
// assert(representativeDecl->isDistributed());
3510+
// fprintf(stderr, "[%s:%d] (%s) OK, representative is DIST\n", __FILE__, __LINE__, __FUNCTION__);
3511+
//
3512+
// auto getterThunkRef = SILDeclRef(representativeDecl->getDistributedThunk(),
3513+
// SILDeclRef::Kind::Func,
3514+
// /*isForeign=*/false,
3515+
// /*isDistributed=*/true);
3516+
// fprintf(stderr, "[%s:%d] (%s) THUNK\n", __FILE__, __LINE__, __FUNCTION__);
3517+
// getterThunkRef.dump();
3518+
//
3519+
// return SGM.getFunction(getterThunkRef, NotForDefinition);
3520+
// }
35213521
case AccessStrategy::DispatchToAccessor: {
35223522
// Identify the property by its vtable or wtable slot.
35233523
return SGM.getAccessorDeclRef(getRepresentativeAccessorForKeyPath(storage));

lib/SILGen/SILGenFunction.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,9 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
14441444
SubstitutionMap substitutions,
14451445
ArgumentSource &&optionalSelfValue, bool isSuper,
14461446
bool isDirectAccessorUse,
1447+
bool isDistributed,
14471448
PreparedArguments &&optionalSubscripts, SGFContext C,
1448-
bool isOnSelfParameter,
1449-
bool shouldUseDistributedThunk);
1449+
bool isOnSelfParameter);
14501450

14511451
void emitSetAccessor(SILLocation loc, SILDeclRef setter,
14521452
SubstitutionMap substitutions,
@@ -1478,7 +1478,8 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
14781478
ManagedValue emitAddressorAccessor(
14791479
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
14801480
ArgumentSource &&optionalSelfValue, bool isSuper,
1481-
bool isDirectAccessorUse, PreparedArguments &&optionalSubscripts,
1481+
bool isDirectAccessorUse, bool isDistributed,
1482+
PreparedArguments &&optionalSubscripts,
14821483
SILType addressType, bool isOnSelfParameter);
14831484

14841485
CleanupHandle emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,

0 commit comments

Comments
 (0)