Debian Codegraph @

js/src/jit-test/tests/typedarray/resizable-typedarray-has-elem-with-sab.js

raw
1 const TypedArrays = [
2 Int8Array,
3 Uint8Array,
4 Int16Array,
5 Uint16Array,
6 Int32Array,
7 Uint32Array,
8 Uint8ClampedArray,
9 Float16Array,
10 Float32Array,
11 Float64Array,
12 BigInt64Array,
13 BigUint64Array,
14 ];
15
16 function test(TA) {
17 const length = 4;
18 const byteLength = length * TA.BYTES_PER_ELEMENT;
19
20 let rab = new SharedArrayBuffer(byteLength, {maxByteLength: byteLength});
21 let actual = new TA(rab);
22 let expected = new TA(length);
23
24 for (let i = 0; i < 200; ++i) {
25 let index = (i % (length + 4));
26 assertEq(index in actual, index in expected);
27 }
28 }
29
30 for (let TA of TypedArrays) {
31 // Copy test function to ensure monomorphic ICs.
32 let copy = Function(`return ${test}`)();
33
34 copy(TA);
35 }