summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/bug670484.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/ion/bug670484.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/jit-test/tests/ion/bug670484.js101
1 files changed, 101 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/bug670484.js b/js/src/jit-test/tests/ion/bug670484.js
new file mode 100644
index 0000000000..81422f02f7
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug670484.js
@@ -0,0 +1,101 @@
+// Call a function with no arguments.
+function a_g() {
+ return 5;
+}
+
+function a_f(g) {
+ return g();
+}
+
+a_g();
+assertEq(a_f(a_g), 5);
+
+///////////////////////////////////////////////////////////////////////////////
+// Call a function with one argument.
+function b_g(a) {
+ return a;
+}
+
+function b_f(h,b) {
+ return h(5);
+}
+b_g(5);
+assertEq(b_f(b_g,4), 5);
+
+///////////////////////////////////////////////////////////////////////////////
+// Try to confuse the register allocator.
+function c_g(a) {
+ return a;
+}
+function c_f(h,b) {
+ var x = h(5);
+ var y = x + 1;
+ var z = h(h(y + x + 2));
+ var k = 2 + z + 3;
+ return h(h(h(k)));
+}
+c_g(2); // prime g().
+assertEq(c_f(c_g,7), 18)
+
+///////////////////////////////////////////////////////////////////////////////
+// Fail during unboxing, get kicked to interpreter.
+// Interpreter throws an exception; handle it.
+
+function d_f(a) {
+ return a(); // Call a known non-object. This fails in unboxing.
+}
+var d_x = 0;
+try {
+ d_f(1); // Don't assert.
+} catch(e) {
+ d_x = 1;
+}
+assertEq(d_x, 1);
+
+///////////////////////////////////////////////////////////////////////////////
+// Try passing an uncompiled function.
+
+function e_uncompiled(a,b,c) {
+ return eval("b");
+}
+function e_f(h) {
+ return h(0,h(2,4,6),1);
+}
+assertEq(e_f(e_uncompiled),4);
+
+///////////////////////////////////////////////////////////////////////////////
+// Try passing a native function.
+
+function f_app(f,n) {
+ return f(n);
+}
+assertEq(f_app(Math.sqrt, 16), 4);
+
+///////////////////////////////////////////////////////////////////////////////
+// Handle the case where too few arguments are passed.
+function g_g(a,b,c,d,e) {
+ return e;
+}
+
+function g_f(g) {
+ return g(2);
+}
+
+g_g();
+assertEq(g_f(g_g), undefined);
+
+///////////////////////////////////////////////////////////////////////////////
+// Don't assert when given a non-function object.
+function h_f(a) {
+ return a();
+}
+
+var x = new Object();
+var h_ret = 0;
+try {
+ h_f(x); // don't assert.
+} catch (e) {
+ h_ret = 1;
+}
+assertEq(h_ret, 1);
+