Skip to content

Commit a91f63e

Browse files
ktosoxedin
authored andcommitted
towards distributed getters
1 parent ddf3aee commit a91f63e

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
@@ -2151,16 +2151,16 @@ getDirectReadAccessStrategy(const AbstractStorageDecl *storage) {
21512151
llvm_unreachable("bad impl kind");
21522152
}
21532153

2154-
static AccessStrategy
2155-
getDirectToDistributedThunkAccessorStrategy(const AbstractStorageDecl *storage) {
2156-
switch (storage->getReadImpl()) {
2157-
case ReadImplKind::Get:
2158-
return AccessStrategy::getDistributedGetAccessor(AccessorKind::Get);
2159-
default:
2160-
llvm_unreachable("bad impl kind for distributed property accessor");
2161-
}
2162-
llvm_unreachable("bad impl kind for distributed property accessor");
2163-
}
2154+
//static AccessStrategy
2155+
//getDirectToDistributedThunkAccessorStrategy(const AbstractStorageDecl *storage) {
2156+
// switch (storage->getReadImpl()) {
2157+
// case ReadImplKind::Get:
2158+
// return AccessStrategy::getDistributedGetAccessor(AccessorKind::Get);
2159+
// default:
2160+
// llvm_unreachable("bad impl kind for distributed property accessor");
2161+
// }
2162+
// llvm_unreachable("bad impl kind for distributed property accessor");
2163+
//}
21642164

