Skip to content

Commit 57e5e7e

Browse files
committed
move argouts next to call instruction for apply inlining
1 parent 538db04 commit 57e5e7e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/Backend/Inline.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ IR::Instr * Inline::InlineApplyWithArgumentsObject(IR::Instr * callInstr, IR::In
23942394
IR::Instr * explicitThisArgOut = nullptr;
23952395
IR::Instr * argumentsObjArgOut = nullptr;
23962396
uint argOutCount = 0;
2397-
this->GetArgInstrsForCallAndApply(callInstr, &implicitThisArgOut, &explicitThisArgOut, &argumentsObjArgOut, argOutCount);
2397+
this->GetArgInstrsForCallAndApply(callInstr, &implicitThisArgOut, &explicitThisArgOut, &argumentsObjArgOut, argOutCount, false /*moveArgsCloseToCall*/);
23982398

23992399
// BailOnNotEqual s4.var ---------------New additional BAILOUT if not stack args or actuals exceed 16 at runtime.
24002400
// Bailout: #004e (BailOutOnInlineFunction)
@@ -2442,6 +2442,14 @@ IR::Instr * Inline::InlineApplyWithArgumentsObject(IR::Instr * callInstr, IR::In
24422442
IR::Instr* builtInStartInstr;
24432443
InsertInlineeBuiltInStartEndTags(callInstr, 3, &builtInStartInstr); //3 args (implicit this + explicit this + arguments = 3)
24442444

2445+
// Move argouts close to call. Globopt expects this for arguments object tracking.
2446+
IR::Instr* argInsertInstr = builtInStartInstr;
2447+
builtInStartInstr->IterateArgInstrs([&](IR::Instr* argInstr) {
2448+
argInstr->Move(argInsertInstr);
2449+
argInsertInstr = argInstr;
2450+
return false;
2451+
});
2452+
24452453
IR::Instr *startCall = IR::Instr::New(Js::OpCode::StartCall, callInstr->m_func);
24462454
startCall->SetDst(IR::RegOpnd::New(TyVar, callInstr->m_func));
24472455
startCall->SetSrc1(IR::IntConstOpnd::New(2, TyInt32, callInstr->m_func)); //2 args (this pointer & ArgOut_A_From_StackArgs for this direct call to init
@@ -2580,7 +2588,7 @@ IR::Instr * Inline::InlineApplyWithoutArrayArgument(IR::Instr *callInstr, const
25802588
return callInstr;
25812589
}
25822590

2583-
void Inline::GetArgInstrsForCallAndApply(IR::Instr* callInstr, IR::Instr** implicitThisArgOut, IR::Instr** explicitThisArgOut, IR::Instr** argumentsOrArrayArgOut, uint &argOutCount)
2591+
void Inline::GetArgInstrsForCallAndApply(IR::Instr* callInstr, IR::Instr** implicitThisArgOut, IR::Instr** explicitThisArgOut, IR::Instr** argumentsOrArrayArgOut, uint &argOutCount, bool moveArgsCloseToCall)
25842592
{
25852593
IR::Opnd * linkOpnd = callInstr->GetSrc2()->AsSymOpnd();
25862594
IR::Instr * argInsertInstr = callInstr;
@@ -2595,7 +2603,10 @@ void Inline::GetArgInstrsForCallAndApply(IR::Instr* callInstr, IR::Instr** impli
25952603
linkOpnd->AsSymOpnd()->m_sym->AsStackSym()->m_allocated = true;
25962604
ConvertToInlineBuiltInArgOut(argInstr);
25972605

2598-
argInstr->Move(argInsertInstr);
2606+
if (moveArgsCloseToCall)
2607+
{
2608+
argInstr->Move(argInsertInstr);
2609+
}
25992610
argInsertInstr = argInstr;
26002611

26012612
linkOpnd = argInstr->GetSrc2();

lib/Backend/Inline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Inline
5252
IR::Instr * InlineApplyWithoutArrayArgument(IR::Instr *callInstr, const FunctionJITTimeInfo * applyInfo, const FunctionJITTimeInfo * applyTargetInfo);
5353
bool InlineApplyScriptTarget(IR::Instr *callInstr, const FunctionJITTimeInfo* inlinerData, const FunctionJITTimeInfo** pInlineeData, const FunctionJITTimeInfo * applyFuncInfo,
5454
const StackSym *symThis, IR::Instr ** returnInstr, uint recursiveInlineDepth, bool isArrayOpndArgumentsObject, uint argsCount);
55-
void GetArgInstrsForCallAndApply(IR::Instr* callInstr, IR::Instr** implicitThisArgOut, IR::Instr** explicitThisArgOut, IR::Instr** argumentsOrArrayArgOut, uint &argOutCount);
55+
void GetArgInstrsForCallAndApply(IR::Instr* callInstr, IR::Instr** implicitThisArgOut, IR::Instr** explicitThisArgOut, IR::Instr** argumentsOrArrayArgOut, uint &argOutCount, bool moveArgsCloseToCall = true);
5656

5757
IR::Instr * InlineCall(IR::Instr *callInstr, const FunctionJITTimeInfo * inlineeData, const FunctionJITTimeInfo * inlinerData, const StackSym *symThis, bool* pIsInlined, uint callSiteId, uint recursiveInlineDepth);
5858
bool InlineCallTarget(IR::Instr *callInstr, const FunctionJITTimeInfo* inlinerData, const FunctionJITTimeInfo** pInlineeData, const FunctionJITTimeInfo *callFuncInfo,

0 commit comments

Comments
 (0)