Skip to content

Commit fe4eb76

Browse files
committed
[Distributed] Remove protocol accessible section; not used after all
1 parent cccaf01 commit fe4eb76

File tree

19 files changed

+28
-379
lines changed

19 files changed

+28
-379
lines changed

include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ HANDLE_SWIFT_SECTION(protocs, "__swift5_protos", "swift5_protocols",
3030
".sw5prt$B")
3131
HANDLE_SWIFT_SECTION(acfuncs, "__swift5_acfuncs", "swift5_accessible_functions",
3232
".sw5acfn$B")
33-
HANDLE_SWIFT_SECTION(dacfuncs, "__swift5_acpfuns", "swift5_accessible_protocol_requirement_functions",
34-
".sw5acpfn$B")
3533
HANDLE_SWIFT_SECTION(mpenum, "__swift5_mpenum", "swift5_mpenum", ".sw5mpen$B")

include/swift/Runtime/Config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,6 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL
307307
#define __ptrauth_swift_accessible_function_record \
308308
__ptrauth(ptrauth_key_process_independent_data, 1, \
309309
SpecialPointerAuthDiscriminators::AccessibleFunctionRecord)
310-
#define __ptrauth_swift_accessible_protocol_requirement_function_record \
311-
__ptrauth(ptrauth_key_process_independent_data, 1, \
312-
SpecialPointerAuthDiscriminators:: \
313-
AccessibleProtocolRequirementFunctionRecord)
314310
#define __ptrauth_swift_objc_superclass \
315311
__ptrauth(ptrauth_key_process_independent_data, 1, \
316312
swift::SpecialPointerAuthDiscriminators::ObjCSuperclass)
@@ -359,7 +355,6 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL
359355
#define __ptrauth_swift_escalation_notification_function
360356
#define __ptrauth_swift_dispatch_invoke_function
361357
#define __ptrauth_swift_accessible_function_record
362-
#define __ptrauth_swift_accessible_protocol_requirement_function_record
363358
#define __ptrauth_swift_objc_superclass
364359
#define __ptrauth_swift_runtime_function_entry
365360
#define __ptrauth_swift_runtime_function_entry_with_key(__key)

lib/IRGen/GenDecl.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4417,14 +4417,6 @@ void IRGenModule::addAccessibleFunction(SILFunction *func) {
44174417
AccessibleFunctions.push_back(func);
44184418
}
44194419

4420-
void IRGenModule::addAccessibleFunctionDistributedAliased(
4421-
std::string mangledRecordName,
4422-
std::optional<std::string> mangledActorTypeName,
4423-
SILFunction *func) {
4424-
AccessibleProtocolFunctions.push_back(AccessibleProtocolFunctionsData(
4425-
func, mangledRecordName, mangledActorTypeName));
4426-
}
4427-
44284420
/// Emit the protocol conformance list and return it (if asContiguousArray is
44294421
/// true, otherwise the records are emitted as individual globals and
44304422
/// nullptr is returned).
@@ -4748,11 +4740,10 @@ void IRGenModule::emitAccessibleFunction(
47484740
}
47494741

47504742
void IRGenModule::emitAccessibleFunctions() {
4751-
if (AccessibleFunctions.empty() && AccessibleProtocolFunctions.empty())
4743+
if (AccessibleFunctions.empty())
47524744
return;
47534745

47544746
StringRef fnsSectionName;
4755-
StringRef protocolFnsSectionName;
47564747
switch (TargetInfo.OutputObjectFormat) {
47574748
case llvm::Triple::DXContainer:
47584749
case llvm::Triple::GOFF:
@@ -4762,17 +4753,14 @@ void IRGenModule::emitAccessibleFunctions() {
47624753
"the selected object format.");
47634754
case llvm::Triple::MachO:
47644755
fnsSectionName = "__TEXT, __swift5_acfuncs, regular";
4765-
protocolFnsSectionName = "__TEXT, __swift5_acpfuns, regular";
47664756
break;
47674757
case llvm::Triple::ELF:
47684758
case llvm::Triple::Wasm:
47694759
fnsSectionName = "swift5_accessible_functions";
4770-
protocolFnsSectionName = "swift5_accessible_protocol_requirement_functions";
47714760
break;
47724761
case llvm::Triple::XCOFF:
47734762
case llvm::Triple::COFF:
47744763
fnsSectionName = ".sw5acfn$B";
4775-
protocolFnsSectionName = ".sw5acpfn$B";
47764764
break;
47774765
}
47784766

@@ -4786,24 +4774,6 @@ void IRGenModule::emitAccessibleFunctions() {
47864774
fnsSectionName, mangledRecordName,
47874775
/*mangledActorName=*/{}, mangledFunctionName, func);
47884776
}
4789-
4790-
for (auto accessibleInfo : AccessibleProtocolFunctions) {
4791-
auto func = accessibleInfo.function;
4792-
4793-
std::string mangledRecordName =
4794-
accessibleInfo.mangledRecordName
4795-
? (*accessibleInfo.mangledRecordName)
4796-
: LinkEntity::forAccessibleFunctionRecord(func).mangleAsString();
4797-
std::string mangledFunctionName =
4798-
LinkEntity::forSILFunction(func).mangleAsString();
4799-
std::string mangledActorName = accessibleInfo.concreteMangledTypeName
4800-
? *accessibleInfo.concreteMangledTypeName
4801-
: "<none>";
4802-
4803-
emitAccessibleFunction(
4804-
protocolFnsSectionName, mangledRecordName,
4805-
mangledActorName, mangledFunctionName, func);
4806-
}
48074777
}
48084778

