Skip to content

Commit d516281

Browse files
committed
[Distributed] NFC: Remove Method from accessor APIs
The API is not constrained to methods only, it should support computed properties as well.
1 parent d1bb98b commit d516281

File tree

14 files changed

+73
-73
lines changed

14 files changed

+73
-73
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ASTMangler : public Mangler {
104104
SwiftAsObjCThunk,
105105
ObjCAsSwiftThunk,
106106
DistributedThunk,
107-
DistributedMethodAccessor,
107+
DistributedAccessor,
108108
AccessibleFunctionRecord
109109
};
110110

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ CONTEXT_NODE(Destructor)
7171
CONTEXT_NODE(DidSet)
7272
NODE(Directness)
7373
NODE(DistributedThunk)
74-
NODE(DistributedMethodAccessor)
74+
NODE(DistributedAccessor)
7575
NODE(DynamicAttribute)
7676
NODE(DirectMethodReferenceAttribute)
7777
NODE(DynamicSelf)

include/swift/IRGen/Linking.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ class LinkEntity {
483483
KnownAsyncFunctionPointer,
484484

485485
/// The pointer is SILFunction*
486-
DistributedMethodAccessor,
487-
/// An async function pointer for a distributed method accessor.
486+
DistributedAccessor,
487+
/// An async function pointer for a distributed accessor (method or property).
488488
/// The pointer is a SILFunction*.
489-
DistributedMethodAccessorAsyncPointer,
489+
DistributedAccessorAsyncPointer,
490490

491491
/// Accessible function record, which describes a function that can be
492492
/// looked up by name by the runtime.
@@ -1246,10 +1246,10 @@ class LinkEntity {
12461246
Kind, unsigned(LinkEntity::Kind::PartialApplyForwarderAsyncFunctionPointer));
12471247
break;
12481248

1249-
case LinkEntity::Kind::DistributedMethodAccessor: {
1249+
case LinkEntity::Kind::DistributedAccessor: {
12501250
entity.Data = LINKENTITY_SET_FIELD(
12511251
Kind,
1252-
unsigned(LinkEntity::Kind::DistributedMethodAccessorAsyncPointer));
1252+
unsigned(LinkEntity::Kind::DistributedAccessorAsyncPointer));
12531253
break;
12541254
}
12551255

@@ -1280,12 +1280,12 @@ class LinkEntity {
12801280
return entity;
12811281
}
12821282

1283-
static LinkEntity forDistributedMethodAccessor(SILFunction *method) {
1283+
static LinkEntity forDistributedTargetAccessor(SILFunction *target) {
12841284
LinkEntity entity;
1285-
entity.Pointer = method;
1285+
entity.Pointer = target;
12861286
entity.SecondaryPointer = nullptr;
12871287
entity.Data =
1288-
LINKENTITY_SET_FIELD(Kind, unsigned(Kind::DistributedMethodAccessor));
1288+
LINKENTITY_SET_FIELD(Kind, unsigned(Kind::DistributedAccessor));
12891289
return entity;
12901290
}
12911291

@@ -1329,9 +1329,9 @@ class LinkEntity {
13291329
Kind, unsigned(LinkEntity::Kind::PartialApplyForwarder));
13301330
break;
13311331

1332-
case LinkEntity::Kind::DistributedMethodAccessorAsyncPointer:
1332+
case LinkEntity::Kind::DistributedAccessorAsyncPointer:
13331333
entity.Data = LINKENTITY_SET_FIELD(
1334-
Kind, unsigned(LinkEntity::Kind::DistributedMethodAccessor));
1334+
Kind, unsigned(LinkEntity::Kind::DistributedAccessor));
13351335
break;
13361336

13371337
default:
@@ -1382,7 +1382,7 @@ class LinkEntity {
13821382
getKind() == Kind::DynamicallyReplaceableFunctionVariable ||
13831383
getKind() == Kind::DynamicallyReplaceableFunctionKey ||
13841384
getKind() == Kind::SILFunction ||
1385-
getKind() == Kind::DistributedMethodAccessor ||
1385+
getKind() == Kind::DistributedAccessor ||
13861386
getKind() == Kind::AccessibleFunctionRecord;
13871387
}
13881388

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ void ASTMangler::appendSymbolKind(SymbolKind SKind) {
849849
case SymbolKind::SwiftAsObjCThunk: return appendOperator("To");
850850
case SymbolKind::ObjCAsSwiftThunk: return appendOperator("TO");
851851
case SymbolKind::DistributedThunk: return appendOperator("TE");
852-
case SymbolKind::DistributedMethodAccessor: return appendOperator("TF");
852+
case SymbolKind::DistributedAccessor: return appendOperator("TF");
853853
case SymbolKind::AccessibleFunctionRecord: return appendOperator("HF");
854854
}
855855
}

