]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/exit-from-ftl-when-caller-passed-extra-args-then-use-function-dot-arguments.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / exit-from-ftl-when-caller-passed-extra-args-then-use-function-dot-arguments.js
diff --git a/tests/stress/exit-from-ftl-when-caller-passed-extra-args-then-use-function-dot-arguments.js b/tests/stress/exit-from-ftl-when-caller-passed-extra-args-then-use-function-dot-arguments.js
new file mode 100644 (file)
index 0000000..d0682ab
--- /dev/null
@@ -0,0 +1,37 @@
+function foo(a, b) {
+    var result = a + b;
+    bar();
+    return result;
+}
+
+var capturedArgs;
+function bar() {
+    capturedArgs = foo.arguments;
+}
+
+noInline(foo);
+noInline(bar);
+
+function arraycmp(a, b) {
+    if (a.length != b.length)
+        return false;
+    for (var i = 0; i < a.length; ++i) {
+        if (a[i] != b[i])
+            return false;
+    }
+    return true;
+}
+
+for (var i = 0; i < 10000; ++i) {
+    var result = foo(1, 2, 3, 4, 5, 6);
+    if (result != 3)
+        throw "Error: bad result in loop: " + result;
+    if (!arraycmp(capturedArgs, [1, 2, 3, 4, 5, 6]))
+        throw "Error: bad captured arguments in loop: " + capturedArgs;
+}
+
+var result = foo(2000000000, 2000000000, 3, 4, 5, 6);
+if (result != 4000000000)
+    throw "Error: bad result at end: " + result;
+if (!arraycmp(capturedArgs, [2000000000, 2000000000, 3, 4, 5, 6]))
+    throw "Error: bad captured arguments at end: " + Array.prototype.join.apply(capturedArgs, ",");