diff --git a/implementation-contributed/javascriptcore/stress/dataview-get-cse.js b/implementation-contributed/javascriptcore/stress/dataview-get-cse.js new file mode 100644 index 0000000000..e3d47a938e --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/dataview-get-cse.js @@ -0,0 +1,137 @@ +"use strict"; + +function assert(b) { + if (!b) + throw new Error; +} + + +function test1() { + function foo(dv) { + return [dv.getFloat32(0), dv.getFloat64(0)]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + dv.setFloat64(0, 128431.42342189432, false); + for (let i = 0; i < 10000; ++i) { + let result = foo(dv); + assert(result[0] !== result[1]); + } +} +test1(); + +function test2() { + function foo(dv) { + return [dv.getFloat32(0), dv.getFloat32(0)]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + dv.setFloat64(0, 128431.42342189432, false); + for (let i = 0; i < 10000; ++i) { + let result = foo(dv); + assert(result[0] === result[1]); + } +} +test2(); + +function test3() { + function foo(dv, ta) { + let a = dv.getFloat64(0, true); + ta[0] = Math.PI; + let b = dv.getFloat64(0, true); + return [a, b]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + let ta = new Float64Array(ab); + for (let i = 0; i < 40000; ++i) { + dv.setFloat64(0, 0.0, true); + let result = foo(dv, ta); + assert(result[0] === 0.0); + assert(result[1] === Math.PI); + } +} +test3(); + +function test4() { + function foo(dv) { + let a = dv.getInt32(0, true); + let b = dv.getInt32(0, false); + return [a, b]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + dv.setInt32(0, 0x11223344, true); + for (let i = 0; i < 40000; ++i) { + let result = foo(dv); + assert(result[0] === 0x11223344); + assert(result[1] === 0x44332211) + } +} +test4(); + +function test5() { + function foo(dv, littleEndian) { + let a = dv.getInt32(0, littleEndian); + let b = dv.getInt32(0, !littleEndian); + return [a, b]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + dv.setInt32(0, 0x11223344, true); + for (let i = 0; i < 40000; ++i) { + let result = foo(dv, true); + assert(result[0] === 0x11223344); + assert(result[1] === 0x44332211) + } +} +test5(); + +function test6() { + function foo(dv, littleEndian) { + let a = dv.getInt32(0, littleEndian); + let b = dv.getInt32(0, littleEndian); + return [a, b]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + dv.setInt32(0, 0x11223344, true); + for (let i = 0; i < 40000; ++i) { + let result = foo(dv, true); + assert(result[0] === 0x11223344); + assert(result[1] === 0x11223344) + } +} +test6(); + +function test7() { + function foo(dv) { + let a = dv.getInt32(0, true); + let b = dv.getInt32(4, true); + return [a, b]; + } + noInline(foo); + + let ab = new ArrayBuffer(8); + let dv = new DataView(ab); + dv.setInt32(0, 0x11223344, true); + dv.setInt32(4, 0x12121212, true); + for (let i = 0; i < 40000; ++i) { + let result = foo(dv, true); + assert(result[0] === 0x11223344); + assert(result[1] === 0x12121212); + } +} +test7(); diff --git a/implementation-contributed/javascriptcore/stress/function-body-to-string-before-parameter-syntax-check.js b/implementation-contributed/javascriptcore/stress/function-body-to-string-before-parameter-syntax-check.js new file mode 100644 index 0000000000..7203b3cc2f --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/function-body-to-string-before-parameter-syntax-check.js @@ -0,0 +1,60 @@ +function shouldBe(actual, expected) { + if (actual !== expected) + throw new Error('bad value: ' + actual); +} + +function shouldThrow(func, errorMessage) { + var errorThrown = false; + var error = null; + try { + func(); + } catch (e) { + errorThrown = true; + error = e; + } + if (!errorThrown) + throw new Error('not thrown'); + if (String(error) !== errorMessage) + throw new Error(`bad error: ${String(error)}`); +} + +shouldThrow(() => { + Function("@", { toString() { throw 42; } }) +}, `42`); + +var counter = 0; +class Parameter { + constructor(index) + { + this.index = index; + } + + toString() { + shouldBe(this.index, counter); + counter++; + return `x${this.index}`; + } +}; + +class Body { + constructor(index) + { + this.index = index; + } + + toString() { + shouldBe(this.index, counter); + counter++; + return `42`; + } +}; + +var parameters = []; +for (var i = 0; i < 50; ++i) { + parameters.push(new Parameter(parameters.length)); + var args = parameters.slice(); + args.push(new Body(args.length)); + counter = 0; + Function.apply(this, args); + shouldBe(counter, args.length); +} diff --git a/implementation-contributed/javascriptcore/stress/function-to-string.js b/implementation-contributed/javascriptcore/stress/function-to-string.js new file mode 100644 index 0000000000..2f96a11957 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/function-to-string.js @@ -0,0 +1,11 @@ +function shouldBe(actual, expected) { + if (actual !== expected) + throw new Error('bad value: ' + actual); +} + +shouldBe((function test() { }).toString(), `function test() { }`); +shouldBe((() => { }).toString(), `() => { }`); +shouldBe((function* test() { }).toString(), `function* test() { }`); +shouldBe((async function* test() { }).toString(), `async function* test() { }`); +shouldBe((async function test() { }).toString(), `async function test() { }`); +shouldBe((async () => { }).toString(), `async () => { }`); diff --git a/implementation-contributed/javascriptcore/stress/may-exit-should-be-false-regexp-constant-folding.js b/implementation-contributed/javascriptcore/stress/may-exit-should-be-false-regexp-constant-folding.js new file mode 100644 index 0000000000..0378a0c7d8 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/may-exit-should-be-false-regexp-constant-folding.js @@ -0,0 +1,25 @@ +//@ runDefault("--jitPolicyScale=0", "--useConcurrentJIT=0", "--validateGraphAtEachPhase=1") + +let re0 = /a/; +let str0 = 'b'; +function foo() { + /a/.exec('b'); + for (var i = 0; i < 6; i++) { + } + for (var i = 0; i < 3; i++) { + re0.exec('a'); + } + str0.match(/a/); + for (var i = 0; i < 2; i++) { + str0.match(/a/g); + } +} +function bar() { + for (var i = 0; i < 6; i++) { + 'a'.match(/b/); + } +} + +foo(); +bar(); +foo(); diff --git a/implementation-contributed/javascriptcore/stress/regress-189132.js b/implementation-contributed/javascriptcore/stress/regress-189132.js new file mode 100644 index 0000000000..dca0287ded --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/regress-189132.js @@ -0,0 +1,12 @@ +try { + var a0 = '\ud801'; + var a1 = []; + a2 = a0.padEnd(2147483644,'x'); + a1[a2]; +} catch (e) { + exception = e; +} + +if (exception != "Error: Out of memory") + throw "FAILED"; + diff --git a/implementation-contributed/javascriptcore/stress/regress-189184.js b/implementation-contributed/javascriptcore/stress/regress-189184.js new file mode 100644 index 0000000000..0670c7568b --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/regress-189184.js @@ -0,0 +1,3 @@ +//@ runDefault +// This test passes if it does not crash. +['a'+0].lastIndexOf('a0'); diff --git a/implementation-contributed/javascriptcore/stress/regress-189185.js b/implementation-contributed/javascriptcore/stress/regress-189185.js new file mode 100644 index 0000000000..d67f9d41b2 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/regress-189185.js @@ -0,0 +1,7 @@ +//@ runDefault +// This passes if it does not crash. +new WebAssembly.CompileError({ + valueOf() { + throw new Error(); + } +}); diff --git a/implementation-contributed/javascriptcore/stress/regress-189186.js b/implementation-contributed/javascriptcore/stress/regress-189186.js new file mode 100644 index 0000000000..c62096696d --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/regress-189186.js @@ -0,0 +1,4 @@ +//@ runDefault +// This test passes if it does not crash. +let x = new DataView(new ArrayBuffer(1)); +Object.defineProperty(x, 'foo', {});