Skip to content

Commit 21b5e9d

Browse files
[MERGE #5232 @Penguinwizzard] Avoid hoisting speculation guards in simplejit
Merge pull request #5232 from Penguinwizzard:ponch_opt_nosimplejit There are issues with region determination for try/catch/finally and the blocks added for the speculation guard hoisting in simplejit (in fulljit, regions are determined earlier and avoid this issue). OS 17538614
2 parents 70af77e + e927650 commit 21b5e9d

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,10 @@ BackwardPass::ProcessBlock(BasicBlock * block)
28392839
if(IsCollectionPass())
28402840
{
28412841
#ifndef _M_ARM
2842-
if (this->collectionPassSubPhase == CollectionPassSubPhase::FirstPass)
2842+
if (
2843+
this->collectionPassSubPhase == CollectionPassSubPhase::FirstPass
2844+
&& !this->func->IsSimpleJit()
2845+
)
28432846
{
28442847
// In the collection pass we do multiple passes over loops. In these passes we keep
28452848
// track of sets of symbols, such that we can know whether or not they are used in
@@ -3232,7 +3235,11 @@ BackwardPass::ProcessBlock(BasicBlock * block)
32323235
if (this->tag == Js::DeadStorePhase)
32333236
{
32343237
#ifndef _M_ARM
3235-
if(block->loop && !this->isLoopPrepass)
3238+
if(
3239+
block->loop
3240+
&& !this->isLoopPrepass
3241+
&& !this->func->IsSimpleJit()
3242+
)
32363243
{
32373244
// In the second pass, we mark instructions that we go by as being safe or unsafe.
32383245
//
@@ -3602,12 +3609,17 @@ BackwardPass::ProcessBlock(BasicBlock * block)
36023609
NEXT_INSTR_BACKWARD_IN_BLOCK_EDITING;
36033610

36043611
#ifndef _M_ARM
3605-
if (this->tag == Js::DeadStorePhase
3612+
if (
3613+
this->tag == Js::DeadStorePhase
3614+
// We don't do the masking in simplejit due to reduced perf concerns and the issues
3615+
// with handling try/catch structures with late-added blocks
3616+
&& !this->func->IsSimpleJit()
36063617
// We don't need the masking blocks in asmjs/wasm mode
36073618
&& !block->GetFirstInstr()->m_func->GetJITFunctionBody()->IsAsmJsMode()
36083619
&& !block->GetFirstInstr()->m_func->GetJITFunctionBody()->IsWasmFunction()
36093620
&& !block->isDead
3610-
&& !block->isDeleted)
3621+
&& !block->isDeleted
3622+
)
36113623
{
36123624
FOREACH_PREDECESSOR_BLOCK(blockPred, block)
36133625
{

test/FlowGraph/for_of_try_catch.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
for(abcd of [])
8+
{
9+
try {
10+
} catch(e) {
11+
}
12+
try {
13+
} catch(e) {
14+
}
15+
}
16+
}
17+
18+
test0();
19+
test0();
20+
test0();
21+
22+
console.log("PASSED");

test/FlowGraph/rlexe.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
<test>
1010
<default>
1111
<files>weird1.js</files>
12-
<compile-flags>-maxinterpretcount:1 -maxsimplejitruncount:1 -werexceptionsupport -oopjit- -off:bailonnoprofile -off:cachedScope</compile-flags>
12+
<compile-flags>-maxinterpretcount:1 -maxsimplejitruncount:1 -oopjit- -off:bailonnoprofile -off:cachedScope</compile-flags>
1313
</default>
1414
</test>
1515
<test>
1616
<default>
1717
<files>weird2.js</files>
18-
<compile-flags>-maxinterpretcount:1 -maxsimplejitruncount:1 -werexceptionsupport -bgjit- -loopinterpretcount:1 -oopjit- -off:simplejit -force:inline</compile-flags>
18+
<compile-flags>-maxinterpretcount:1 -maxsimplejitruncount:1 -bgjit- -loopinterpretcount:1 -oopjit- -off:simplejit -force:inline</compile-flags>
19+
</default>
20+
</test>
21+
<test>
22+
<default>
23+
<files>for_of_try_catch.js</files>
24+
<compile-flags>-maxinterpretcount:1 -maxsimplejitruncount:1 -bgjit- -oopjit- -off:jitloopbody</compile-flags>
1925
</default>
2026
</test>
2127
</regress-exe>

0 commit comments

Comments
 (0)