]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/dead-access-to-captured-variable-preceded-by-a-live-store-in-function-with-multiple-basic-blocks.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / dead-access-to-captured-variable-preceded-by-a-live-store-in-function-with-multiple-basic-blocks.js
diff --git a/tests/stress/dead-access-to-captured-variable-preceded-by-a-live-store-in-function-with-multiple-basic-blocks.js b/tests/stress/dead-access-to-captured-variable-preceded-by-a-live-store-in-function-with-multiple-basic-blocks.js
new file mode 100644 (file)
index 0000000..ab8e3f3
--- /dev/null
@@ -0,0 +1,26 @@
+function foo(p) {
+    if (p) {
+        var x = 42;
+        (function() { x = 43; })();
+        x++;
+        var realResult = x;
+        (function() { x = 44; })();
+        var fakeResult = x;
+        return realResult;
+    }
+    var y = 45;
+    (function() { y = 46; })();
+    y++;
+    var realResult2 = y;
+    (function() { y = 47; })();
+    var fakeResult2 = y;
+    return realResult2;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 10000; ++i) {
+    var result = foo(i & 1);
+    if (result != ((i & 1) ? 44 : 47))
+        throw "Error: bad result with i = " + i + ": " + result;
+}