Skip to content

Commit ed6d69f

Browse files
committed
Mangling: Add a mangling for back deployment fallback functions and update the back deployment thunk mangling to use the same prefix.
1 parent 97e8e31 commit ed6d69f

File tree

9 files changed

+44
-14
lines changed

9 files changed

+44
-14
lines changed

docs/ABI/Mangling.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ types where the metadata itself has unknown layout.)
223223
global ::= global 'TI' // implementation of a dynamic_replaceable function
224224
global ::= global 'Tu' // async function pointer of a function
225225
global ::= global 'TX' // function pointer of a dynamic_replaceable function
226-
global ::= global 'Tw' // back deployment thunk
226+
global ::= global 'Twb' // back deployment thunk
227+
global ::= global 'TwB' // back deployment fallback function
227228
global ::= entity entity 'TV' // vtable override thunk, derived followed by base
228229
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.
229230
global ::= type 'TC' // continuation prototype (not actually used for real symbols)

include/swift/AST/ASTMangler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class ASTMangler : public Mangler {
106106
DistributedThunk,
107107
DistributedAccessor,
108108
AccessibleFunctionRecord,
109-
BackDeployedThunk,
109+
BackDeploymentThunk,
110+
BackDeploymentFallback,
110111
};
111112

112113
ASTMangler(bool DWARFMangling = false)

include/swift/Demangling/DemangleNodes.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ NODE(CompileTimeConst)
332332

333333
// Added in Swift 5.7
334334
NODE(OpaqueReturnTypeIndexed)
335-
NODE(BackDeployed)
335+
NODE(BackDeploymentThunk)
336+
NODE(BackDeploymentFallback)
336337

337338
#undef CONTEXT_NODE
338339
#undef NODE

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,8 @@ void ASTMangler::appendSymbolKind(SymbolKind SKind) {
857857
case SymbolKind::DistributedThunk: return appendOperator("TE");
858858
case SymbolKind::DistributedAccessor: return appendOperator("TF");
859859
case SymbolKind::AccessibleFunctionRecord: return appendOperator("HF");
860-
// FIXME(backDeploy): Check whether mangling needs to be extended since
861-
// the available thunk mangling names are almost exhausted.
862-
case SymbolKind::BackDeployedThunk: return appendOperator("Tw");
860+
case SymbolKind::BackDeploymentThunk: return appendOperator("Twb");
861+
case SymbolKind::BackDeploymentFallback: return appendOperator("TwB");
863862
}
864863
}
865864

lib/Demangling/Demangler.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ bool swift::Demangle::isFunctionAttr(Node::Kind kind) {
139139
case Node::Kind::AsyncAwaitResumePartialFunction:
140140
case Node::Kind::AsyncSuspendResumePartialFunction:
141141
case Node::Kind::AccessibleFunctionRecord:
142+
case Node::Kind::BackDeploymentThunk:
143+
case Node::Kind::BackDeploymentFallback:
142144
return true;
143145
default:
144146
return false;
@@ -2395,7 +2397,6 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
23952397
case 'X': return createNode(Node::Kind::DynamicallyReplaceableFunctionVar);
23962398
case 'x': return createNode(Node::Kind::DynamicallyReplaceableFunctionKey);
23972399
case 'I': return createNode(Node::Kind::DynamicallyReplaceableFunctionImpl);
2398-
case 'w': return createNode(Node::Kind::BackDeployed);
23992400
case 'Y':
24002401
case 'Q': {
24012402
NodePointer discriminator = demangleIndexAsNode();
@@ -2642,6 +2643,13 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
26422643
return demangleAutoDiffFunctionOrSimpleThunk(
26432644
Node::Kind::AutoDiffFunction);
26442645
}
2646+
case 'w':
2647+
switch (nextChar()) {
2648+
case 'b': return createNode(Node::Kind::BackDeploymentThunk);
2649+
case 'B': return createNode(Node::Kind::BackDeploymentFallback);
2650+
default:
2651+
return nullptr;
2652+
}
26452653
default:
26462654
return nullptr;
26472655
}

