Skip to content

Commit 2e7183b

Browse files
committed
Mark ExtendArg parameters as live on back edge in JIT loops
For HomeObj opcodes the helper call is done using ExtendArgs. When the ExtendArgs are hoisted outside the loop marking them as live on back edge to avoid being reused.
1 parent c9a6482 commit 2e7183b

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

lib/Backend/LowerMDShared.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ LowererMD::LowerCallHelper(IR::Instr *instrCall)
231231
regArg->Free(this->m_func);
232232
instrArg->Remove();
233233
}
234+
else if (instrArg->m_opcode == Js::OpCode::ExtendArg_A)
235+
{
236+
if (instrArg->GetSrc1()->IsRegOpnd())
237+
{
238+
m_lowerer->addToLiveOnBackEdgeSyms->Set(instrArg->GetSrc1()->AsRegOpnd()->GetStackSym()->m_id);
239+
}
240+
}
234241
}
235242

236243
switch (helperMethod)

lib/Backend/arm/LowerMD.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ LowererMD::LowerCallHelper(IR::Instr *instrCall)
227227
regArg->Free(this->m_func);
228228
instrArg->Remove();
229229
}
230+
else if (instrArg->m_opcode == Js::OpCode::ExtendArg_A)
231+
{
232+
if (instrArg->GetSrc1()->IsRegOpnd())
233+
{
234+
m_lowerer->addToLiveOnBackEdgeSyms->Set(instrArg->GetSrc1()->AsRegOpnd()->GetStackSym()->m_id);
235+
}
236+
}
230237
}
231238

232239
switch (helperMethod)

lib/Backend/arm64/LowerMD.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ LowererMD::LowerCallHelper(IR::Instr *instrCall)
241241
regArg->Free(this->m_func);
242242
instrArg->Remove();
243243
}
244+
else if (instrArg->m_opcode == Js::OpCode::ExtendArg_A)
245+
{
246+
if (instrArg->GetSrc1()->IsRegOpnd())
247+
{
248+
m_lowerer->addToLiveOnBackEdgeSyms->Set(instrArg->GetSrc1()->AsRegOpnd()->GetStackSym()->m_id);
249+
}
250+
}
244251
}
245252

246253
switch (helperMethod)

test/Bugs/HomeObjInLoop.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
function test0(){
7+
var arrObj0 = {};
8+
arrObj0[0] = 1;
9+
10+
function v0(o)
11+
{
12+
for (var v1 = 0 ; v1 < 8 ; v1++)
13+
{
14+
class class7 {
15+
func56 (){
16+
}
17+
}
18+
o[v1] = v1;
19+
}
20+
}
21+
22+
v0(arrObj0);
23+
24+
25+
};
26+
27+
test0();
28+
test0();
29+
test0();
30+
print("pass");

test/Bugs/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,5 +477,11 @@
477477
<files>bug_OS17417473.js</files>
478478
<compile-flags>-pageheap:2 -CollectGarbage -lic:4 -Sja:4 -Fja:6 -maxInterpretCount:2 -MinBailOutsBeforeRejit:2 -args summary -endargs</compile-flags>
479479
</default>
480+
</test>
481+
<test>
482+
<default>
483+
<files>HomeObjInLoop.js</files>
484+
<compile-flags>-forceNative -forcejitloopbody -off:aggressiveinttypespec -off:ArrayCheckHoist</compile-flags>
485+
</default>
480486
</test>
481487
</regress-exe>

0 commit comments

Comments
 (0)