21652165
static AccessStrategy
21662166
getDirectWriteAccessStrategy(const AbstractStorageDecl *storage) {
@@ -2295,13 +2295,13 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
22952295
if (shouldUseNativeDynamicDispatch())
22962296
return getOpaqueAccessStrategy(this, accessKind, /*dispatch*/ false);
22972297

2298-
if (auto var = dyn_cast<VarDecl>(this)) {
2299-
if (var->isDistributed()) {
2300-
fprintf(stderr, "[%s:%d] (%s) DIST STRATEGY!!\n", __FILE__, __LINE__, __FUNCTION__);
2301-
var->dump();
2302-
return getDirectToDistributedThunkAccessorStrategy(this);
2303-
}
2304-
}
2298+
// if (auto var = dyn_cast<VarDecl>(this)) {
2299+
// if (var->isDistributed()) {
2300+
// fprintf(stderr, "[%s:%d] (%s) DIST STRATEGY!!\n", __FILE__, __LINE__, __FUNCTION__);
2301+
// var->dump();
2302+
// return getDirectToDistributedThunkAccessorStrategy(this);
2303+
// }
2304+
// }
23052305

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

lib/SILGen/SILGen.cpp

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

lib/SILGen/SILGenApply.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5377,6 +5377,7 @@ static Callee getBaseAccessorFunctionRef(SILGenFunction &SGF,
53775377
ArgumentSource &selfValue,
53785378
bool isSuper,
53795379
bool isDirectUse,
5380+
bool isDistributed,
53805381
SubstitutionMap subs,
53815382
bool isOnSelfParameter) {
53825383
auto *decl = cast<AbstractFunctionDecl>(constant.getDecl());
@@ -5456,12 +5457,13 @@ emitSpecializedAccessorFunctionRef(SILGenFunction &SGF,
54565457
ArgumentSource &selfValue,
54575458
bool isSuper,
54585459
bool isDirectUse,
5460+
bool isDistributed,
54595461
bool isOnSelfParameter)
54605462
{
54615463
// Get the accessor function. The type will be a polymorphic function if
54625464
// the Self type is generic.
54635465
Callee callee = getBaseAccessorFunctionRef(SGF, loc, constant, selfValue,
5464-
isSuper, isDirectUse,
5466+
isSuper, isDirectUse, isDistributed,
54655467
substitutions, isOnSelfParameter);
54665468

54675469
// Collect captures if the accessor has them.
@@ -5773,23 +5775,23 @@ SILDeclRef SILGenModule::getAccessorDeclRef(AccessorDecl *accessor) {
57735775
RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
57745776
SubstitutionMap substitutions,
57755777
ArgumentSource &&selfValue, bool isSuper,
5776-
bool isDirectUse,
5778+
bool isDirectUse, bool isDistributed,
57775779
PreparedArguments &&subscriptIndices,
57785780
SGFContext c,
5779-
bool isOnSelfParameter,
5780-
bool shouldUseDistributedThunk) {
5781+
bool isOnSelfParameter) {
57815782
// Scope any further writeback just within this operation.
57825783
FormalEvaluationScope writebackScope(*this);
57835784

57845785
auto constant = get;
5785-
if (shouldUseDistributedThunk) {
5786-
get.dump();
5787-
assert(false && "should use dist thunk");
5788-
}
5786+
5787+
// if (isDistributed) {
5788+
// get.dump();
5789+
// assert(false && "should use dist thunk");
5790+
// }
57895791

57905792
Callee getter = emitSpecializedAccessorFunctionRef(
57915793
*this, loc, constant, substitutions, selfValue, isSuper, isDirectUse,
5792-
isOnSelfParameter);
5794+
isDistributed, isOnSelfParameter);
57935795
bool hasSelf = (bool)selfValue;
57945796
CanAnyFunctionType accessType = getter.getSubstFormalType();
57955797

@@ -5822,7 +5824,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58225824

58235825
Callee setter = emitSpecializedAccessorFunctionRef(
58245826
*this, loc, set, substitutions, selfValue, isSuper, isDirectUse,
5825-
isOnSelfParameter);
5827+
/*isDistributed=*/false, isOnSelfParameter);
58265828
bool hasSelf = (bool)selfValue;
58275829
CanAnyFunctionType accessType = setter.getSubstFormalType();
58285830

@@ -5857,14 +5859,14 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58575859
ManagedValue SILGenFunction::emitAddressorAccessor(
58585860
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
58595861
ArgumentSource &&selfValue, bool isSuper, bool isDirectUse,
5860-
PreparedArguments &&subscriptIndices, SILType addressType,
5861-
bool isOnSelfParameter) {
5862+
bool isDistributed, PreparedArguments &&subscriptIndices,
5863+
SILType addressType, bool isOnSelfParameter) {
58625864
// Scope any further writeback just within this operation.
58635865
FormalEvaluationScope writebackScope(*this);
58645866

58655867
Callee callee = emitSpecializedAccessorFunctionRef(
58665868
*this, loc, addressor, substitutions, selfValue, isSuper, isDirectUse,
5867-
isOnSelfParameter);
5869+
isDistributed, isOnSelfParameter);
58685870
bool hasSelf = (bool)selfValue;
58695871
CanAnyFunctionType accessType = callee.getSubstFormalType();
58705872

@@ -5919,7 +5921,9 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
59195921
Callee callee =
59205922
emitSpecializedAccessorFunctionRef(*this, loc, accessor,
59215923
substitutions, selfValue,
5922-
isSuper, isDirectUse, isOnSelfParameter);
5924+
isSuper, isDirectUse,
5925+
/*isDistributed=*/false,
5926+
isOnSelfParameter);
59235927

59245928
// We're already in a full formal-evaluation scope.
59255929
// 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
@@ -3504,23 +3504,23 @@ getIdForKeyPathComponentComputedProperty(SILGenModule &SGM,
35043504
// stable identifier.
35053505
return SGM.getFunction(getterRef, NotForDefinition);
35063506
}
3507-
case AccessStrategy::DirectToDistributedThunkAccessor: {
3508-
assert(false && "dont need this");
3509-
// Locate the distributed thunk for the getter of this property
3510-
fprintf(stderr, "[%s:%d] (%s) CHECKING.... DirectToDistributedThunkAccessor\n", __FILE__, __LINE__, __FUNCTION__);
3511-
auto representativeDecl = getRepresentativeAccessorForKeyPath(storage);
3512-
assert(representativeDecl->isDistributed());
3513-
fprintf(stderr, "[%s:%d] (%s) OK, representative is DIST\n", __FILE__, __LINE__, __FUNCTION__);
3514-
3515-
auto getterThunkRef = SILDeclRef(representativeDecl->getDistributedThunk(),
3516-
SILDeclRef::Kind::Func,
3517-
/*isForeign=*/false,
3518-
/*isDistributed=*/true);
3519-
fprintf(stderr, "[%s:%d] (%s) THUNK\n", __FILE__, __LINE__, __FUNCTION__);
3520-
getterThunkRef.dump();
3521-
3522-
return SGM.getFunction(getterThunkRef, NotForDefinition);
3523-
}
3507+
// case AccessStrategy::DirectToDistributedThunkAccessor: {
3508+
// assert(false && "dont need this");
3509+
// // Locate the distributed thunk for the getter of this property
3510+
// fprintf(stderr, "[%s:%d] (%s) CHECKING.... DirectToDistributedThunkAccessor\n", __FILE__, __LINE__, __FUNCTION__);
3511+
// auto representativeDecl = getRepresentativeAccessorForKeyPath(storage);
3512+
// assert(representativeDecl->isDistributed());
3513+
// fprintf(stderr, "[%s:%d] (%s) OK, representative is DIST\n", __FILE__, __LINE__, __FUNCTION__);
3514+
//
3515+
// auto getterThunkRef = SILDeclRef(representativeDecl->getDistributedThunk(),
3516+
// SILDeclRef::Kind::Func,
3517+
// /*isForeign=*/false,
3518+
// /*isDistributed=*/true);
3519+
// fprintf(stderr, "[%s:%d] (%s) THUNK\n", __FILE__, __LINE__, __FUNCTION__);
3520+
// getterThunkRef.dump();
3521+
//
3522+
// return SGM.getFunction(getterThunkRef, NotForDefinition);
3523+
// }
35243524
case AccessStrategy::DispatchToAccessor: {
35253525
// Identify the property by its vtable or wtable slot.
35263526
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)