Skip to content

Commit a0f24d2

Browse files
paulbissfacebook-github-bot
authored andcommitted
Eliminate final usage of spillInlinedFrames()
Summary: Now that `CallFuncEntry` operates on frame locals we can simple use it when side exiting from a func entry instead of doing an `InlineCall` and spilling all inlined frames. Reviewed By: jano Differential Revision: D72594276 fbshipit-source-id: 172193fb545d0b0a41962156f43cb27b350be80d
1 parent a543114 commit a0f24d2

21 files changed

+55
-253
lines changed

hphp/doc/ir.specification

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,19 +1629,6 @@ To string conversions:
16291629

16301630
Marks the end of an inlined function. S0 is no longer a valid frame location.
16311631

1632-
| InlineCall<retSPOff>, ND, S(FramePtr) S(FramePtr), NF
1633-
1634-
Sets the current vmfp for an inlined call to S0, and the m_sfp of S0 to the
1635-
previous vmfp, S1.
1636-
1637-
This instruction is primarily used to represent an inlined frame in the IR
1638-
when it cannot be eliminated during a side-exit. It performs callee-side
1639-
responsibilities for setting up an activation record (i.e. setting the return
1640-
ip, m_func and m_callOff, storing the frame pointer into D).
1641-
1642-
The caller frame pointer is passed as S1. This is used to keep track of the
1643-
call chain of inlined functions for simplification and dead code elimination.
1644-
16451632
| InlineSideExitSyncStack<offset>, ND, S(StkPtr), NF
16461633

16471634
This instruction does nothing, but has memory effects that force the stack
@@ -1898,10 +1885,6 @@ ReqBindJmp and CallFuncEntry.
18981885

18991886
Store the func in m_funcId/m_func for S0.
19001887

1901-
| StFrameMeta<callBCOff,flags>, ND, S(FramePtr), NF
1902-
1903-
Store the m_callOffAndFlags field of S0.
1904-
19051888
10. Trace exits
19061889

19071890
| StVMFP, ND, S(FramePtr), NF

hphp/runtime/vm/jit/alias-analysis.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ void visit_locations(const BlockList& blocks, Visit visit) {
7373
[&] (const PureStore& x) { visit(x.dst); },
7474
[&] (const ExitEffects& x) { visit(x.live);
7575
visit(x.kills);
76-
visit(x.uninits); },
77-
[&] (const PureInlineCall& x) { visit(x.base);
78-
visit(x.actrec); }
76+
visit(x.uninits); }
7977
);
8078
}
8179
}

hphp/runtime/vm/jit/dce.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ bool canDCE(const IRInstruction& inst) {
455455
case NewStructDict:
456456
case NewBespokeStructDict:
457457
case Clone:
458-
case InlineCall:
459458
case InlineSideExit:
460459
case InlineSideExitSyncStack:
461460
case Call:
@@ -740,7 +739,6 @@ bool canDCE(const IRInstruction& inst) {
740739
case ProfileIsTypeStruct:
741740
case StFrameCtx:
742741
case StFrameFunc:
743-
case StFrameMeta:
744742
case LookupClsCns:
745743
case LookupClsCtxCns:
746744
case ArrayMarkLegacyShallow:
@@ -1078,12 +1076,7 @@ void processCatchBlock(IRUnit& unit, DceState& state, Block* block,
10781076
},
10791077
[&] (const PureLoad& x) { return process_stack(x.src); },
10801078
[&] (const PureStore& x) { return do_store(x.dst, &*inst); },
1081-
[&] (const ExitEffects& x) { return process_stack(x.live); },
1082-
[&] (const PureInlineCall& x) {
1083-
return
1084-
process_stack(x.base) ||
1085-
process_stack(x.actrec);
1086-
}
1079+
[&] (const ExitEffects& x) { return process_stack(x.live); }
10871080
);
10881081
}
10891082

