Skip to content

Commit cd27b56

Browse files
author
Meghana Gupta
committed
[MERGE #5316 @meg-gupta] Enable deadstore for jit loop bodies when there is try
Merge pull request #5316 from meg-gupta:loopcrash We insert LdSlots at the top of the function in jitloopbody for all syms that are coming in live to the loop. These LdSlots should be restored correctly on BailOutFromSimpleJitToJitLoopBody. However we do unreachable code elimination in flowgraph in simplejit, which can dead code the uses of these syms, and so they will not be restored on bailout. This works if we run deadstore pass which will cleanup all the LdSlots inserted at the top of the function, after we run unreachable block elimination phase. But since we turn off deadstore for functions with try/catch, we end up having a nullptr AV. Fixes OS#17447405
2 parents 8cd6346 + 1a9529a commit cd27b56

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ BackwardPass::DoMarkTempObjectVerify() const
107107
bool
108108
BackwardPass::DoDeadStore(Func* func)
109109
{
110-
return
111-
!PHASE_OFF(Js::DeadStorePhase, func) &&
112-
(!func->HasTry() || func->DoOptimizeTry());
110+
return !PHASE_OFF(Js::DeadStorePhase, func);
113111
}
114112

115113
bool
@@ -124,8 +122,7 @@ bool
124122
BackwardPass::DoDeadStoreSlots() const
125123
{
126124
// only dead store fields if glob opt is on to generate the trackable fields bitvector
127-
return (tag == Js::DeadStorePhase && this->func->DoGlobOpt()
128-
&& (!this->func->HasTry()));
125+
return (tag == Js::DeadStorePhase && this->func->DoGlobOpt());
129126
}
130127

131128
// Whether dead store is enabled for given func and sym.

test/EH/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,11 @@
204204
<files>tfjitloopbug.js</files>
205205
</default>
206206
</test>
207+
<test>
208+
<default>
209+
<files>tcdeadstorebug.js</files>
210+
<compile-flags> -maxinterpretcount:1 -maxsimplejitruncount:1 -MinMemOpCount:0 -werexceptionsupport -bgjit- -loopinterpretcount:1</compile-flags>
211+
<tags>exclude_dynapogo</tags>
212+
</default>
213+
</test>
207214
</regress-exe>

test/EH/tcdeadstorebug.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
function test0() {
6+
var i32 = new Int32Array(1);
7+
{
8+
class class0 {
9+
}
10+
class class8 {
11+
}
12+
class class17 {
13+
static func91(argMath135) {
14+
if (new class0() * h) {
15+
}
16+
}
17+
static func94() {
18+
return class8.func78;
19+
}
20+
}
21+
for (var _strvar2 in i32) {
22+
continue;
23+
try {
24+
} catch (ex) {
25+
class8;
26+
}
27+
}
28+
}
29+
}
30+
test0();
31+
test0();
32+
print("Passed");

0 commit comments

Comments
 (0)