Skip to content

Commit 40f36e3

Browse files
committed
[MERGE #5275 @paolosevMSFT] OS#17417473 - Fixing hoisting of const symbols
Merge pull request #5275 from paolosevMSFT:user/paolosev/17417473 Modify GlobOpt::OptIsInvariant() to make sure a const symbol is not hoisted if not alive in landingPad.
2 parents 2dc8c3a + 717e1ae commit 40f36e3

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

lib/Backend/GlobOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14251,7 +14251,7 @@ GlobOpt::OptIsInvariant(Sym *sym, BasicBlock *block, Loop *loop, Value *srcVal,
1425114251
}
1425214252
else if (sym->IsPropertySym())
1425314253
{
14254-
if (!loop->landingPad->globOptData.liveFields->Test(sym->m_id))
14254+
if (!loop->landingPad->globOptData.liveFields->Test(sym->AsPropertySym()->m_stackSym->m_id))
1425514255
{
1425614256
return false;
1425714257
}

test/Bugs/bug_OS17417473.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+
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
7+
8+
var tests = [
9+
{
10+
name: "OS17417473: hoisting a constant propertySymbol should not trigger assertion",
11+
body: function () {
12+
function opt() {
13+
let _1337;
14+
s = "";
15+
s = "" & s.hasOwnProperty("");
16+
var s = 0x1337;
17+
for (i =0; i < 1; i++) {
18+
_1337 = s.hasOwnProperty("x");
19+
}
20+
}
21+
22+
// trigger the full jit
23+
for (let i = 0; i < 100; i++) {
24+
opt();
25+
}
26+
}
27+
},
28+
];
29+
30+
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });

test/Bugs/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,10 @@
472472
<files>symcmpbug.js</files>
473473
</default>
474474
</test>
475+
<test>
476+
<default>
477+
<files>bug_OS17417473.js</files>
478+
<compile-flags>-pageheap:2 -CollectGarbage -lic:4 -Sja:4 -Fja:6 -maxInterpretCount:2 -MinBailOutsBeforeRejit:2 -args summary -endargs</compile-flags>
479+
</default>
480+
</test>
475481
</regress-exe>

0 commit comments

Comments
 (0)