hphp/runtime/vm/jit/def-sink.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ bool conflicts(const IRInstruction& instr,
457457
[&] (const GeneralEffects&) { return false; },
458458
[&] (const PureLoad&) { return false; },
459459
[&] (const PureStore&) { return false; },
460-
[&] (const PureInlineCall&) { return false; },
461460
[&] (const ExitEffects&) { return true; },
462461
[&] (const UnknownEffects&) { return true; }
463462
);
@@ -494,7 +493,6 @@ bool conflicts(const IRInstruction& instr,
494493
},
495494
[&] (const PureLoad&) { return false; },
496495
[&] (const PureStore& store) { return load.src.maybe(store.dst); },
497-
[&] (const PureInlineCall& call) { return load.src.maybe(call.base); },
498496
[&] (const ExitEffects&) { return true; },
499497
[&] (const UnknownEffects&) { return true; }
500498
);
@@ -550,7 +548,6 @@ bool conflicts(const IRInstruction& instr,
550548
},
551549
[&] (const PureLoad&) { return false; },
552550
[&] (const PureStore& store) { return test_reads(store.dst); },
553-
[&] (const PureInlineCall& call) { return test_reads(call.base); },
554551
[&] (const ExitEffects&) { return true; },
555552
[&] (const UnknownEffects&) { return true; }
556553
);
@@ -594,7 +591,6 @@ bool conflicts(const IRInstruction& sinkee, const IRInstruction& barrier) {
594591
[&] (const ReturnEffects&) { always_assert(false); return true; },
595592
[&] (const CallEffects&) { always_assert(false); return true; },
596593
[&] (const PureStore&) { always_assert(false); return true; },
597-
[&] (const PureInlineCall&) { always_assert(false); return true; },
598594
[&] (const ExitEffects&) { always_assert(false); return true; },
599595
[&] (const UnknownEffects&) { always_assert(false); return true; }
600596
);
@@ -636,7 +632,6 @@ TriBool will_conflict(const IRInstruction& inst) {
636632
[&] (const ReturnEffects&) { return TriBool::Yes; },
637633
[&] (const CallEffects&) { return TriBool::Maybe; },
638634
[&] (const PureStore&) { return TriBool::Maybe; },
639-
[&] (const PureInlineCall&) { return TriBool::Maybe; },
640635
[&] (const ExitEffects&) { return TriBool::Yes; },
641636
[&] (const UnknownEffects&) { return TriBool::Yes; }
642637
);
@@ -1118,7 +1113,6 @@ State make_state(IRUnit& unit,
11181113
[&] (const ReturnEffects&) { return false; },
11191114
[&] (const CallEffects&) { return false; },
11201115
[&] (const PureStore&) { return false; },
1121-
[&] (const PureInlineCall&) { return false; },
11221116
[&] (const ExitEffects&) { return false; },
11231117
[&] (const UnknownEffects&) { return false; }
11241118
);

hphp/runtime/vm/jit/extra-data.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,31 +1168,6 @@ struct ReqBindJmpData : IRExtraData {
11681168
bool popFrame;
11691169
};
11701170

