Skip to content

Commit c24e64c

Browse files
committed
towards distributed getters
1 parent be58051 commit c24e64c

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
@@ -2137,16 +2137,16 @@ getDirectReadAccessStrategy(const AbstractStorageDecl *storage) {
21372137
llvm_unreachable("bad impl kind");
21382138
}
21392139

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

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

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

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

lib/SILGen/SILGen.cpp

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

lib/SILGen/SILGenApply.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5385,6 +5385,7 @@ static Callee getBaseAccessorFunctionRef(SILGenFunction &SGF,
53855385
ArgumentSource &selfValue,
53865386
bool isSuper,
53875387
bool isDirectUse,
5388+
bool isDistributed,
53885389
SubstitutionMap subs,
53895390
bool isOnSelfParameter) {
53905391
auto *decl = cast<AbstractFunctionDecl>(constant.getDecl());
@@ -5464,12 +5465,13 @@ emitSpecializedAccessorFunctionRef(SILGenFunction &SGF,
54645465
ArgumentSource &selfValue,
54655466
bool isSuper,
54665467
bool isDirectUse,
5468+
bool isDistributed,
54675469
bool isOnSelfParameter)
54685470
{
54695471
// Get the accessor function. The type will be a polymorphic function if
54705472
// the Self type is generic.
54715473
Callee callee = getBaseAccessorFunctionRef(SGF, loc, constant, selfValue,
5472-
isSuper, isDirectUse,
5474+
isSuper, isDirectUse, isDistributed,
54735475
substitutions, isOnSelfParameter);
54745476

54755477
// Collect captures if the accessor has them.
@@ -5781,23 +5783,23 @@ SILDeclRef SILGenModule::getAccessorDeclRef(AccessorDecl *accessor) {
57815783
RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
57825784
SubstitutionMap substitutions,
57835785
ArgumentSource &&selfValue, bool isSuper,
5784-
bool isDirectUse,
5786+
bool isDirectUse, bool isDistributed,
57855787
PreparedArguments &&subscriptIndices,
57865788
SGFContext c,
5787-
bool isOnSelfParameter,
5788-
bool shouldUseDistributedThunk) {
5789+
bool isOnSelfParameter) {
57895790
// Scope any further writeback just within this operation.
57905791
FormalEvaluationScope writebackScope(*this);
57915792

57925793
auto constant = get;
5793-
if (shouldUseDistributedThunk) {
5794-
get.dump();
5795-
assert(false && "should use dist thunk");
5796-
}
5794+
5795+
// if (isDistributed) {
5796+
// get.dump();
5797+
// assert(false && "should use dist thunk");
5798+
// }
57975799

57985800
Callee getter = emitSpecializedAccessorFunctionRef(
57995801
*this, loc, constant, substitutions, selfValue, isSuper, isDirectUse,
5800-
isOnSelfParameter);
5802+
isDistributed, isOnSelfParameter);
58015803
bool hasSelf = (bool)selfValue;
58025804
CanAnyFunctionType accessType = getter.getSubstFormalType();
58035805

@@ -5830,7 +5832,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58305832

58315833
Callee setter = emitSpecializedAccessorFunctionRef(
58325834
*this, loc, set, substitutions, selfValue, isSuper, isDirectUse,
5833-
isOnSelfParameter);
5835+
/*isDistributed=*/false, isOnSelfParameter);
58345836
bool hasSelf = (bool)selfValue;
58355837
CanAnyFunctionType accessType = setter.getSubstFormalType();
58365838

@@ -5865,14 +5867,14 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58655867
ManagedValue SILGenFunction::emitAddressorAccessor(
58665868
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
58675869
ArgumentSource &&selfValue, bool isSuper, bool isDirectUse,
5868-
PreparedArguments &&subscriptIndices, SILType addressType,
5869-
bool isOnSelfParameter) {
5870+
bool isDistributed, PreparedArguments &&subscriptIndices,
5871+
SILType addressType, bool isOnSelfParameter) {
58705872
// Scope any further writeback just within this operation.
58715873
FormalEvaluationScope writebackScope(*this);
58725874

58735875
Callee callee = emitSpecializedAccessorFunctionRef(
58745876
*this, loc, addressor, substitutions, selfValue, isSuper, isDirectUse,
5875-
isOnSelfParameter);
5877+
isDistributed, isOnSelfParameter);
58765878
bool hasSelf = (bool)selfValue;
58775879
CanAnyFunctionType accessType = callee.getSubstFormalType();
58785880

@@ -5927,7 +5929,9 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
59275929
Callee callee =
59285930
emitSpecializedAccessorFunctionRef(*this, loc, accessor,
59295931
substitutions, selfValue,
5930-
isSuper, isDirectUse, isOnSelfParameter);
5932+
isSuper, isDirectUse,
5933+
/*isDistributed=*/false,
5934+
isOnSelfParameter);
59315935