lib/Demangling/Demangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ bool swift::Demangle::isFunctionAttr(Node::Kind kind) {
133133
case Node::Kind::OutlinedBridgedMethod:
134134
case Node::Kind::MergedFunction:
135135
case Node::Kind::DistributedThunk:
136-
case Node::Kind::DistributedMethodAccessor:
136+
case Node::Kind::DistributedAccessor:
137137
case Node::Kind::DynamicallyReplaceableFunctionImpl:
138138
case Node::Kind::DynamicallyReplaceableFunctionKey:
139139
case Node::Kind::DynamicallyReplaceableFunctionVar:
@@ -2367,7 +2367,7 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
23672367
case 'D': return createNode(Node::Kind::DynamicAttribute);
23682368
case 'd': return createNode(Node::Kind::DirectMethodReferenceAttribute);
23692369
case 'E': return createNode(Node::Kind::DistributedThunk);
2370-
case 'F': return createNode(Node::Kind::DistributedMethodAccessor);
2370+
case 'F': return createNode(Node::Kind::DistributedAccessor);
23712371
case 'a': return createNode(Node::Kind::PartialApplyObjCForwarder);
23722372
case 'A': return createNode(Node::Kind::PartialApplyForwarder);
23732373
case 'm': return createNode(Node::Kind::MergedFunction);

lib/Demangling/NodePrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class NodePrinter {
561561
case Node::Kind::ProtocolConformanceRefInProtocolModule:
562562
case Node::Kind::ProtocolConformanceRefInOtherModule:
563563
case Node::Kind::DistributedThunk:
564-
case Node::Kind::DistributedMethodAccessor:
564+
case Node::Kind::DistributedAccessor:
565565
case Node::Kind::DynamicallyReplaceableFunctionKey:
566566
case Node::Kind::DynamicallyReplaceableFunctionImpl:
567567
case Node::Kind::DynamicallyReplaceableFunctionVar:
@@ -2001,9 +2001,9 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
20012001
Printer << "distributed thunk for ";
20022002
}
20032003
return nullptr;
2004-
case Node::Kind::DistributedMethodAccessor:
2004+
case Node::Kind::DistributedAccessor:
20052005
if (!Options.ShortenThunk) {
2006-
Printer << "distributed method accessor for ";
2006+
Printer << "distributed accessor for ";
20072007
}
20082008
return nullptr;
20092009
case Node::Kind::AccessibleFunctionRecord:

lib/Demangling/OldRemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ Remangler::mangleDistributedThunk(Node *node, unsigned depth) {
736736
}
737737

738738
ManglingError
739-
Remangler::mangleDistributedMethodAccessor(Node *node, unsigned depth) {
739+
Remangler::mangleDistributedAccessor(Node *node, unsigned depth) {
740740
Buffer << "TF";
741741
return ManglingError::Success;
742742
}

lib/Demangling/Remangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ ManglingError Remangler::mangleGlobal(Node *node, unsigned depth) {
16111611
case Node::Kind::DirectMethodReferenceAttribute:
16121612
case Node::Kind::MergedFunction:
16131613
case Node::Kind::DistributedThunk:
1614-
case Node::Kind::DistributedMethodAccessor:
1614+
case Node::Kind::DistributedAccessor:
16151615
case Node::Kind::DynamicallyReplaceableFunctionKey:
16161616
case Node::Kind::DynamicallyReplaceableFunctionImpl:
16171617
case Node::Kind::DynamicallyReplaceableFunctionVar:
@@ -2251,7 +2251,7 @@ Remangler::mangleDistributedThunk(Node *node, unsigned depth) {
22512251
}
22522252

22532253
ManglingError
2254-
Remangler::mangleDistributedMethodAccessor(Node *node, unsigned depth) {
2254+
Remangler::mangleDistributedAccessor(Node *node, unsigned depth) {
22552255
Buffer << "TF";
22562256
return ManglingError::Success;
22572257
}

lib/IRGen/GenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4150,7 +4150,7 @@ void IRGenModule::emitAccessibleFunctions() {
41504150
llvm::Constant *funcAddr = nullptr;
41514151
if (func->isDistributed()) {
41524152
funcAddr = getAddrOfAsyncFunctionPointer(
4153-
LinkEntity::forDistributedMethodAccessor(func));
4153+
LinkEntity::forDistributedTargetAccessor(func));
41544154
} else if (func->isAsync()) {
41554155
funcAddr = getAddrOfAsyncFunctionPointer(func);
41564156
} else {

lib/IRGen/GenDistributed.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class DistributedAccessor {
7575
IRGenFunction &IGF;
7676

7777
/// Underlying distributed method for this accessor.
78-
SILFunction *Method;
78+
SILFunction *Target;
7979

8080
/// The interface type of this accessor function.
8181
CanSILFunctionType AccessorType;
@@ -86,25 +86,25 @@ class DistributedAccessor {
8686
SmallVector<AllocationInfo, 4> AllocatedArguments;
8787

8888
public:
89-
DistributedAccessor(IRGenFunction &IGF, SILFunction *method,
89+
DistributedAccessor(IRGenFunction &IGF, SILFunction *target,
9090
CanSILFunctionType accessorTy);
9191

9292
void emit();
9393

9494
private:
9595
void computeArguments(llvm::Value *argumentBuffer, Explosion &arguments);
9696

97-
FunctionPointer getPointerToMethod() const;
97+
FunctionPointer getPointerToTarget() const;
9898

99-
Callee getCalleeForDistributedMethod(llvm::Value *self) const;
99+
Callee getCalleeForDistributedTarget(llvm::Value *self) const;
100100
};
101101

102102
} // end namespace
103103

104104
/// Compute a type of a distributed method accessor function based
105105
/// on the provided distributed method.
106106
static CanSILFunctionType getAccessorType(IRGenModule &IGM,
107-
SILFunction *DistMethod) {
107+
SILFunction *Target) {
108108
auto &Context = IGM.Context;
109109

110110
auto getRawPointerParmeter = [&]() {
@@ -120,10 +120,10 @@ static CanSILFunctionType getAccessorType(IRGenModule &IGM,
120120
.withAsync()
121121
.build();
122122

123-
auto methodTy = DistMethod->getLoweredFunctionType();
123+
auto targetTy = Target->getLoweredFunctionType();
124124

125-
assert(methodTy->isAsync());
126-
assert(methodTy->hasErrorResult());
125+
assert(targetTy->isAsync());
126+
assert(targetTy->hasErrorResult());
127127

128128
// Accessor gets argument value buffer and a reference to `self` of
129129
// the actor and produces a call to the distributed thunk forwarding
@@ -133,18 +133,18 @@ static CanSILFunctionType getAccessorType(IRGenModule &IGM,
133133
ParameterConvention::Direct_Guaranteed,
134134
{/*argumentBuffer=*/getRawPointerParmeter(),
135135
/*resultBuffer=*/getRawPointerParmeter(),
136-
/*actor=*/methodTy->getParameters().back()},
136+
/*actor=*/targetTy->getParameters().back()},
137137
/*Yields=*/{},
138138
/*Results=*/{},
139-
/*ErrorResult=*/methodTy->getErrorResult(),
139+
/*ErrorResult=*/targetTy->getErrorResult(),
140140
/*patternSubs=*/SubstitutionMap(),
141141
/*invocationSubs=*/SubstitutionMap(), Context);
142142
}
143143

144144
llvm::Function *
145-
IRGenModule::getAddrOfDistributedMethodAccessor(SILFunction *F,
145+
IRGenModule::getAddrOfDistributedTargetAccessor(SILFunction *F,
146146
ForDefinition_t forDefinition) {
147-
auto entity = LinkEntity::forDistributedMethodAccessor(F);
147+
auto entity = LinkEntity::forDistributedTargetAccessor(F);
148148

149149
llvm::Function *&entry = GlobalFuncs[entity];
150150
if (entry) {
@@ -159,21 +159,21 @@ IRGenModule::getAddrOfDistributedMethodAccessor(SILFunction *F,
159159
return createFunction(*this, link, signature);
160160
}
161161

162-
void IRGenModule::emitDistributedMethodAccessor(SILFunction *method) {
163-
assert(method->isDistributed());
162+
void IRGenModule::emitDistributedTargetAccessor(SILFunction *target) {
163+
assert(target->isDistributed());
164164

165-
auto *f = getAddrOfDistributedMethodAccessor(method, ForDefinition);
165+
auto *f = getAddrOfDistributedTargetAccessor(target, ForDefinition);
166166
if (!f->isDeclaration())
167167
return;
168168

169169
IRGenFunction IGF(*this, f);
170-
DistributedAccessor(IGF, method, getAccessorType(*this, method)).emit();
170+
DistributedAccessor(IGF, target, getAccessorType(*this, target)).emit();
171171
}
172172

173173
DistributedAccessor::DistributedAccessor(IRGenFunction &IGF,
174-
SILFunction *method,
174+
SILFunction *target,
175175
CanSILFunctionType accessorTy)
176-
: IGM(IGF.IGM), IGF(IGF), Method(method), AccessorType(accessorTy),
176+
: IGM(IGF.IGM), IGF(IGF), Target(target), AccessorType(accessorTy),
177177
AsyncLayout(getAsyncContextLayout(
178178
IGM, AccessorType, AccessorType, SubstitutionMap(),
179179
/*suppress generics*/ true,
@@ -182,7 +182,7 @@ DistributedAccessor::DistributedAccessor(IRGenFunction &IGF,
182182

183183
void DistributedAccessor::computeArguments(llvm::Value *argumentBuffer,
184184
Explosion &arguments) {
185-
auto fnType = Method->getLoweredFunctionType();
185+
auto fnType = Target->getLoweredFunctionType();
186186

187187
// Cover all of the arguments except to `self` of the actor.
188188
auto parameters = fnType->getParameters().drop_back();
@@ -283,8 +283,8 @@ void DistributedAccessor::computeArguments(llvm::Value *argumentBuffer,
283283
}
284284

285285
void DistributedAccessor::emit() {
286-
auto methodTy = Method->getLoweredFunctionType();
287-
SILFunctionConventions targetConv(methodTy, IGF.getSILModule());
286+
auto targetTy = Target->getLoweredFunctionType();
287+
SILFunctionConventions targetConv(targetTy, IGF.getSILModule());
288288
SILFunctionConventions accessorConv(AccessorType, IGF.getSILModule());
289289
TypeExpansionContext expansionContext = IGM.getMaximalTypeExpansionContext();
290290

@@ -306,7 +306,7 @@ void DistributedAccessor::emit() {
306306
// Reference to a `self` of the actor to be called.
307307
auto *actorSelf = params.claimNext();
308308

309-
GenericContextScope scope(IGM, methodTy->getInvocationGenericSignature());
309+
GenericContextScope scope(IGM, targetTy->getInvocationGenericSignature());
310310

311311
// Preliminary: Setup async context for this accessor.
312312
{
@@ -315,7 +315,7 @@ void DistributedAccessor::emit() {
315315
/*useSpecialConvention*/ false)
316316
.getAsyncContextIndex();
317317

318-
auto entity = LinkEntity::forDistributedMethodAccessor(Method);
318+
auto entity = LinkEntity::forDistributedTargetAccessor(Target);
319319
emitAsyncFunctionEntry(IGF, AsyncLayout, entity, asyncContextIdx);
320320
emitAsyncFunctionPointer(IGM, IGF.CurFn, entity, AsyncLayout.getSize());
321321
}
@@ -341,7 +341,7 @@ void DistributedAccessor::emit() {
341341
Explosion result;
342342
Explosion error;
343343

344-
auto callee = getCalleeForDistributedMethod(actorSelf);
344+
auto callee = getCalleeForDistributedTarget(actorSelf);
345345
auto emission =
346346
getCallEmission(IGF, callee.getSwiftContext(), std::move(callee));
347347

@@ -363,7 +363,7 @@ void DistributedAccessor::emit() {
363363
// Both accessor and distributed method are always `async throws`
364364
// so we need to load error value (if any) from the slot.
365365
{
366-
assert(methodTy->hasErrorResult());
366+
assert(targetTy->hasErrorResult());
367367

368368
SILType errorType = accessorConv.getSILErrorType(expansionContext);
369369
Address calleeErrorSlot =
@@ -386,23 +386,23 @@ void DistributedAccessor::emit() {
386386
}
387387
}
388388

389-
FunctionPointer DistributedAccessor::getPointerToMethod() const {
390-
auto fnType = Method->getLoweredFunctionType();
391-
auto fpKind = classifyFunctionPointerKind(Method);
389+
FunctionPointer DistributedAccessor::getPointerToTarget() const {
390+
auto fnType = Target->getLoweredFunctionType();
391+
auto fpKind = classifyFunctionPointerKind(Target);
392392
auto signature = IGM.getSignature(fnType, fpKind.useSpecialConvention());
393393

394394
auto *fnPtr =
395-
llvm::ConstantExpr::getBitCast(IGM.getAddrOfAsyncFunctionPointer(Method),
395+
llvm::ConstantExpr::getBitCast(IGM.getAddrOfAsyncFunctionPointer(Target),
396396
signature.getType()->getPointerTo());
397397

398398
return FunctionPointer::forDirect(
399399
FunctionPointer::Kind(fnType), fnPtr,
400-
IGM.getAddrOfSILFunction(Method, NotForDefinition), signature);
400+
IGM.getAddrOfSILFunction(Target, NotForDefinition), signature);
401401
}
402402

403403
Callee
404-
DistributedAccessor::getCalleeForDistributedMethod(llvm::Value *self) const {
405-
auto fnType = Method->getLoweredFunctionType();
404+
DistributedAccessor::getCalleeForDistributedTarget(llvm::Value *self) const {
405+
auto fnType = Target->getLoweredFunctionType();
406406
CalleeInfo info{fnType, fnType, SubstitutionMap()};
407-
return {std::move(info), getPointerToMethod(), self};
407+
return {std::move(info), getPointerToTarget(), self};
408408
}

lib/IRGen/IRGenModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,10 +1643,10 @@ private: \
16431643
Address getAddrOfObjCISAMask();
16441644

16451645
llvm::Function *
1646-
getAddrOfDistributedMethodAccessor(SILFunction *F,
1646+
getAddrOfDistributedTargetAccessor(SILFunction *F,
16471647
ForDefinition_t forDefinition);
16481648

1649-
void emitDistributedMethodAccessor(SILFunction *method);
1649+
void emitDistributedTargetAccessor(SILFunction *method);
16501650

16511651
/// Retrieve the generic signature for the current generic context, or null if no
16521652
/// generic environment is active.

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,7 @@ void IRGenSILFunction::emitSILFunction() {
22022202
// Emit distributed accessor, and mark the thunk as accessible
22032203
// by name at runtime through it.
22042204
if (CurSILFn->isDistributed() && CurSILFn->isThunk()) {
2205-
IGM.emitDistributedMethodAccessor(CurSILFn);
2205+
IGM.emitDistributedTargetAccessor(CurSILFn);
22062206
IGM.addAccessibleFunction(CurSILFn);
22072207
}
22082208

0 commit comments

Comments
 (0)