summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/typedarray-megamorphic-has.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/cacheir/typedarray-megamorphic-has.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 'js/src/jit-test/tests/cacheir/typedarray-megamorphic-has.js')
-rw-r--r--js/src/jit-test/tests/cacheir/typedarray-megamorphic-has.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/typedarray-megamorphic-has.js b/js/src/jit-test/tests/cacheir/typedarray-megamorphic-has.js
new file mode 100644
index 0000000000..e2348caca9
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/typedarray-megamorphic-has.js
@@ -0,0 +1,53 @@
+function has(k) {
+ var p = {};
+ p[k] = 1;
+
+ // TypedArrays intercept any TypedArray indices (canonical numeric indices in the spec),
+ // so when reading |k| from |ta| we shouldn't return the inherited property |p[k]|.
+ var ta = new Int32Array(10);
+ Object.setPrototypeOf(ta, p);
+
+ // Assume sixteen different objects trigger a transition to a megamorphic IC.
+ var xs = [
+ ta,
+
+ {a:0}, {b:0}, {c:0}, {d:0}, {e:0}, {f:0}, {g:0}, {h:0},
+ {j:0}, {k:0}, {l:0}, {m:0}, {n:0}, {o:0}, {p:0},
+ ];
+
+ for (var i = 0; i < 100; ++i) {
+ var x = xs[i & 15];
+ assertEq(k in x, false);
+ }
+}
+
+// Make sure we use a distinct function for each test.
+function test(fn) {
+ return Function(`return ${fn};`)();
+}
+
+// TypedArray index representable as an Int32.
+test(has)(100);
+test(has)("100");
+
+// TypedArray index not representable as an Int32.
+test(has)(4294967296);
+test(has)("4294967296");
+
+// Non-finite TypedArray indices.
+test(has)(Infinity);
+test(has)("Infinity");
+
+test(has)(-Infinity);
+test(has)("-Infinity");
+
+test(has)(NaN);
+test(has)("NaN");
+
+// TypedArray index with fractional parts.
+test(has)(1.1);
+test(has)("1.1");
+
+// TypedArray index with exponent parts.
+test(has)(1e+25);
+test(has)("1e+25");