JS/Inlining: refactor TemporaryAssignmentElimination, add more tests

This commit is contained in:
Alexey Andreev
2016-05-26 12:21:43 +03:00
parent b8b6999afc
commit a26c09ae81
8 changed files with 356 additions and 34 deletions
@@ -0,0 +1,19 @@
function f(x) {
return x;
}
function box() {
var result1, result2;
if (f(true)) {
result1 = "1";
}
if (result1 !== "1") return "fail1: " + result1;
if (f(false)) {
result2 = "1";
}
if (result2 !== void 0) return "fail2: " + result2;
return "OK";
}
@@ -0,0 +1,21 @@
function f(x) {
return x;
}
function box() {
var result1, result2, $a, $b;
if (f(true)) {
$a = "1";
}
result1 = $a;
if (result1 !== "1") return "fail1: " + result1;
if (f(false)) {
$b = "1";
}
result2 = $b;
if (result2 !== void 0) return "fail2: " + result2;
return "OK";
}
@@ -0,0 +1,71 @@
function f(x) {
return x;
}
function testRegular() {
var result;
result = f("testRegular");
return result;
}
function testIrregular() {
var result;
result = f("testIrregular");
return result;
}
function testDoubleUse1() {
var result;
var $b;
$b = f("testDoubleUse1");
result = $b;
f($b);
return result;
}
function testDoubleUse2() {
var $d;
$d = f("testDoubleUse2");
var result = $d;
f($d);
return result;
}
function testDoubleUse3() {
var result;
var $a;
$a = f("testDoubleUse3");
result = $a;
f($a);
return result;
}
function testCircular() {
var $b;
$b = f("testCircular");
$b = $b;
var result = $b;
return result;
}
function box() {
var result = testRegular();
if (result != "testRegular") return "failRegular: " + result;
result = testIrregular();
if (result != "testIrregular") return "failIrregular: " + result;
result = testDoubleUse1();
if (result != "testDoubleUse1") return "failDoubleUse1: " + result;
result = testDoubleUse2();
if (result != "testDoubleUse2") return "failDoubleUse2: " + result;
result = testDoubleUse3();
if (result != "testDoubleUse3") return "failDoubleUse3: " + result;
result = testCircular();
if (result != "testCircular") return "failCircular: " + result;
return "OK"
}
@@ -0,0 +1,89 @@
function f(x) {
return x;
}
function testRegular() {
var $a, $b, $c, $d;
$a = f("testRegular");
$b = $a;
$c = $b;
$d = $c;
var result = $d;
return result;
}
function testIrregular() {
var $a, $b, $d;
$a = f("testIrregular");
$b = $a;
var $c = $b;
$d = $c;
var result = $d;
return result;
}
function testDoubleUse1() {
var $a, $b, $c, $d;
$a = f("testDoubleUse1");
$b = $a;
$c = $b;
$d = $c;
var result = $d;
f($b);
return result;
}
function testDoubleUse2() {
var $a, $b, $c, $d;
$a = f("testDoubleUse2");
$b = $a;
$c = $b;
$d = $c;
var result = $d;
f($d);
return result;
}
function testDoubleUse3() {
var $a, $b, $c, $d;
$a = f("testDoubleUse3");
$b = $a;
$c = $b;
$d = $c;
var result = $d;
f($a);
return result;
}
function testCircular() {
var $a, $b, $c, $d;
$a = f("testCircular");
$b = $a;
$c = $b;
$d = $c;
$b = $d;
var result = $b;
return result;
}
function box() {
var result = testRegular();
if (result != "testRegular") return "failRegular: " + result;
result = testIrregular();
if (result != "testIrregular") return "failIrregular: " + result;
result = testDoubleUse1();
if (result != "testDoubleUse1") return "failDoubleUse1: " + result;
result = testDoubleUse2();
if (result != "testDoubleUse2") return "failDoubleUse2: " + result;
result = testDoubleUse3();
if (result != "testDoubleUse3") return "failDoubleUse3: " + result;
result = testCircular();
if (result != "testCircular") return "failCircular: " + result;
return "OK"
}
@@ -0,0 +1,57 @@
function f(x) {
return x;
}
function testCatch1() {
var result;
try {
result = f("testCatch1");
throw new Error();
} catch (e) {
}
return result;
}
function testCatch2() {
var result;
try {
throw new Error();
} catch (e) {
}
return result;
}
function testFinally() {
var result;
try {
result = f("testFinally");
} finally {
}
return result;
}
function testOuter() {
var result;
try {
result = f("testOuter");
} finally {
f("23")
}
return result;
}
function box() {
var result = testCatch1();
if (result !== "testCatch1") return "failCatch1: " + result;
result = testCatch2();
if (result !== void 0) return "failCatch2: " + result;
result = testFinally();
if (result !== "testFinally") return "failFinally: " + result;
result = testOuter();
if (result !== "testOuter") return "testOuter: " + result;
return "OK";
}
@@ -0,0 +1,66 @@
function f(x) {
return x;
}
function testCatch1() {
var $tmp;
var result;
try {
$tmp = f("testCatch1");
throw new Error();
} catch (e) {
result = $tmp;
}
return result;
}
function testCatch2() {
var $tmp;
var result;
try {
throw new Error();
$tmp = f("testCatch2");
} catch (e) {
result = $tmp;
}
return result;
}
function testFinally() {
var $tmp;
var result;
try {
$tmp = f("testFinally");
} finally {
result = $tmp;
}
return result;
}
function testOuter() {
var $tmp;
var result;
try {
$tmp = f("testOuter");
} finally {
f("23")
}
result = $tmp;
return result;
}
function box() {
var result = testCatch1();
if (result !== "testCatch1") return "failCatch1: " + result;
result = testCatch2();
if (result !== void 0) return "failCatch2: " + result;
result = testFinally();
if (result !== "testFinally") return "failFinally: " + result;
result = testOuter();
if (result !== "testOuter") return "testOuter: " + result;
return "OK";
}