lib/Demangling/NodePrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ class NodePrinter {
591591
case Node::Kind::AsyncAwaitResumePartialFunction:
592592
case Node::Kind::AsyncSuspendResumePartialFunction:
593593
case Node::Kind::AccessibleFunctionRecord:
594-
case Node::Kind::BackDeployed:
594+
case Node::Kind::BackDeploymentThunk:
595+
case Node::Kind::BackDeploymentFallback:
595596
return false;
596597
}
597598
printer_unreachable("bad node kind");
@@ -2051,11 +2052,14 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
20512052
Printer << "dynamically replaceable variable for ";
20522053
}
20532054
return nullptr;
2054-
case Node::Kind::BackDeployed:
2055+
case Node::Kind::BackDeploymentThunk:
20552056
if (!Options.ShortenThunk) {
20562057
Printer << "back deployment thunk for ";
20572058
}
20582059
return nullptr;
2060+
case Node::Kind::BackDeploymentFallback:
2061+
Printer << "back deployment fallback for ";
2062+
return nullptr;
20592063
case Node::Kind::ProtocolSymbolicReference:
20602064
Printer << "protocol symbolic reference 0x";
20612065
Printer.writeHex(Node->getIndex());

lib/Demangling/OldRemangler.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,7 +2801,13 @@ ManglingError Remangler::mangleAccessibleFunctionRecord(Node *node,
28012801
return ManglingError::Success;
28022802
}
28032803

2804-
ManglingError Remangler::mangleBackDeployed(Node *node, unsigned depth) {
2805-
Buffer << "Tw";
2804+
ManglingError Remangler::mangleBackDeploymentThunk(Node *node, unsigned depth) {
2805+
Buffer << "Twb";
2806+
return ManglingError::Success;
2807+
}
2808+
2809+
ManglingError Remangler::mangleBackDeploymentFallback(Node *node,
2810+
unsigned depth) {
2811+
Buffer << "TwB";
28062812
return ManglingError::Success;
28072813
}

lib/Demangling/Remangler.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,8 @@ ManglingError Remangler::mangleGlobal(Node *node, unsigned depth) {
16271627
case Node::Kind::AsyncAwaitResumePartialFunction:
16281628
case Node::Kind::AsyncSuspendResumePartialFunction:
16291629
case Node::Kind::AccessibleFunctionRecord:
1630+
case Node::Kind::BackDeploymentThunk:
1631+
case Node::Kind::BackDeploymentFallback:
16301632
mangleInReverseOrder = true;
16311633
break;
16321634
default:
@@ -3407,8 +3409,15 @@ ManglingError Remangler::mangleAccessibleFunctionRecord(Node *node,
34073409
return ManglingError::Success;
34083410
}
34093411

3410-
ManglingError Remangler::mangleBackDeployed(Node *node, unsigned depth) {
3411-
Buffer << "Tw";
3412+
ManglingError Remangler::mangleBackDeploymentThunk(Node *node,
3413+
unsigned depth) {
3414+
Buffer << "Twb";
3415+
return ManglingError::Success;
3416+
}
3417+
3418+
ManglingError Remangler::mangleBackDeploymentFallback(Node *node,
3419+
unsigned depth) {
3420+
Buffer << "TwB";
34123421
return ManglingError::Success;
34133422
}
34143423

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,5 @@ $s16distributed_test1XC7computeyS2iFTF ---> distributed accessor for distributed
425425
$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTETFHF ---> accessible function runtime record for distributed accessor for distributed thunk for distributed_actor_accessors.MyActor.simple2(Swift.Int) -> Swift.String
426426
$s1A3bar1aySSYt_tF ---> A.bar(a: _const Swift.String) -> ()
427427
$s1t1fyyFSiAA3StrVcs7KeyPathCyADSiGcfu_SiADcfu0_33_556644b740b1b333fecb81e55a7cce98ADSiTf3npk_n ---> function signature specialization <Arg[1] = [Constant Propagated KeyPath : _556644b740b1b333fecb81e55a7cce98<t.Str,Swift.Int>]> of implicit closure #2 (t.Str) -> Swift.Int in implicit closure #1 (Swift.KeyPath<t.Str, Swift.Int>) -> (t.Str) -> Swift.Int in t.f() -> ()
428-
428+
$s21back_deploy_attribute0A12DeployedFuncyyFTwb ---> back deployment thunk for back_deploy_attribute.backDeployedFunc() -> ()
429+
$s21back_deploy_attribute0A12DeployedFuncyyFTwB ---> back deployment fallback for back_deploy_attribute.backDeployedFunc() -> ()

0 commit comments

Comments
 (0)