Skip to content

Commit 7c2426d

Browse files
committed
Similar issue to the missiung-undef-initialization case I fixed last week, this is the case where we have a dominating initialization that nevertheless doesn't write to the variable's register, but a later delay-captured reference does write to the register. Conservatively emitting undef-init now; delay capture needs to be revisited in the wake of the stable closures change.
1 parent 669f058 commit 7c2426d

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

lib/Runtime/ByteCode/ByteCodeEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ void ByteCodeGenerator::DefineUserVars(FuncInfo *funcInfo)
13891389

13901390
// Undef-initialize the home location if it is a register (not closure-captured, or else capture
13911391
// is delayed) or a property of an object.
1392-
if ((!sym->GetHasInit() && (!sym->NeedsSlotAlloc(funcInfo) || sym->GetHasNonCommittedReference())) ||
1392+
if ((sym->GetLocation() != Js::Constants::NoRegister && (!sym->GetHasInit() || (sym->NeedsSlotAlloc(funcInfo) && sym->GetHasNonCommittedReference()))) ||
13931393
(funcInfo->bodyScope->GetIsObject() && !funcInfo->GetHasCachedScope()))
13941394
{
13951395
Js::RegSlot reg = sym->GetLocation();
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
function test0() {
2+
var loopInvariant = false ? 7 : 12;
3+
var GiantPrintArray = [];
4+
function makeArrayLength() {
5+
}
6+
function leaf() {
7+
}
8+
var obj0 = {};
9+
var protoObj0 = {};
10+
var obj1 = {};
11+
var arrObj0 = {};
12+
var litObj0 = { prop1: 3.14159265358979 };
13+
var litObj1 = { prop0: 0 };
14+
var func0 = function () {
15+
};
16+
var func1 = function () {
17+
};
18+
var func2 = function () {
19+
for (; protoObj0.prop0; 2) {
20+
ary(851125506.1 !== 2 && 2 < arrObj0.prop2, func0(arguments[2 + 0]), ary.reverse(), typeof ary[((Object.prototype.prop2 !== Object.prototype.length || obj5.prop1 < Object.prototype.length) >= 0 ? Object.prototype.prop2 !== Object.prototype.length || obj5.prop1 < Object.prototype.length : 0) & 15] != 'undefined', ui8[loopInvariant + 1 & 255] * (false ? (Object.defineProperty(obj5, 'prop0', {
21+
get: function () {
22+
WScript.Echo();
23+
return 3;
24+
},
25+
configurable: true
26+
}), 4294967297 & 702469842) : 4294967297 & 702469842) + ary.unshift(typeof obj5.prop0 != 'number', -1556722774.9 + Object.prototype.prop2, !221, func0.call(arrObj0, -1556722774.9 + Object.prototype.prop2), Object.prototype.prop2 >>= 33, typeof obj0.prop2 != 'object', -8074665319890990000 && 1413529899.1, obj5.prop1 = obj5.prop0, function () {
27+
;
28+
} instanceof (typeof Number == 'function' ? Number : Object), Math.sin(Object.prototype.prop0), -8074665319890990000 && 1413529899.1), typeof protoObj0.length == 'object', arguments[((typeof Object.prototype.prop1-- == 'boolean') >= 0 ? typeof Object.prototype.prop1-- == 'boolean' : 0) & 15]);
29+
func0(uic8[1522725379.1]);
30+
}
31+
};
32+
var func3 = function () {
33+
};
34+
var func4 = function () {
35+
};
36+
obj0.method0 = func2;
37+
obj1.method0 = obj0.method0;
38+
var ary = Array(10);
39+
var i8 = new Int8Array(256);
40+
var i16 = new Int16Array();
41+
var i32 = new Int32Array();
42+
var ui8 = new Uint8Array();
43+
var ui16 = new Uint16Array();
44+
var ui32 = new Uint32Array();
45+
var f32 = new Float32Array();
46+
var f64 = new Float64Array();
47+
var uic8 = new Uint8ClampedArray();
48+
var IntArr0 = Array(9);
49+
var IntArr1 = Array(-1399162652, 173143797, -1810098018, 96552438, 65535, -14752727, 1269200816, 226, -229);
50+
var FloatArr0 = [];
51+
var VarArr0 = Array();
52+
var a = 0;
53+
var b = 851125506.1;
54+
177;
55+
243;
56+
var aliasOflitObj0 = litObj0;
57+
-137;
58+
makeArrayLength(8805654756604090000);
59+
-1178371243;
60+
190816894 * this;
61+
var uniqobj4 = [];
62+
do {
63+
if (__loopvar0) {
64+
}
65+
var __loopvar1 = loopInvariant;
66+
for (var _strvar0 in i8) {
67+
if (4) {
68+
}
69+
obj1.method0();
70+
var __loopvar2 = loopInvariant, __loopSecondaryVar2_0 = loopInvariant;
71+
for (; _strvar0 < 3077559403207580000; VarArr0) {
72+
if (-2) {
73+
break;
74+
}
75+
var v1 = shouldBailout;
76+
var v2 = true;
77+
function v3() {
78+
Math(_strvar0 * __loopvar2);
79+
({ prop1: FloatArr0 });
80+
}
81+
v3(5);
82+
var __loopvar3 = loopInvariant, __loopSecondaryVar3_0 = loopInvariant;
83+
var __loopSecondaryVar4_0 = loopInvariant, __loopSecondaryVar4_1 = loopInvariant;
84+
85+
var __loopvar5 = loopInvariant - 3;
86+
for (var _strvar0 in FloatArr0) {
87+
if (typeof _strvar0 === 'string' && _strvar0.indexOf('method') != -1) {
88+
continue;
89+
}
90+
__loopvar5++;
91+
if (__loopvar5 == loopInvariant + 1) {
92+
break;
93+
}
94+
FloatArr0[_strvar0] = _strvar0;
95+
}
96+
var id28 = test0.caller >>> uic8[120 & 255];
97+
}
98+
}
99+
} while (false);
100+
var __loopvar0 = loopInvariant, __loopSecondaryVar0_0 = loopInvariant, __loopSecondaryVar0_1 = loopInvariant;
101+
}
102+
test0();
103+
104+
WScript.Echo('pass');

test/Closures/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
<tags>exclude_fre</tags>
7575
</default>
7676
</test>
77+
<test>
78+
<default>
79+
<files>delaycapture-loopbody2.js</files>
80+
<compile-flags>-lic:1 -bgjit- -InitializeInterpreterSlotsWithInvalidStackVar</compile-flags>
81+
<tags>exclude_fre</tags>
82+
</default>
83+
</test>
7784
<test>
7885
<default>
7986
<files>initcachedscope.js</files>

0 commit comments

Comments
 (0)