summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/getelem-bounds-hoist.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/ion/getelem-bounds-hoist.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/ion/getelem-bounds-hoist.js')
-rw-r--r--js/src/jit-test/tests/ion/getelem-bounds-hoist.js83
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 000000000..694da72d6
--- /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);