Index: test/mjsunit/fixed-context-shapes-when-recompiling.js |
diff --git a/test/mjsunit/fixed-context-shapes-when-recompiling.js b/test/mjsunit/fixed-context-shapes-when-recompiling.js |
index bd64e3d1680de3d1b217ee790764e6fa8d5e5e01..7f88330d381d8f90cd7e015d61e4524810698379 100644 |
--- a/test/mjsunit/fixed-context-shapes-when-recompiling.js |
+++ b/test/mjsunit/fixed-context-shapes-when-recompiling.js |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Flags: --min-preparse-length 1 --allow-natives-syntax |
+// Flags: --min-preparse-length 1 --allow-natives-syntax --lazy-inner-functions |
// Test that the information on which variables to allocate in context doesn't |
// change when recompiling. |
@@ -50,6 +50,24 @@ |
} |
})(); |
+(function TestConstInInnerFunction() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ const a = 0; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
(function TestInnerFunctionParameter() { |
var a = 1; |
var b = 2; |
@@ -67,6 +85,23 @@ |
} |
})(); |
+(function TestInnerFunctionRestParameter() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner(...a) { |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
(function TestInnerInnerFunctionParameter() { |
var a = 1; |
var b = 2; |
@@ -84,6 +119,23 @@ |
} |
})(); |
+(function TestInnerInnerFunctionRestParameter() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ function innerinner(...a) { a; b; c; } |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
(function TestInnerArrowFunctionParameter() { |
var a = 1; |
var b = 2; |
@@ -101,6 +153,23 @@ |
} |
})(); |
+(function TestInnerArrowFunctionRestParameter() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ var f = (...a) => a + b + c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
(function TestInnerFunctionInnerFunction() { |
var a = 1; |
var b = 2; |
@@ -252,9 +321,171 @@ |
} |
})(); |
+(function TestInnerFunctionDestructuring1() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ var [a, a2] = [1, 2]; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring2() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ let [a, a2] = [1, 2]; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring3() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ const [a, a2] = [1, 2]; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring4() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ var [a2, ...a] = [1, 2]; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring5() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ let [a2, ...a] = [1, 2]; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring6() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ const [a2, ...a] = [1, 2]; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring7() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ var {a, a2} = {a: 1, a2: 2}; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring8() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ let {a, a2} = {a: 1, a2: 2}; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
+(function TestInnerFunctionDestructuring9() { |
+ var a = 1; |
+ var b = 2; |
+ var c = 3; |
+ function inner() { |
+ const {a, a2} = {a: 1, a2: 2}; |
+ a; b; c; |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ assertEquals(1, a); |
+ assertEquals(2, b); |
+ assertEquals(3, c); |
+ } |
+})(); |
+ |
// A cluster of similar tests where the inner function only declares a variable |
// whose name clashes with an outer function variable name, but doesn't use it. |
-(function TestRegress650969_1() { |
+(function TestRegress650969_1_var() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
@@ -266,67 +497,67 @@ |
} |
})(); |
-(function TestRegress650969_2() { |
+(function TestRegress650969_1_let() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
} |
var a; |
function inner() { |
- var a = 6; |
+ let a; |
} |
} |
})(); |
-(function TestRegress650969_3() { |
+(function TestRegress650969_2_var() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
} |
var a; |
function inner() { |
- var a, b; |
+ var a = 6; |
} |
} |
})(); |
-(function TestRegress650969_4() { |
+(function TestRegress650969_2_let() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
} |
var a; |
function inner() { |
- var a = 6, b; |
+ let a = 6; |
} |
} |
})(); |
-(function TestRegress650969_5() { |
+(function TestRegress650969_2_const() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
} |
var a; |
function inner() { |
- let a; |
+ const a = 6; |
} |
} |
})(); |
-(function TestRegress650969_6() { |
+(function TestRegress650969_3_var() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
} |
var a; |
function inner() { |
- let a = 6; |
+ var a, b; |
} |
} |
})(); |
-(function TestRegress650969_7() { |
+(function TestRegress650969_3_let() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
@@ -338,7 +569,19 @@ |
} |
})(); |
-(function TestRegress650969_8() { |
+(function TestRegress650969_4_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var a = 6, b; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_4_let() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
%OptimizeOsr(); |
@@ -350,6 +593,18 @@ |
} |
})(); |
+(function TestRegress650969_4_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const a = 0, b = 0; |
+ } |
+ } |
+})(); |
+ |
(function TestRegress650969_9() { |
for (var i = 0; i < 3; ++i) { |
if (i == 1) { |
@@ -360,3 +615,307 @@ |
} |
} |
})(); |
+ |
+(function TestRegress650969_10() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner(...a) { |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_11_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var [a, b] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_11_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ let [a, b] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_11_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const [a, b] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_12_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var [b, a] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_12_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ let [b, a] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_12_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const [b, a] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_13_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var [b, ...a] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_13_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ let [b, ...a] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_13_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const [b, ...a] = [1, 2]; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_14_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var {a, b} = {a: 1, b: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_14_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ let {a, b} = {a: 1, b: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_14_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const {a, b} = {a: 1, b: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_15_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var {b: {a}, c} = {b: {a: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_15_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ let {b: {a}, c} = {b: {a: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_15_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const {b: {a}, c} = {b: {a: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_16_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ var {a: {b}, c} = {a: {b: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_16_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ let {a: {b}, c} = {a: {b: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_16_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ const {a: {b}, c} = {a: {b: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_17_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ for (var a = 0; 0 == 1; ) { } |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_17_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ for (let a = 0; 0 == 1; ) { } |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_17_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a; |
+ function inner() { |
+ for (const a = 0; 0 == 1; ) { } |
+ } |
+ } |
+})(); |
+ |
+// Regression tests for an intermediate stage where unresolved references were |
+// discarded too aggressively. |
+(function TestRegress650969_sidetrack_var() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a = 0; |
+ function inner() { |
+ return a; |
+ var {b: {a}, c} = {b: {a: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_sidetrack_let() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a = 0; |
+ function inner() { |
+ return a; |
+ let {b: {a}, c} = {b: {a: 1}, c: 2}; |
+ } |
+ } |
+})(); |
+ |
+(function TestRegress650969_sidetrack_const() { |
+ for (var i = 0; i < 3; ++i) { |
+ if (i == 1) { |
+ %OptimizeOsr(); |
+ } |
+ var a = 0; |
+ function inner() { |
+ return a; |
+ const {b: {a}, c} = {b: {a: 1}, c: 2}; |
+ } |
+ } |
+})(); |