summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/typedarray
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/typedarray')
-rw-r--r--js/src/jit-test/tests/typedarray/construct-with-growable-sharedarraybuffer.js81
-rw-r--r--js/src/jit-test/tests/typedarray/construct-with-resizable-arraybuffer.js102
-rw-r--r--js/src/jit-test/tests/typedarray/ensure-non-inline.js12
-rw-r--r--js/src/jit-test/tests/typedarray/growable-sharedarraybuffer-bytelength.js14
-rw-r--r--js/src/jit-test/tests/typedarray/indexed-integer-exotics.js8
-rw-r--r--js/src/jit-test/tests/typedarray/oom-allocating-arraybuffer-contents.js2
-rw-r--r--js/src/jit-test/tests/typedarray/oom-allocating-copying-same-buffer-contents.js2
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-arraybuffer-bytelength.js20
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-buffer-inlined-data-moved.js53
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength-with-sab.js29
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength.js41
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset-sab.js43
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset.js57
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem-with-sab.js49
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem.js49
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem-with-sab.js36
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem.js36
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-byteOffset.js73
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLength.js75
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLengthZeroOnOutOfBounds.js75
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-length-with-sab.js29
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-length.js41
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem-with-sab.js54
-rw-r--r--js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem.js54
24 files changed, 1027 insertions, 8 deletions
diff --git a/js/src/jit-test/tests/typedarray/construct-with-growable-sharedarraybuffer.js b/js/src/jit-test/tests/typedarray/construct-with-growable-sharedarraybuffer.js
new file mode 100644
index 0000000000..29696f0860
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/construct-with-growable-sharedarraybuffer.js
@@ -0,0 +1,81 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+// Test TypedArray constructor when called with growable SharedArrayBuffers.
+
+function testSharedArrayBuffer() {
+ function test() {
+ var N = 200;
+ var sab = new SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: (5 + N) * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < N; ++i) {
+ var ta = new Int32Array(sab);
+ assertEq(ta.length, 4 + i);
+
+ // Ensure auto-length tracking works correctly.
+ sab.grow((5 + i) * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 5 + i);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testSharedArrayBuffer();
+
+function testSharedArrayBufferAndByteOffset() {
+ function test() {
+ var N = 200;
+ var sab = new SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: (5 + N) * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < N; ++i) {
+ var ta = new Int32Array(sab, Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 3 + i);
+
+ // Ensure auto-length tracking works correctly.
+ sab.grow((5 + i) * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 4 + i);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testSharedArrayBufferAndByteOffset();
+
+function testSharedArrayBufferAndByteOffsetAndLength() {
+ function test() {
+ var N = 200;
+ var sab = new SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: (5 + N) * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < N; ++i) {
+ var ta = new Int32Array(sab, Int32Array.BYTES_PER_ELEMENT, 2);
+ assertEq(ta.length, 2);
+
+ // Ensure length doesn't change when resizing the buffer.
+ sab.grow((5 + i) * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 2);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testSharedArrayBufferAndByteOffsetAndLength();
+
+function testWrappedSharedArrayBuffer() {
+ var g = newGlobal();
+
+ function test() {
+ var N = 200;
+ var sab = new g.SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: (5 + N) * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < N; ++i) {
+ var ta = new Int32Array(sab);
+ assertEq(ta.length, 4 + i);
+
+ // Ensure auto-length tracking works correctly.
+ sab.grow((5 + i) * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 5 + i);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testWrappedSharedArrayBuffer();
diff --git a/js/src/jit-test/tests/typedarray/construct-with-resizable-arraybuffer.js b/js/src/jit-test/tests/typedarray/construct-with-resizable-arraybuffer.js
new file mode 100644
index 0000000000..33f7a4f6c6
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/construct-with-resizable-arraybuffer.js
@@ -0,0 +1,102 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+// Test TypedArray constructor when called with resizable ArrayBuffers.
+
+function testArrayBuffer() {
+ function test() {
+ var ab = new ArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: 5 * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < 200; ++i) {
+ var ta = new Int32Array(ab);
+ assertEq(ta.length, 4);
+
+ // Ensure auto-length tracking works correctly.
+ ab.resize(5 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 5);
+
+ ab.resize(2 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 2);
+
+ // Reset to original length.
+ ab.resize(4 * Int32Array.BYTES_PER_ELEMENT);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testArrayBuffer();
+
+function testArrayBufferAndByteOffset() {
+ function test() {
+ var ab = new ArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: 5 * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < 200; ++i) {
+ var ta = new Int32Array(ab, Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 3);
+
+ // Ensure auto-length tracking works correctly.
+ ab.resize(5 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 4);
+
+ ab.resize(2 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 1);
+
+ // Reset to original length.
+ ab.resize(4 * Int32Array.BYTES_PER_ELEMENT);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testArrayBufferAndByteOffset();
+
+function testArrayBufferAndByteOffsetAndLength() {
+ function test() {
+ var ab = new ArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: 5 * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < 200; ++i) {
+ var ta = new Int32Array(ab, Int32Array.BYTES_PER_ELEMENT, 2);
+ assertEq(ta.length, 2);
+
+ // Ensure length doesn't change when resizing the buffer.
+ ab.resize(5 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 2);
+
+ // Returns zero when the TypedArray get out-of-bounds.
+ ab.resize(2 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 0);
+
+ // Reset to original length.
+ ab.resize(4 * Int32Array.BYTES_PER_ELEMENT);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testArrayBufferAndByteOffsetAndLength();
+
+function testWrappedArrayBuffer() {
+ var g = newGlobal();
+
+ function test() {
+ var ab = new g.ArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT, {maxByteLength: 5 * Int32Array.BYTES_PER_ELEMENT});
+ for (var i = 0; i < 200; ++i) {
+ var ta = new Int32Array(ab);
+ assertEq(ta.length, 4);
+
+ // Ensure auto-length tracking works correctly.
+ ab.resize(5 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 5);
+
+ ab.resize(2 * Int32Array.BYTES_PER_ELEMENT);
+ assertEq(ta.length, 2);
+
+ // Reset to original length.
+ ab.resize(4 * Int32Array.BYTES_PER_ELEMENT);
+ }
+ }
+ for (var i = 0; i < 2; ++i) {
+ test();
+ }
+}
+testWrappedArrayBuffer();
diff --git a/js/src/jit-test/tests/typedarray/ensure-non-inline.js b/js/src/jit-test/tests/typedarray/ensure-non-inline.js
index d8859fa627..a1321be88a 100644
--- a/js/src/jit-test/tests/typedarray/ensure-non-inline.js
+++ b/js/src/jit-test/tests/typedarray/ensure-non-inline.js
@@ -1,3 +1,5 @@
+// |jit-test| --enable-arraybuffer-resizable
+
const constructors = [
Int8Array,
Uint8Array,
@@ -73,6 +75,16 @@ function test() {
const big = new ctor(ab);
messWith(big, ab);
}
+
+ // With resizable buffer.
+ for (const ctor of constructors) {
+ let ab = new ArrayBuffer(32, {maxByteLength: 64});
+ const small = new ctor(ab);
+ messWith(small, small);
+ ab = new ArrayBuffer(4000, {maxByteLength: 4096});
+ const big = new ctor(ab);
+ messWith(big, big);
+ }
}
try {
diff --git a/js/src/jit-test/tests/typedarray/growable-sharedarraybuffer-bytelength.js b/js/src/jit-test/tests/typedarray/growable-sharedarraybuffer-bytelength.js
new file mode 100644
index 0000000000..421bf03475
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/growable-sharedarraybuffer-bytelength.js
@@ -0,0 +1,14 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+function testGrowableSharedArrayBuffer() {
+ for (let i = 0; i < 4; ++i) {
+ let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
+ for (let j = 0; j < 100; ++j) {
+ assertEq(sab.byteLength, i + j);
+
+ sab.grow(i + j + 1);
+ assertEq(sab.byteLength, i + j + 1);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testGrowableSharedArrayBuffer();
diff --git a/js/src/jit-test/tests/typedarray/indexed-integer-exotics.js b/js/src/jit-test/tests/typedarray/indexed-integer-exotics.js
index 6331efd7c3..510e57c0f0 100644
--- a/js/src/jit-test/tests/typedarray/indexed-integer-exotics.js
+++ b/js/src/jit-test/tests/typedarray/indexed-integer-exotics.js
@@ -88,10 +88,10 @@ assertEq(undefined, f());
// These checks currently fail due to bug 1129202 not being implemented yet.
// We should uncomment them once that bug landed.
-//assertThrows('Object.defineProperty(new Int32Array(100), -1, {value: 1})');
+assertThrows('Object.defineProperty(new Int32Array(100), -1, {value: 1})');
// -0 gets converted to the string "0", so use "-0" instead.
-//assertThrows('Object.defineProperty(new Int32Array(100), "-0", {value: 1})');
-//assertThrows('Object.defineProperty(new Int32Array(100), -10, {value: 1})');
-//assertThrows('Object.defineProperty(new Int32Array(), 4294967295, {value: 1})');
+assertThrows('Object.defineProperty(new Int32Array(100), "-0", {value: 1})');
+assertThrows('Object.defineProperty(new Int32Array(100), -10, {value: 1})');
+assertThrows('Object.defineProperty(new Int32Array(), 4294967295, {value: 1})');
check();
diff --git a/js/src/jit-test/tests/typedarray/oom-allocating-arraybuffer-contents.js b/js/src/jit-test/tests/typedarray/oom-allocating-arraybuffer-contents.js
index 16d1bf976f..1362c8d14c 100644
--- a/js/src/jit-test/tests/typedarray/oom-allocating-arraybuffer-contents.js
+++ b/js/src/jit-test/tests/typedarray/oom-allocating-arraybuffer-contents.js
@@ -1,5 +1,3 @@
-// |jit-test| skip-if: !('oomTest' in this)
-
// Resolve ArrayBuffer before OOM-testing, so OOM-testing runs less code and is
// less fragile.
var AB = ArrayBuffer;
diff --git a/js/src/jit-test/tests/typedarray/oom-allocating-copying-same-buffer-contents.js b/js/src/jit-test/tests/typedarray/oom-allocating-copying-same-buffer-contents.js
index ec33e4ef8e..cdbc3d7215 100644
--- a/js/src/jit-test/tests/typedarray/oom-allocating-copying-same-buffer-contents.js
+++ b/js/src/jit-test/tests/typedarray/oom-allocating-copying-same-buffer-contents.js
@@ -1,5 +1,3 @@
-// |jit-test| skip-if: !('oomTest' in this)
-
var buffer = new ArrayBuffer(16);
var i8 = new Int8Array(buffer);
var i16 = new Int16Array(buffer);
diff --git a/js/src/jit-test/tests/typedarray/resizable-arraybuffer-bytelength.js b/js/src/jit-test/tests/typedarray/resizable-arraybuffer-bytelength.js
new file mode 100644
index 0000000000..7b50331a15
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-arraybuffer-bytelength.js
@@ -0,0 +1,20 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+function testResizableArrayBuffer() {
+ for (let i = 0; i < 4; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ab.byteLength, i);
+
+ ab.resize(i + 1);
+ assertEq(ab.byteLength, i + 1);
+
+ if (i > 0) {
+ ab.resize(i - 1);
+ assertEq(ab.byteLength, i - 1);
+ }
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
diff --git a/js/src/jit-test/tests/typedarray/resizable-buffer-inlined-data-moved.js b/js/src/jit-test/tests/typedarray/resizable-buffer-inlined-data-moved.js
new file mode 100644
index 0000000000..1206edd5e5
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-buffer-inlined-data-moved.js
@@ -0,0 +1,53 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+function fillArrayBuffer(rab) {
+ let fill = new Int8Array(rab);
+ for (let i = 0; i < fill.length; ++i) fill[i] = i + 1;
+}
+
+function test() {
+ let rab = new ArrayBuffer(4, {maxByteLength: 4});
+ let ta = new Int8Array(rab, 2, 2);
+
+ fillArrayBuffer(rab);
+
+ assertEq(ta[0], 3);
+ assertEq(ta[1], 4);
+
+ // Shrink to make |ta| out-of-bounds.
+ rab.resize(3);
+
+ // Request GC to move inline data.
+ gc();
+
+ // Grow to make |ta| in-bounds again.
+ rab.resize(4);
+
+ assertEq(ta[0], 3);
+ assertEq(ta[1], 0);
+}
+test();
+
+
+function testAutoLength() {
+ let rab = new ArrayBuffer(4, {maxByteLength: 4});
+ let ta = new Int8Array(rab, 2);
+
+ fillArrayBuffer(rab);
+
+ assertEq(ta[0], 3);
+ assertEq(ta[1], 4);
+
+ // Shrink to make |ta| out-of-bounds.
+ rab.resize(1);
+
+ // Request GC to move inline data.
+ gc();
+
+ // Grow to make |ta| in-bounds again.
+ rab.resize(4);
+
+ assertEq(ta[0], 0);
+ assertEq(ta[1], 0);
+}
+testAutoLength();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength-with-sab.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength-with-sab.js
new file mode 100644
index 0000000000..828e989b92
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength-with-sab.js
@@ -0,0 +1,29 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+function testResizableArrayBuffer() {
+ for (let i = 0; i < 4; ++i) {
+ let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
+ let ta = new Int8Array(sab, 0, i);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.byteLength, i);
+
+ sab.grow(i + j + 1);
+ assertEq(ta.byteLength, i);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
+
+function testResizableArrayBufferAutoLength() {
+ for (let i = 0; i < 4; ++i) {
+ let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
+ let ta = new Int8Array(sab);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.byteLength, i + j);
+
+ sab.grow(i + j + 1);
+ assertEq(ta.byteLength, i + j + 1);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength.js
new file mode 100644
index 0000000000..925750d186
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-bytelength.js
@@ -0,0 +1,41 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+function testResizableArrayBuffer() {
+ for (let i = 0; i < 4; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab, 0, i);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.byteLength, i);
+
+ ab.resize(i + 1);
+ assertEq(ta.byteLength, i);
+
+ if (i > 0) {
+ ab.resize(i - 1);
+ assertEq(ta.byteLength, 0);
+ }
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
+
+function testResizableArrayBufferAutoLength() {
+ for (let i = 0; i < 4; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.byteLength, i);
+
+ ab.resize(i + 1);
+ assertEq(ta.byteLength, i + 1);
+
+ if (i > 0) {
+ ab.resize(i - 1);
+ assertEq(ta.byteLength, i - 1);
+ }
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset-sab.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset-sab.js
new file mode 100644
index 0000000000..6142d75978
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset-sab.js
@@ -0,0 +1,43 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+function testResizableArrayBufferAutoLength() {
+ for (let i = 0; i < 4; ++i) {
+ let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
+ let ta = new Int8Array(sab);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.byteOffset, 0);
+
+ sab.grow(i + j + 1);
+ assertEq(ta.byteOffset, 0);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
+
+function testResizableArrayBufferAutoLengthNonZeroOffset() {
+ for (let i = 1; i < 4 + 1; ++i) {
+ let sab = new SharedArrayBuffer(i + 1, {maxByteLength: i + 100 + 1});
+ let ta = new Int8Array(sab, 1);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.byteOffset, 1);
+
+ sab.grow(i + j + 2);
+ assertEq(ta.byteOffset, 1);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLengthNonZeroOffset();
+
+function testResizableArrayBufferNonZeroOffset() {
+ for (let i = 2; i < 4 + 2; ++i) {
+ let sab = new SharedArrayBuffer(i + 2, {maxByteLength: i + 100 + 2});
+ let ta = new Int8Array(sab, 1, 1);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.byteOffset, 1);
+
+ sab.grow(i + j + 3);
+ assertEq(ta.byteOffset, 1);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferNonZeroOffset();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset.js
new file mode 100644
index 0000000000..56552eeb7f
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-byteoffset.js
@@ -0,0 +1,57 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+function testResizableArrayBufferAutoLength() {
+ for (let i = 0; i < 4; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.byteOffset, 0);
+
+ ab.resize(i + 1);
+ assertEq(ta.byteOffset, 0);
+
+ if (i > 0) {
+ ab.resize(i - 1);
+ assertEq(ta.byteOffset, 0);
+ }
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
+
+function testResizableArrayBufferAutoLengthNonZeroOffset() {
+ for (let i = 1; i < 4 + 1; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab, 1);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.byteOffset, 1);
+
+ ab.resize(i + 1);
+ assertEq(ta.byteOffset, 1);
+
+ ab.resize(i - 1);
+ assertEq(ta.byteOffset, i > 1 ? 1 : 0);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLengthNonZeroOffset();
+
+function testResizableArrayBufferNonZeroOffset() {
+ for (let i = 2; i < 4 + 2; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab, 1, 1);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.byteOffset, 1);
+
+ ab.resize(i + 1);
+ assertEq(ta.byteOffset, 1);
+
+ ab.resize(i - 1);
+ assertEq(ta.byteOffset, i > 2 ? 1 : 0);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferNonZeroOffset();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem-with-sab.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem-with-sab.js
new file mode 100644
index 0000000000..236641d9a8
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem-with-sab.js
@@ -0,0 +1,49 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+const TypedArrays = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ BigInt64Array,
+ BigUint64Array,
+];
+
+function test(TA) {
+ const length = 4;
+ const byteLength = length * TA.BYTES_PER_ELEMENT;
+
+ let rab = new SharedArrayBuffer(byteLength, {maxByteLength: byteLength});
+ let actual = new TA(rab);
+ let expected = new TA(length);
+ let type = expected[0].constructor;
+
+ for (let i = 0; i < length; ++i) {
+ actual[i] = type(i * i);
+ expected[i] = type(i * i);
+ }
+
+ // In-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % length;
+ assertEq(actual[index], expected[index]);
+ }
+
+ // Out-of-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % (length + 4);
+ assertEq(actual[index], expected[index]);
+ }
+}
+
+for (let TA of TypedArrays) {
+ // Copy test function to ensure monomorphic ICs.
+ let copy = Function(`return ${test}`)();
+
+ copy(TA);
+}
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem.js
new file mode 100644
index 0000000000..902841e526
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-get-elem.js
@@ -0,0 +1,49 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+const TypedArrays = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ BigInt64Array,
+ BigUint64Array,
+];
+
+function test(TA) {
+ const length = 4;
+ const byteLength = length * TA.BYTES_PER_ELEMENT;
+
+ let rab = new ArrayBuffer(byteLength, {maxByteLength: byteLength});
+ let actual = new TA(rab);
+ let expected = new TA(length);
+ let type = expected[0].constructor;
+
+ for (let i = 0; i < length; ++i) {
+ actual[i] = type(i * i);
+ expected[i] = type(i * i);
+ }
+
+ // In-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % length;
+ assertEq(actual[index], expected[index]);
+ }
+
+ // Out-of-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % (length + 4);
+ assertEq(actual[index], expected[index]);
+ }
+}
+
+for (let TA of TypedArrays) {
+ // Copy test function to ensure monomorphic ICs.
+ let copy = Function(`return ${test}`)();
+
+ copy(TA);
+}
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem-with-sab.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem-with-sab.js
new file mode 100644
index 0000000000..40d51ebfe2
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem-with-sab.js
@@ -0,0 +1,36 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+const TypedArrays = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ BigInt64Array,
+ BigUint64Array,
+];
+
+function test(TA) {
+ const length = 4;
+ const byteLength = length * TA.BYTES_PER_ELEMENT;
+
+ let rab = new SharedArrayBuffer(byteLength, {maxByteLength: byteLength});
+ let actual = new TA(rab);
+ let expected = new TA(length);
+
+ for (let i = 0; i < 200; ++i) {
+ let index = (i % (length + 4));
+ assertEq(index in actual, index in expected);
+ }
+}
+
+for (let TA of TypedArrays) {
+ // Copy test function to ensure monomorphic ICs.
+ let copy = Function(`return ${test}`)();
+
+ copy(TA);
+}
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem.js
new file mode 100644
index 0000000000..07d44bf55b
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem.js
@@ -0,0 +1,36 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+const TypedArrays = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ BigInt64Array,
+ BigUint64Array,
+];
+
+function test(TA) {
+ const length = 4;
+ const byteLength = length * TA.BYTES_PER_ELEMENT;
+
+ let rab = new ArrayBuffer(byteLength, {maxByteLength: byteLength});
+ let actual = new TA(rab);
+ let expected = new TA(length);
+
+ for (let i = 0; i < 200; ++i) {
+ let index = (i % (length + 4));
+ assertEq(index in actual, index in expected);
+ }
+}
+
+for (let TA of TypedArrays) {
+ // Copy test function to ensure monomorphic ICs.
+ let copy = Function(`return ${test}`)();
+
+ copy(TA);
+}
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-byteOffset.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-byteOffset.js
new file mode 100644
index 0000000000..1b9f9a28e7
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-byteOffset.js
@@ -0,0 +1,73 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+const TypedArrayByteOffset = getSelfHostedValue("TypedArrayByteOffset");
+
+function testTypedArrayByteOffset() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab),
+ new Int8Array(ab, 1),
+ new Int8Array(ab, 2),
+ new Int8Array(ab, 3),
+ ];
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayByteOffset(ta), i & 3);
+ }
+}
+testTypedArrayByteOffset();
+
+function testTypedArrayByteOffsetOutOfBounds() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab, 0, 10),
+ new Int8Array(ab, 1, 10),
+ new Int8Array(ab, 2, 10),
+ new Int8Array(ab, 3, 10),
+ ];
+
+ // Resize to zero to make all views out-of-bounds.
+ ab.resize(0);
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayByteOffset(ta), i & 3);
+ }
+}
+testTypedArrayByteOffsetOutOfBounds();
+
+function testTypedArrayByteOffsetDetached() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab, 0, 10),
+ new Int8Array(ab, 1, 10),
+ new Int8Array(ab, 2, 10),
+ new Int8Array(ab, 3, 10),
+ ];
+
+ // Detach the buffer.
+ ab.transfer();
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayByteOffset(ta), 0);
+ }
+}
+testTypedArrayByteOffsetDetached();
+
+function testTypedArrayByteOffsetWithShared() {
+ let ab = new SharedArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab),
+ new Int8Array(ab, 1),
+ new Int8Array(ab, 2),
+ new Int8Array(ab, 3),
+ ];
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayByteOffset(ta), i & 3);
+ }
+}
+testTypedArrayByteOffsetWithShared();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLength.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLength.js
new file mode 100644
index 0000000000..c36b4f997f
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLength.js
@@ -0,0 +1,75 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+load(libdir + "asserts.js");
+
+const TypedArrayLength = getSelfHostedValue("TypedArrayLength");
+
+function testTypedArrayLength() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab),
+ new Int8Array(ab, 1),
+ new Int8Array(ab, 2),
+ new Int8Array(ab, 3),
+ ];
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLength(ta), 100 - (i & 3));
+ }
+}
+testTypedArrayLength();
+
+function testTypedArrayLengthOutOfBounds() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab, 0, 10),
+ new Int8Array(ab, 1, 10),
+ new Int8Array(ab, 2, 10),
+ new Int8Array(ab, 3, 10),
+ ];
+
+ // Resize to zero to make all views out-of-bounds.
+ ab.resize(0);
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertThrowsInstanceOf(() => TypedArrayLength(ta), TypeError);
+ }
+}
+testTypedArrayLengthOutOfBounds();
+
+function testTypedArrayLengthDetached() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab, 0, 10),
+ new Int8Array(ab, 1, 10),
+ new Int8Array(ab, 2, 10),
+ new Int8Array(ab, 3, 10),
+ ];
+
+ // Detach the buffer.
+ ab.transfer();
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLength(ta), 0);
+ }
+}
+testTypedArrayLengthDetached();
+
+function testTypedArrayLengthWithShared() {
+ let ab = new SharedArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab),
+ new Int8Array(ab, 1),
+ new Int8Array(ab, 2),
+ new Int8Array(ab, 3),
+ ];
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLength(ta), 100 - (i & 3));
+ }
+}
+testTypedArrayLengthWithShared();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLengthZeroOnOutOfBounds.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLengthZeroOnOutOfBounds.js
new file mode 100644
index 0000000000..a272d7d8c2
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-intrinsic-typedArrayLengthZeroOnOutOfBounds.js
@@ -0,0 +1,75 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+load(libdir + "asserts.js");
+
+const TypedArrayLengthZeroOnOutOfBounds = getSelfHostedValue("TypedArrayLengthZeroOnOutOfBounds");
+
+function testTypedArrayLength() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab),
+ new Int8Array(ab, 1),
+ new Int8Array(ab, 2),
+ new Int8Array(ab, 3),
+ ];
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLengthZeroOnOutOfBounds(ta), 100 - (i & 3));
+ }
+}
+testTypedArrayLength();
+
+function testTypedArrayLengthOutOfBounds() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab, 0, 10),
+ new Int8Array(ab, 1, 10),
+ new Int8Array(ab, 2, 10),
+ new Int8Array(ab, 3, 10),
+ ];
+
+ // Resize to zero to make all views out-of-bounds.
+ ab.resize(0);
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLengthZeroOnOutOfBounds(ta), 0);
+ }
+}
+testTypedArrayLengthOutOfBounds();
+
+function testTypedArrayLengthDetached() {
+ let ab = new ArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab, 0, 10),
+ new Int8Array(ab, 1, 10),
+ new Int8Array(ab, 2, 10),
+ new Int8Array(ab, 3, 10),
+ ];
+
+ // Detach the buffer.
+ ab.transfer();
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLengthZeroOnOutOfBounds(ta), 0);
+ }
+}
+testTypedArrayLengthDetached();
+
+function testTypedArrayLengthWithShared() {
+ let ab = new SharedArrayBuffer(100, {maxByteLength: 100});
+ let typedArrays = [
+ new Int8Array(ab),
+ new Int8Array(ab, 1),
+ new Int8Array(ab, 2),
+ new Int8Array(ab, 3),
+ ];
+
+ for (let i = 0; i < 200; ++i) {
+ let ta = typedArrays[i & 3];
+ assertEq(TypedArrayLengthZeroOnOutOfBounds(ta), 100 - (i & 3));
+ }
+}
+testTypedArrayLengthWithShared();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-length-with-sab.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-length-with-sab.js
new file mode 100644
index 0000000000..9b1a9d41e8
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-length-with-sab.js
@@ -0,0 +1,29 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+function testResizableArrayBuffer() {
+ for (let i = 0; i < 4; ++i) {
+ let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
+ let ta = new Int8Array(sab, 0, i);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.length, i);
+
+ sab.grow(i + j + 1);
+ assertEq(ta.length, i);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
+
+function testResizableArrayBufferAutoLength() {
+ for (let i = 0; i < 4; ++i) {
+ let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
+ let ta = new Int8Array(sab);
+ for (let j = 0; j < 100; ++j) {
+ assertEq(ta.length, i + j);
+
+ sab.grow(i + j + 1);
+ assertEq(ta.length, i + j + 1);
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-length.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-length.js
new file mode 100644
index 0000000000..96bbc9752e
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-length.js
@@ -0,0 +1,41 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+function testResizableArrayBuffer() {
+ for (let i = 0; i < 4; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab, 0, i);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.length, i);
+
+ ab.resize(i + 1);
+ assertEq(ta.length, i);
+
+ if (i > 0) {
+ ab.resize(i - 1);
+ assertEq(ta.length, 0);
+ }
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
+
+function testResizableArrayBufferAutoLength() {
+ for (let i = 0; i < 4; ++i) {
+ let ab = new ArrayBuffer(i, {maxByteLength: i + 1});
+ let ta = new Int8Array(ab);
+ for (let j = 0; j < 100; ++j) {
+ ab.resize(i);
+ assertEq(ta.length, i);
+
+ ab.resize(i + 1);
+ assertEq(ta.length, i + 1);
+
+ if (i > 0) {
+ ab.resize(i - 1);
+ assertEq(ta.length, i - 1);
+ }
+ }
+ }
+}
+for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem-with-sab.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem-with-sab.js
new file mode 100644
index 0000000000..67a15e7714
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem-with-sab.js
@@ -0,0 +1,54 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
+
+const TypedArrays = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ BigInt64Array,
+ BigUint64Array,
+];
+
+function test(TA) {
+ const length = 4;
+ const byteLength = length * TA.BYTES_PER_ELEMENT;
+
+ let rab = new SharedArrayBuffer(byteLength, {maxByteLength: byteLength});
+ let actual = new TA(rab);
+ let expected = new TA(length);
+ let type = expected[0].constructor;
+
+ // In-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % length;
+
+ let v = type(i);
+ actual[index] = v;
+ expected[index] = v;
+
+ assertEq(actual[index], expected[index]);
+ }
+
+ // Out-of-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % (length + 4);
+
+ let v = type(i);
+ actual[index] = v;
+ expected[index] = v;
+
+ assertEq(actual[index], expected[index]);
+ }
+}
+
+for (let TA of TypedArrays) {
+ // Copy test function to ensure monomorphic ICs.
+ let copy = Function(`return ${test}`)();
+
+ copy(TA);
+}
diff --git a/js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem.js b/js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem.js
new file mode 100644
index 0000000000..91f5c7b048
--- /dev/null
+++ b/js/src/jit-test/tests/typedarray/resizable-typedarray-set-elem.js
@@ -0,0 +1,54 @@
+// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize
+
+const TypedArrays = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ BigInt64Array,
+ BigUint64Array,
+];
+
+function test(TA) {
+ const length = 4;
+ const byteLength = length * TA.BYTES_PER_ELEMENT;
+
+ let rab = new ArrayBuffer(byteLength, {maxByteLength: byteLength});
+ let actual = new TA(rab);
+ let expected = new TA(length);
+ let type = expected[0].constructor;
+
+ // In-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % length;
+
+ let v = type(i);
+ actual[index] = v;
+ expected[index] = v;
+
+ assertEq(actual[index], expected[index]);
+ }
+
+ // Out-of-bounds access
+ for (let i = 0; i < 200; ++i) {
+ let index = i % (length + 4);
+
+ let v = type(i);
+ actual[index] = v;
+ expected[index] = v;
+
+ assertEq(actual[index], expected[index]);
+ }
+}
+
+for (let TA of TypedArrays) {
+ // Copy test function to ensure monomorphic ICs.
+ let copy = Function(`return ${test}`)();
+
+ copy(TA);
+}