1171-
struct StFrameMetaData : IRExtraData {
1172-
std::string show() const {
1173-
return folly::to<std::string>(
1174-
callBCOff, ',',
1175-
asyncEagerReturn
1176-
);
1177-
}
1178-
1179-
size_t stableHash() const {
1180-
return folly::hash::hash_combine(
1181-
std::hash<Offset>()(callBCOff),
1182-
std::hash<bool>()(asyncEagerReturn)
1183-
);
1184-
}
1185-
1186-
bool equals(const StFrameMetaData& o) const {
1187-
return callBCOff == o.callBCOff && asyncEagerReturn == o.asyncEagerReturn;
1188-
}
1189-
1190-
1191-
Offset callBCOff;
1192-
bool isInlined;
1193-
bool asyncEagerReturn;
1194-
};
1195-
11961171
struct CallBuiltinData : IRExtraData {
11971172
explicit CallBuiltinData(IRSPRelOffset spOffset,
11981173
const Func* callee)
@@ -3141,7 +3116,6 @@ X(DefFrameRelSP, DefStackData);
31413116
X(DefRegSP, DefStackData);
31423117
X(LdStk, IRSPRelOffsetData);
31433118
X(LdStkAddr, IRSPRelOffsetData);
3144-
X(StFrameMeta, StFrameMetaData);
31453119
X(DefCalleeFP, DefCalleeFPData);
31463120
X(ReqBindJmp, ReqBindJmpData);
31473121
X(ReqInterpBBNoTranslate, ReqBindJmpData);

hphp/runtime/vm/jit/frame-state.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ void FrameStateMgr::update(const IRInstruction* inst) {
306306
switch (inst->op()) {
307307
case EnterInlineFrame: trackEnterInlineFrame(inst); break;
308308
case LeaveInlineFrame: trackLeaveInlineFrame(); break;
309-
case InlineCall: trackInlineCall(inst); break;
310309
case InlineSideExit: trackInlineSideExit(inst); break;
311310
case InlineSideExitSyncStack:
312311
assertx(cur().bcSPOff ==
@@ -764,7 +763,6 @@ void FrameStateMgr::handleConservatively(const IRInstruction* inst) {
764763
store(x.outputs);
765764
},
766765
[&] (const PureStore& x) { store(x.dst); },
767-
[&] (const PureInlineCall& x) { store(x.base); },
768766
[&] (const UnknownEffects&) { store(AUnknown); },
769767
[&] (const ReturnEffects&) {},
770768
[&] (const ExitEffects&) {},
@@ -1073,11 +1071,6 @@ void FrameStateMgr::trackLeaveInlineFrame() {
10731071
assertx(cur().checkMInstrStateDead());
10741072
}
10751073

1076-
void FrameStateMgr::trackInlineCall(const IRInstruction* inst) {
1077-
assertx(cur().fixupFPValue == inst->src(1));
1078-
cur().fixupFPValue = inst->src(0);
1079-
}
1080-
10811074
void FrameStateMgr::trackInlineSideExit(const IRInstruction* inst) {
10821075
auto const callee = inst->extra<InlineSideExit>()->callee;
10831076
auto const arOffset = inst->src(1)->inst()->extra<DefCalleeFP>()->spOffset;

hphp/runtime/vm/jit/frame-state.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ struct FrameStateMgr final {
515515
void uninitStack();
516516
void trackEnterInlineFrame(const IRInstruction* inst);
517517
void trackLeaveInlineFrame();
518-
void trackInlineCall(const IRInstruction* inst);
519518
void trackInlineSideExit(const IRInstruction* inst);
520519

521520
void pointerLoad(SSATmp*, SSATmp*);

hphp/runtime/vm/jit/inline-state.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ struct InlineFrame {
6767
* Saved cost.
6868
*/
6969
int savedCost;
70+
71+
/*
72+
* Callee context (TCls, TObj, TNullptr)
73+
*/
74+
SSATmp* ctx;
7075
};
7176

7277
struct InlineState {

hphp/runtime/vm/jit/ir-opcode.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ bool opcodeMayRaise(Opcode opc) {
681681
case InitThrowableFileAndLine:
682682
case InitVecElem:
683683
case InitVecElemLoop:
684-
case InlineCall:
685684
case InlineSideExitSyncStack:
686685
case InstanceOf:
687686
case InstanceOfBitmask:
@@ -918,7 +917,6 @@ bool opcodeMayRaise(Opcode opc) {
918917
case StContArValue:
919918
case StFrameCtx:
920919
case StFrameFunc:
921-
case StFrameMeta:
922920
case StImplicitContext:
923921
case StIterEnd:
924922
case StIterPos:

hphp/runtime/vm/jit/irgen-call.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -280,34 +280,6 @@ SSATmp* callImpl(IRGS& env, SSATmp* callee, const FCallArgs& fca,
280280
);
281281
}
282282

283-
SSATmp* callFuncEntry(IRGS& env, SrcKey entry, SSATmp* objOrClass,
284-
SSATmp* calleeFP, uint32_t numArgsInclUnpack,
285-
bool asyncEagerReturn) {
286-
assertx(entry.funcEntry());
287-
if (objOrClass == nullptr) objOrClass = cns(env, TNullptr);
288-
assertx(objOrClass->isA(TNullptr) || objOrClass->isA(TObj|TCls));
289-
290-
auto const pubFP = env.irb->fs()[0].fp();
291-
auto pubBcOff = bcOff(env);
292-
if (env.irb->fs().inlineDepth()) {
293-
auto const firstUnpubFP = env.irb->fs()[1].fp();
294-
pubBcOff = firstUnpubFP->inst()->marker().sk().offset();
295-
}
296-
297-
auto const arFlags = ActRec::encodeCallOffsetAndFlags(
298-
pubBcOff,
299-
asyncEagerReturn ? (1 << ActRec::AsyncEagerRet) : 0
300-
);
301-
302-
auto const data = CallFuncEntryData {
303-
entry,
304-
numArgsInclUnpack,
305-
arFlags,
306-
env.formingRegion
307-
};
308-
return gen(env, CallFuncEntry, data, calleeFP, pubFP, objOrClass);
309-
}
310-
311283
void handleCallReturn(IRGS& env, const Func* callee, SSATmp* retVal,
312284
Offset asyncEagerOffset, bool unlikely) {
313285
// Insert a debugger interrupt check after returning from a call
@@ -1363,6 +1335,34 @@ void fcallFuncStr(IRGS& env, const FCallArgs& fca) {
13631335

13641336
} // namespace
13651337

1338+
SSATmp* callFuncEntry(IRGS& env, SrcKey entry, SSATmp* objOrClass,
1339+
SSATmp* calleeFP, uint32_t numArgsInclUnpack,
1340+
bool asyncEagerReturn) {
1341+
assertx(entry.funcEntry());
1342+
if (objOrClass == nullptr) objOrClass = cns(env, TNullptr);
1343+
assertx(objOrClass->isA(TNullptr) || objOrClass->isA(TObj|TCls));
1344+
1345+
auto const pubFP = env.irb->fs()[0].fp();
1346+
auto pubBcOff = bcOff(env);
1347+
if (env.irb->fs().inlineDepth()) {
1348+
auto const firstUnpubFP = env.irb->fs()[1].fp();
1349+
pubBcOff = firstUnpubFP->inst()->marker().sk().offset();
1350+
}
1351+
1352+
auto const arFlags = ActRec::encodeCallOffsetAndFlags(
1353+
pubBcOff,
1354+
asyncEagerReturn ? (1 << ActRec::AsyncEagerRet) : 0
1355+
);
1356+
1357+
auto const data = CallFuncEntryData {
1358+
entry,
1359+
numArgsInclUnpack,
1360+
arFlags,
1361+
env.formingRegion
1362+
};
1363+
return gen(env, CallFuncEntry, data, calleeFP, pubFP, objOrClass);
1364+
}
1365+
13661366
void emitDeploymentBoundaryCheck(IRGS& env, SSATmp* symbol) {
13671367
if (!Cfg::Eval::EnforceDeployment) return;
13681368
auto const caller = curFunc(env);

0 commit comments

Comments
 (0)