Bug 1273858 - Testcases r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Thu, 16 Feb 2017 22:51:18 -0500
changeset 373287 a6570d4652e65bf1106f6a1a6484294eeb570c20
parent 373286 0a3a0f9eb7737b7f7c28b638d0effc3f56b7aa4f
child 373288 6873195437cb47ecfd93aad7e43da6102e61014e
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1273858
milestone54.0a1
Bug 1273858 - Testcases r=jandem MozReview-Commit-ID: AasrybVpMgN
js/src/jit-test/tests/ion/bug1273858-1.js
js/src/jit-test/tests/ion/bug1273858-2.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug1273858-1.js
@@ -0,0 +1,53 @@
+// |jit-test| --no-threads
+
+function t1() {
+    let x = [];
+
+    for (let k = 0; k < 100; ++k)
+        x[k] = () => k; // Lexical capture
+
+    try {
+        eval("k");
+        throw false;
+    }
+    catch (e) {
+        if (!(e instanceof ReferenceError))
+            throw "Loop index escaped block";
+    }
+
+    for (var i = 0; i < 100; ++i)
+        if (x[i]() != i)
+            throw "Bad let capture";
+}
+t1();
+t1();
+t1();
+t1();
+
+function t2() {
+    let x = [];
+    let y = {};
+
+    for (var i = 0; i < 100; ++i)
+        x[i] = i;
+
+    for (const k of x)
+        y[k] = () => k; // Lexical capture
+
+    try {
+        eval("k");
+        throw false;
+    }
+    catch (e) {
+        if (!(e instanceof ReferenceError))
+            throw "Loop index escaped block";
+    }
+
+    for (var i = 0; i < 100; ++i)
+        if (y[i]() != i)
+            throw "Bad const capture";
+}
+t2();
+t2();
+t2();
+t2();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug1273858-2.js
@@ -0,0 +1,46 @@
+// |jit-test| --no-threads
+
+function t1() {
+    let x = [];
+
+    try
+    {
+        for (let k = 0; k < 100; ++k)
+        {
+            let w = () => k; // Lexical capture
+
+            if (w() > 10)
+            {
+                throw () => w; // Lexical capture
+            }
+
+            x[k] = w;
+        }
+    }
+    catch (e)
+    {
+        // 'w' and 'k' should leave scope as exception unwinds
+
+        try {
+            eval("k");
+            throw false;
+        }
+        catch (e) {
+            if (!(e instanceof ReferenceError))
+                throw "Loop index escaped block";
+        }
+
+        try {
+            eval("w");
+            throw false;
+        }
+        catch (e) {
+            if (!(e instanceof ReferenceError))
+                throw "Local name escaped block";
+        }
+    }
+}
+t1();
+t1();
+t1();
+t1();