diff options
Diffstat (limited to 'js/src/jit-test/tests/typedarray/ensure-non-inline.js')
-rw-r--r-- | js/src/jit-test/tests/typedarray/ensure-non-inline.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/typedarray/ensure-non-inline.js b/js/src/jit-test/tests/typedarray/ensure-non-inline.js new file mode 100644 index 0000000000..d8859fa627 --- /dev/null +++ b/js/src/jit-test/tests/typedarray/ensure-non-inline.js @@ -0,0 +1,85 @@ +const constructors = [ + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array ]; + +function messWith(view, obj) { + view[0] = 1; + view[1] = 1; + view[2] = 2; + view[3] = 3; + ensureNonInline(obj); + assertEq(view[0], 1); + assertEq(view[1], 1); + assertEq(view[2], 2); + assertEq(view[3], 3); +} + +function test() { + // Bufferless + for (const ctor of constructors) { + let small = new ctor(4); + messWith(small, small); + let big = new ctor(4000); + messWith(big, big); + } + + // With buffer, single view, operate on view + for (const ctor of constructors) { + let ab = new ArrayBuffer(96); + const small = new ctor(ab); + messWith(small, small); + ab = new ArrayBuffer(4000); + const big = new ctor(ab); + messWith(big, big); + } + + // With buffer, single view, operate on ArrayBuffer + for (const ctor of constructors) { + let ab = new ArrayBuffer(96); + const small = new ctor(ab); + messWith(small, ab); + ab = new ArrayBuffer(4000); + const big = new ctor(ab); + messWith(big, ab); + } + + // With buffer, dual view, operate on view + for (const ctor of constructors) { + let ab = new ArrayBuffer(96); + let view0 = new Uint8Array(ab); + const small = new ctor(ab); + messWith(small, small); + ab = new ArrayBuffer(4000); + view0 = new Uint8Array(ab); + const big = new ctor(ab); + messWith(big, big); + } + + // With buffer, dual view, operate on ArrayBuffer + for (const ctor of constructors) { + let ab = new ArrayBuffer(96); + let view0 = new Uint8Array(ab); + const small = new ctor(ab); + messWith(small, ab); + ab = new ArrayBuffer(4000); + view0 = new Uint8Array(ab); + const big = new ctor(ab); + messWith(big, ab); + } +} + +try { + ensureNonInline(new Array(3)); + assertEq(false, true); +} catch (e) { + assertEq(e.message.includes("unhandled type"), true); +} + +test(); |