diff --git a/implementation-contributed/javascriptcore/stress/big-int-subtraction-jit.js b/implementation-contributed/javascriptcore/stress/big-int-subtraction-jit.js new file mode 100644 index 0000000000..2e1f6ae8c2 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/big-int-subtraction-jit.js @@ -0,0 +1,19 @@ +//@ runBigIntEnabled + +let assert = { + sameValue: function(i, e, m) { + if (i !== e) + throw new Error(m); + } +} + +function bigIntAddition(x, y) { + return x - y - 1n; +} +noInline(bigIntAddition); + +for (let i = 0; i < 10000; i++) { + let r = bigIntAddition(3n, 10n); + assert.sameValue(r, -8n, 3n + " - " + 10n + " - 1 = " + r); +} + diff --git a/implementation-contributed/javascriptcore/stress/value-sub-big-int-prediction-propagation.js b/implementation-contributed/javascriptcore/stress/value-sub-big-int-prediction-propagation.js new file mode 100644 index 0000000000..44cbb28119 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/value-sub-big-int-prediction-propagation.js @@ -0,0 +1,18 @@ +//@ runBigIntEnabled + +function assert(v, e) { + if (v !== e) + throw new Error("Expected value: " + e + " but got: " + v) +} + +function bigIntPropagation(a, b) { + let c = a - b; + return c - 0n; +} +noInline(bigIntPropagation); + +for (let i = 0; i < 100000; i++) { + let out = bigIntPropagation(0xffffffffffffffffffffffffffffffn, 0x1n); + assert(out, 0xfffffffffffffffffffffffffffffen) +} + diff --git a/implementation-contributed/javascriptcore/stress/value-sub-big-int-untyped.js b/implementation-contributed/javascriptcore/stress/value-sub-big-int-untyped.js new file mode 100644 index 0000000000..8c3f7ff2ad --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/value-sub-big-int-untyped.js @@ -0,0 +1,26 @@ +//@ runBigIntEnabled + +function assert(v, e) { + if (v !== e) + throw new Error("Expected value: " + e + " but got: " + v) +} + +function bigIntOperations(a, b) { + let c = a - b; + return a - c; +} +noInline(bigIntOperations); + +c = 0; +let o = { valueOf: function () { + c++; + return 0b1111n; +}}; + +for (let i = 0; i < 100000; i++) { + let out = bigIntOperations(o, 0b1010n); + assert(out, 10n); +} + +assert(c, 200000); + diff --git a/implementation-contributed/javascriptcore/stress/value-sub-spec-none-case.js b/implementation-contributed/javascriptcore/stress/value-sub-spec-none-case.js new file mode 100644 index 0000000000..2472cef9b3 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/value-sub-spec-none-case.js @@ -0,0 +1,22 @@ +function assert(a, e) { + if (a !== e) + throw new Error("Bad"); +} + +function valueSub() { + let sum = 0; + do { + // We trigger the JIT compilation of valueSub + // so Date.now() will have SpecNone as result + for (let i = 0; i < 10000; i++) + sum++; + + sum += 0.5; + } while (Date.now() - sum < 0); + + assert(sum, 10000.5); +} +noInline(valueSub); + +valueSub(); +