48094779
/// Fetch a global reference to a reference to the given Objective-C class.

lib/IRGen/IRGenModule.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,8 +2232,3 @@ bool swift::writeEmptyOutputFilesFor(
22322232
}
22332233
return false;
22342234
}
2235-
IRGenModule::AccessibleProtocolFunctionsData::AccessibleProtocolFunctionsData(
2236-
SILFunction *function, const std::optional<std::string> &mangledRecordName,
2237-
const std::optional<std::string> &concreteMangledTypeName)
2238-
: function(function), mangledRecordName(mangledRecordName),
2239-
concreteMangledTypeName(concreteMangledTypeName) {}

lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,6 @@ class IRGenModule {
11521152
void addObjCClassStub(llvm::Constant *addr);
11531153
void addProtocolConformance(ConformanceDescription &&conformance);
11541154
void addAccessibleFunction(SILFunction *func);
1155-
void addAccessibleFunctionDistributedAliased(
1156-
std::string mangledRecordName,
1157-
std::optional<std::string> mangledActorTypeName,
1158-
SILFunction *func);
11591155

11601156
llvm::Constant *emitSwiftProtocols(bool asContiguousArray);
11611157
llvm::Constant *emitProtocolConformances(bool asContiguousArray);
@@ -1314,25 +1310,6 @@ class IRGenModule {
13141310
/// up at runtime.
13151311
SmallVector<SILFunction *, 4> AccessibleFunctions;
13161312

1317-
struct AccessibleProtocolFunctionsData {
1318-
SILFunction *function;
1319-
/// Mangled name of the requirement function.
1320-
std::optional<std::string> mangledRecordName;
1321-
std::optional<std::string> concreteMangledTypeName;
1322-
AccessibleProtocolFunctionsData(
1323-
SILFunction *function,
1324-
const std::optional<std::string> &mangledRecordName,
1325-
const std::optional<std::string> &concreteMangledTypeName);
1326-
};
1327-
/// List of all functions which are protocol *requirements* which may be
1328-
/// looked up by name at runtime. The record can be used to pair
1329-
/// a concrete implementation type with the protocol (record) name,
1330-
/// in order to locate the *witness* function name on this specific type.
1331-
///
1332-
/// The witness function name can then be used to look up the witness at
1333-
/// runtime by inspecting `AccessibleFunctions`.
1334-
SmallVector<AccessibleProtocolFunctionsData, 4> AccessibleProtocolFunctions;
1335-
13361313
/// Map of Objective-C protocols and protocol references, bitcast to i8*.
13371314
/// The interesting global variables relating to an ObjC protocol.
13381315
struct ObjCProtocolPair {

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,36 +2476,7 @@ void IRGenSILFunction::emitSILFunction() {
24762476
IGM.emitDistributedTargetAccessor(CurSILFn);
24772477
IGM.addAccessibleFunction(CurSILFn);
24782478

2479-
if (auto val = CurSILFn->getLocation().castToASTNode<ValueDecl>()) {
2480-
if (auto attr =
2481-
val->getAttrs().getAttribute<DistributedThunkTargetAttr>()) {
2482-
2483-
// the original `distributed func`
2484-
auto func = attr->getTargetFunction();
2485-
2486-
auto distributedRequirements = func->getDistributedMethodWitnessedProtocolRequirements();
2487-
if (distributedRequirements.size() == 1) {
2488-
auto protocolFunc = distributedRequirements.front();
2489-
Mangle::ASTMangler mangler;
2490-
// The mangled name of the requirement is the name of the record
2491-
auto mangledProtocolFuncName =
2492-
mangler.mangleDistributedThunk(cast<FuncDecl>(protocolFunc));
2493-
2494-
std::optional<std::string> mangledActorTypeName;
2495-
if (isa<ClassDecl>(func->getDeclContext()->getAsDecl())) {
2496-
// a concrete type, not a "distributed" protocol
2497-
mangledActorTypeName = mangler.mangleAnyDecl(
2498-
func->getDeclContext()->getSelfNominalTypeDecl(),
2499-
/*prefix=*/true);
2500-
}
2501-
2502-
IGM.addAccessibleFunctionDistributedAliased(
2503-
/*mangledRecordName=*/mangledProtocolFuncName,
2504-
/*mangledActorTypeName=*/mangledActorTypeName,
2505-
CurSILFn);
2506-
}
2507-
}
2508-
}
2479+
// TODO(distributed): for protocols emit a special accessor
25092480
}
25102481

25112482
// Configure the dominance resolver.

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -482,26 +482,6 @@ extension DistributedActorSystem {
482482
let targetName = target.identifier
483483
let targetNameUTF8 = Array(targetName.utf8)
484484

485-
let concreteTargetNameTypeNamePair: _SwiftNamePair?
486-
if #available(SwiftStdlib 5.11, *) {
487-
let dataAndLength = targetNameUTF8.withUnsafeBufferPointer { targetNameUTF8 in
488-
_getConcreteAccessibleWitnessName(on: actor,
489-
targetNameUTF8.baseAddress!, UInt(targetNameUTF8.endIndex))
490-
}
491-
// If the length is greater than zero it is a real value, nil otherwise
492-
if dataAndLength.1 > 0 {
493-
concreteTargetNameTypeNamePair = dataAndLength
494-
} else {
495-
concreteTargetNameTypeNamePair = nil
496-
}
497-
} else {
498-
// protocol method targets not supported in previous Swift versions,
499-
// the targetName can be assumed to be a concrete name
500-
concreteTargetNameTypeNamePair = nil
501-
}
502-
let concreteTargetNameData = concreteTargetNameTypeNamePair?.0
503-
let concreteTargetNameLength = (concreteTargetNameTypeNamePair?.1).map(UInt.init)
504-
505485
// Gen the generic environment (if any) associated with the target.
506486
let genericEnv =
507487
targetNameUTF8.withUnsafeBufferPointer { targetNameUTF8 in

stdlib/public/Distributed/DistributedMetadata.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ func __getReturnTypeInfo(
9595
/// uses to return String data/length pairs.
9696
typealias _SwiftNamePair = (UnsafePointer<UInt8>, Int)
9797

98-
@available(SwiftStdlib 5.11, *)
99-
@_silgen_name("swift_distributed_getConcreteAccessibleWitnessName")
100-
func _getConcreteAccessibleWitnessName(
101-
on actor: AnyObject, // : DistributedActor
102-
_ targetNameStart: UnsafePointer<UInt8>,
103-
_ targetNameLength: UInt
104-
) -> _SwiftNamePair
98+
//@available(SwiftStdlib 5.11, *)
99+
//@_silgen_name("swift_distributed_getConcreteAccessibleWitnessName")
100+
//func _getConcreteAccessibleWitnessName(
101+
// on actor: AnyObject, // : DistributedActor
102+
// _ targetNameStart: UnsafePointer<UInt8>,
103+
// _ targetNameLength: UInt
104+
//) -> _SwiftNamePair
105105

106106
/// Retrieve a generic environment descriptor associated with
107107
/// the given distributed target.

stdlib/public/SwiftShims/swift/shims/MetadataSections.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct MetadataSections {
9797
MetadataSectionRange swift5_capture;
9898
MetadataSectionRange swift5_mpenum;
9999
MetadataSectionRange swift5_accessible_functions;
100-
MetadataSectionRange swift5_accessible_protocol_requirement_functions;
101100
MetadataSectionRange swift5_runtime_attributes;
102101
MetadataSectionRange swift5_tests;
103102
};

0 commit comments

Comments
 (0)