Skip to content

Commit d9e818b

Browse files
committed
Double counted copy-prop syms hit FailFast
- copy prop'd syms can be referenced by key and value - both key and value can be in the unrestorableSymbols list - always check for both key and value - in each case check if the symbol is needed based on the BackEndId being checked 'key' or 'value'
1 parent d5c6f59 commit d9e818b

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

lib/Backend/LinearScan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5135,13 +5135,13 @@ void LinearScan::GeneratorBailIn::BuildBailInSymbolList(
51355135

51365136
if (unrestorableSymbols.TestAndClear(value->m_id))
51375137
{
5138-
if (this->NeedsReloadingSymWhenBailingIn(copyPropSym.Key()))
5138+
if (this->NeedsReloadingSymWhenBailingIn(copyPropSym.Value()))
51395139
{
51405140
BailInSymbol bailInSym(key->m_id /* fromByteCodeRegSlot */, value->m_id /* toBackendId */);
51415141
bailInSymbols->PrependNode(this->func->m_alloc, bailInSym);
51425142
}
51435143
}
5144-
else if (unrestorableSymbols.TestAndClear(key->m_id))
5144+
if (unrestorableSymbols.TestAndClear(key->m_id))
51455145
{
51465146
if (this->NeedsReloadingSymWhenBailingIn(copyPropSym.Key()))
51475147
{

test/es6/async-jit-bugs.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
4+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
5+
//-------------------------------------------------------------------------------------------------------
6+
7+
function main() {
8+
const v2 = [13.37,13.37,13.37,13.37,13.37];
9+
async function v4(v5,v6,v7,v8) {
10+
const v10 = 0;
11+
for (let v14 = 0; v14 < 8; v14++) {
12+
v5["vEBD7ei78q"] = v14;
13+
}
14+
for (let v16 = 1; v16 < 1337; v16++) {
15+
const v17 = v2.__proto__;
16+
const v23 = [13.37,13.37,-2.2250738585072014e-308,13.37,13.37];
17+
const v24 = v23.length;
18+
const v25 = "-4294967296";
19+
const v26 = 7;
20+
function* v28(v29,v30,v31,...v32) {}
21+
let v33 = -2.2250738585072014e-308;
22+
const v34 = v28(v33,Object,Object);
23+
const v35 = 13.37;
24+
const v36 = 2384357829;
25+
const v37 = await "-4294967296";
26+
const v38 = --v33;
27+
}
28+
const v39 = 128;
29+
print("pass")
30+
}
31+
v4("vEBD7ei78q");
32+
}
33+
main();

test/es6/generator-jit-bugs.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
55
//-------------------------------------------------------------------------------------------------------
66

7-
let results = 0;
8-
let test = 0;
7+
// Simpler mini-test harness to avoid any complicating factors when testing these jit bugs
8+
var results = 0;
9+
var test = 0;
910
const verbose = WScript.Arguments[0] != "summary";
1011

1112
function check(actual, expected) {
@@ -90,6 +91,7 @@ check(gen4.next().value, 1);
9091
check(gen4.next().value, 2);
9192
check(gen4.next().value, 3);
9293

94+
// Test 5 - scope slots fail to load inside for-in loop
9395
title("Load Scope Slots in presence of for-in");
9496
function* gf5(v1) {
9597
for(v0 in v1) {
@@ -106,6 +108,7 @@ check(gen5.next().value, undefined);
106108
check(gen5.next().value, undefined);
107109
check(gen5.next().value, undefined);
108110

111+
// Test 6 - scope slots used in loop control have invalid values
109112
title("Load Scope Slots used in loop control");
110113
function* gf6 () {
111114
for (let v1 = 0; v1 < 1000; ++v1) {
@@ -121,6 +124,7 @@ check(gen6.next().value, 1);
121124
check(gen6.next().value, 2);
122125
check(gen6.next().value, 3);
123126

127+
// Test 7 - storing scoped slot from loop control in array
124128
title("Load Scope Slots used in loop control and captured indirectly");
125129
function* gf7(v1) {
126130
for (const v2 in v1) {
@@ -136,5 +140,17 @@ check(gen7.next().value, 1);
136140
check(gen7.next().value, 2);
137141
check(gen7.next().value, undefined);
138142

143+
// Test 8 - copy prop'd sym is counted as two values - hits bookkeeping FailFast
144+
title("Copy prop sym double counted in unrestorable symbols hits FailFast");
145+
function* gf8() {
146+
var v8 = 1.1;
147+
yield* [];
148+
yield {v8};
149+
}
150+
151+
check(gf8().next().value.v8, 1.1);
152+
check(gf8().next().value.v8, 1.1);
153+
check(gf8().next().value.v8, 1.1);
154+
139155

140156
print("pass");

test/es6/rlexe.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@
153153
<tags>exclude_nonative, exclude_dynapogo</tags>
154154
</default>
155155
</test>
156+
<test>
157+
<default>
158+
<files>async-jit-bugs.js</files>
159+
<compile-flags>-JitES6Generators -args summary -endargs</compile-flags>
160+
<tags>exclude_nonative</tags>
161+
</default>
162+
</test>
163+
<test>
164+
<default>
165+
<files>async-jit-bugs.js</files>
166+
<compile-flags>-JitES6Generators -off:simplejit -args summary -endargs</compile-flags>
167+
<tags>exclude_nonative</tags>
168+
</default>
169+
</test>
170+
<test>
171+
<default>
172+
<files>async-jit-bugs.js</files>
173+
<compile-flags>-JitES6Generators -off:fulljit -args summary -endargs</compile-flags>
174+
<tags>exclude_nonative, exclude_dynapogo</tags>
175+
</default>
176+
</test>
156177
<test>
157178
<default>
158179
<files>proto_basic.js</files>

0 commit comments

Comments
 (0)