diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/self-hosting/is-possibly-wrapped-typed-array.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/self-hosting/is-possibly-wrapped-typed-array.js')
-rw-r--r-- | js/src/jit-test/tests/self-hosting/is-possibly-wrapped-typed-array.js | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/self-hosting/is-possibly-wrapped-typed-array.js b/js/src/jit-test/tests/self-hosting/is-possibly-wrapped-typed-array.js new file mode 100644 index 000000000..5e76aad69 --- /dev/null +++ b/js/src/jit-test/tests/self-hosting/is-possibly-wrapped-typed-array.js @@ -0,0 +1,151 @@ +var IsPossiblyWrappedTypedArray = getSelfHostedValue("IsPossiblyWrappedTypedArray"); + +var declareSamples = ` + var allTypedArraySamples = [ + { value: new Int8Array(1), expected: true }, + { value: new Uint8Array(1), expected: true }, + { value: new Int16Array(1), expected: true }, + { value: new Uint16Array(1), expected: true }, + { value: new Int32Array(1), expected: true }, + { value: new Uint32Array(1), expected: true }, + { value: new Float32Array(1), expected: true }, + { value: new Float64Array(1), expected: true }, + { value: new Uint8ClampedArray(1), expected: true } + ]; + + var allObjectSamples = [ + { value: new Array(1), expected: false }, + { value: {}, expected: false }, + { value: { length: 1 }, expected: false } + ]; + + var allNonObjectSamples = [ + { value: "a", expected: false }, + { value: 1.2, expected: false }, + { value: true, expected: false }, + { value: Symbol("a"), expected: false } + ]; +`; + +// Create a new global to wrap with cross compartment wrappers. +var g = newGlobal(); +evaluate(declareSamples) +g.evaluate(declareSamples); + +var assertCode = `function (value, expected) { + assertEq(IsPossiblyWrappedTypedArray(value), expected); + return inIon(); +}`; + +function checkSamples(samples) { + // Create the assert function anew every run so as not to share JIT code, + // type information, etc. + var assert = new Function(`return (${assertCode})`)(); + + // Prevent Ion compilation of this function so that we don't freeze the + // sample array's type. If we did, IonBuilder's typed-array-length inlining + // would always see a Mixed state, preventing IsPossiblyWrappedTypedArray + // from being inlined. + with ({}) {}; + + do { + // spinInJit is used to ensure that we at least test all elements in the + // sample vector while running a compiled version of the assert + // function. + var spinInJit = true; + for (var i = 0; i < samples.length; i++) { + var e = samples[i]; + if (!e) continue; + spinInJit = spinInJit && assert(e.value, e.expected); + } + } while(!spinInJit); +} + +// Check a mix of samples from each type. +function test(a, b, c, d, e, f) { + var samples = [ + a == -1 ? null : allTypedArraySamples[a], + b == -1 ? null : allObjectSamples[b], + c == -1 ? null : allNonObjectSamples[c], + d == -1 ? null : g.allTypedArraySamples[d], + e == -1 ? null : g.allObjectSamples[e], + f == -1 ? null : g.allNonObjectSamples[f] + ]; + + checkSamples(samples); +} + +// Check all samples. +checkSamples(allTypedArraySamples); +checkSamples(allObjectSamples); +checkSamples(allNonObjectSamples); +checkSamples(g.allTypedArraySamples); +checkSamples(g.allObjectSamples); +checkSamples(g.allNonObjectSamples); + +// Check combinations mixing 2 elements from different types. +test(-1, -1, -1, -1, 0, 0); +test(-1, -1, -1, 0, -1, 0); +test(-1, -1, -1, 0, 0, -1); +test(-1, -1, 0, -1, -1, 0); +test(-1, -1, 0, -1, 0, -1); +test(-1, -1, 0, 0, -1, -1); +test(-1, 0, -1, -1, -1, 0); +test(-1, 0, -1, -1, 0, -1); +test(-1, 0, -1, 0, -1, -1); +test(-1, 0, 0, -1, -1, -1); +test( 0, -1, -1, -1, -1, 0); +test( 0, -1, -1, -1, 0, -1); +test( 0, -1, -1, 0, -1, -1); +test( 0, -1, 0, -1, -1, -1); +test( 0, 0, -1, -1, -1, -1); + +// Check combinations mixing 3 elements from different types. +test(-1, -1, -1, 0, 0, 0); +test(-1, -1, 0, -1, 0, 0); +test(-1, -1, 0, 0, -1, 0); +test(-1, -1, 0, 0, 0, -1); +test(-1, 0, -1, -1, 0, 0); +test(-1, 0, -1, 0, -1, 0); +test(-1, 0, -1, 0, 0, -1); +test(-1, 0, 0, -1, -1, 0); +test(-1, 0, 0, -1, 0, -1); +test(-1, 0, 0, 0, -1, -1); +test( 0, -1, -1, -1, 0, 0); +test( 0, -1, -1, 0, -1, 0); +test( 0, -1, -1, 0, 0, -1); +test( 0, -1, 0, -1, -1, 0); +test( 0, -1, 0, -1, 0, -1); +test( 0, -1, 0, 0, -1, -1); +test( 0, 0, -1, -1, -1, 0); +test( 0, 0, -1, -1, 0, -1); +test( 0, 0, -1, 0, -1, -1); +test( 0, 0, 0, -1, -1, -1); + +// Check combinations mixing 4 elements from different types. +test(-1, -1, 0, 0, 0, 0); +test(-1, 0, -1, 0, 0, 0); +test(-1, 0, 0, -1, 0, 0); +test(-1, 0, 0, 0, -1, 0); +test(-1, 0, 0, 0, 0, -1); +test( 0, -1, -1, 0, 0, 0); +test( 0, -1, 0, -1, 0, 0); +test( 0, -1, 0, 0, -1, 0); +test( 0, -1, 0, 0, 0, -1); +test( 0, 0, -1, -1, 0, 0); +test( 0, 0, -1, 0, -1, 0); +test( 0, 0, -1, 0, 0, -1); +test( 0, 0, 0, -1, -1, 0); +test( 0, 0, 0, -1, 0, -1); +test( 0, 0, 0, 0, -1, -1); + +// Check combinations mixing 5 elements from different types. +test(-1, 0, 0, 0, 0, 0); +test( 0, -1, 0, 0, 0, 0); +test( 0, 0, -1, 0, 0, 0); +test( 0, 0, 0, -1, 0, 0); +test( 0, 0, 0, 0, -1, 0); +test( 0, 0, 0, 0, 0, -1); + +// Check combinations mixing 6 elements from different types. +test( 0, 0, 0, 0, 0, 0); |