59325936
// We're already in a full formal-evaluation scope.
59335937
// 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
@@ -3444,23 +3444,23 @@ getIdForKeyPathComponentComputedProperty(SILGenModule &SGM,
34443444
// stable identifier.
34453445
return SGM.getFunction(getterRef, NotForDefinition);
34463446
}
3447-
case AccessStrategy::DirectToDistributedThunkAccessor: {
3448-
assert(false && "dont need this");
3449-
// Locate the distributed thunk for the getter of this property
3450-
fprintf(stderr, "[%s:%d] (%s) CHECKING.... DirectToDistributedThunkAccessor\n", __FILE__, __LINE__, __FUNCTION__);
3451-
auto representativeDecl = getRepresentativeAccessorForKeyPath(storage);
3452-
assert(representativeDecl->isDistributed());
3453-
fprintf(stderr, "[%s:%d] (%s) OK, representative is DIST\n", __FILE__, __LINE__, __FUNCTION__);
3454-
3455-
auto getterThunkRef = SILDeclRef(representativeDecl->getDistributedThunk(),
3456-
SILDeclRef::Kind::Func,
3457-
/*isForeign=*/false,
3458-
/*isDistributed=*/true);
3459-
fprintf(stderr, "[%s:%d] (%s) THUNK\n", __FILE__, __LINE__, __FUNCTION__);
3460-
getterThunkRef.dump();
3461-
3462-
return SGM.getFunction(getterThunkRef, NotForDefinition);
3463-
}
3447+
// case AccessStrategy::DirectToDistributedThunkAccessor: {
3448+
// assert(false && "dont need this");
3449+
// // Locate the distributed thunk for the getter of this property
3450+
// fprintf(stderr, "[%s:%d] (%s) CHECKING.... DirectToDistributedThunkAccessor\n", __FILE__, __LINE__, __FUNCTION__);
3451+
// auto representativeDecl = getRepresentativeAccessorForKeyPath(storage);
3452+
// assert(representativeDecl->isDistributed());
3453+
// fprintf(stderr, "[%s:%d] (%s) OK, representative is DIST\n", __FILE__, __LINE__, __FUNCTION__);
3454+
//
3455+
// auto getterThunkRef = SILDeclRef(representativeDecl->getDistributedThunk(),
3456+
// SILDeclRef::Kind::Func,
3457+
// /*isForeign=*/false,
3458+
// /*isDistributed=*/true);
3459+
// fprintf(stderr, "[%s:%d] (%s) THUNK\n", __FILE__, __LINE__, __FUNCTION__);
3460+
// getterThunkRef.dump();
3461+
//
3462+
// return SGM.getFunction(getterThunkRef, NotForDefinition);
3463+
// }
34643464
case AccessStrategy::DispatchToAccessor: {
34653465
// Identify the property by its vtable or wtable slot.
34663466
return SGM.getAccessorDeclRef(getRepresentativeAccessorForKeyPath(storage));

lib/SILGen/SILGenFunction.h

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

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

14831484
CleanupHandle emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,

0 commit comments

Comments
 (0)