@@ -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 ();
0 commit comments