diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/ion/getelem-bounds-hoist.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/ion/getelem-bounds-hoist.js | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/getelem-bounds-hoist.js b/js/src/jit-test/tests/ion/getelem-bounds-hoist.js new file mode 100644 index 0000000000..694da72d6a --- /dev/null +++ b/js/src/jit-test/tests/ion/getelem-bounds-hoist.js @@ -0,0 +1,83 @@ +var a = [1,2,3,4,5]; + +// Basic overflow in hoisted condition. +function foo(x, n) { + var v = 0; + for (var i = 0; i < n; i++) + v += x[i]; + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo(a, 5), 15); +assertEq(foo(a, 6), NaN); + +// Basic underflow in hoisted condition. +function foo2(x, m, n) { + var v = 0; + for (var i = m; i < n; i++) + v += x[i]; + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo2(a, 0, 5), 15); +assertEq(foo2(a, -1, 5), NaN); + +// Overflow when hoisting consolidated condition. +function foo3(x, m, n) { + var v = 0; + for (var i = m; i < n; i++) + v += x[i] + x[i + 1] + x[i + 2]; + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo3(a, 0, 3), 27); +assertEq(foo3(a, 0, 4), NaN); + +// Underflow when hoisting consolidated condition. +function foo4(x, m, n) { + var v = 0; + for (var i = m; i < n; i++) + v += x[i] + x[i - 1] + x[i - 2]; + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo4(a, 2, 5), 27); +assertEq(foo4(a, 0, 5), NaN); + +// Underflow due to decreasing index. +function foo5(x, n) { + var v = 0; + for (var i = 0; i < n; i++) { + v += x[i]; + if (n == 4) + i -= 2; + if (i == -5) + break; + } + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo5(a, 5), 15); +assertEq(foo5(a, 4), NaN); + +// Overflow after access at constant offset. +function foo6(x, m, n) { + var v = 0; + for (var i = m; i < n; i++) + v += x[i + 10]; + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo6(a, -10, -5), 15); +assertEq(foo6(a, -10, -4), NaN); + +// Underflow after access at constant offset. +function foo7(x, m, n) { + var v = 0; + for (var i = m; i < n; i++) + v += x[i + 10]; + return v; +} +for (var i = 0; i < 15; i++) + assertEq(foo7(a, -10, -5), 15); +assertEq(foo7(a, -11, -5), NaN); |