From 6059c1c526d191291eab8803ef65c78241f7db27 Mon Sep 17 00:00:00 2001
From: test262-automation <test262-automation@bocoup.com>
Date: Thu, 8 Nov 2018 18:54:34 +0000
Subject: [PATCH] [javascriptcore-test262-automation] Changes from
 https://github.com/webkit/webkit.git at sha 5ec2ecf1e4 on Thu Nov 08 2018
 18:51:29 GMT+0000 (Coordinated Universal Time)

---
 .../stress/big-int-negate-jit.js              | 48 +++++++++++++++++++
 .../stress/value-add-big-int-and-string.js    | 18 +++++++
 ...alue-add-big-int-prediction-propagation.js | 18 +++++++
 .../stress/value-add-big-int-untyped.js       | 26 ++++++++++
 4 files changed, 110 insertions(+)
 create mode 100644 implementation-contributed/javascriptcore/stress/big-int-negate-jit.js
 create mode 100644 implementation-contributed/javascriptcore/stress/value-add-big-int-and-string.js
 create mode 100644 implementation-contributed/javascriptcore/stress/value-add-big-int-prediction-propagation.js
 create mode 100644 implementation-contributed/javascriptcore/stress/value-add-big-int-untyped.js

diff --git a/implementation-contributed/javascriptcore/stress/big-int-negate-jit.js b/implementation-contributed/javascriptcore/stress/big-int-negate-jit.js
new file mode 100644
index 0000000000..6baa8e7ba0
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/big-int-negate-jit.js
@@ -0,0 +1,48 @@
+//@ skip if not $jitTests
+//@ runBigIntEnabled
+
+function assert(a, b) {
+    if (a !== b)
+        throw new Error("Bad!");
+}
+
+function negateBigInt(n) {
+    return -n;
+}
+noInline(negateBigInt);
+
+for (let i = 0; i < 100000; i++) {
+    assert(negateBigInt(100n), -100n);
+    assert(negateBigInt(-0x1fffffffffffff01n), 0x1fffffffffffff01n);
+}
+
+if (numberOfDFGCompiles(negateBigInt) > 1)
+    throw "Failed negateBigInt(). We should have compiled a single negate for the BigInt type.";
+
+function negateBigIntSpecializedToInt(n) {
+    return -n;
+}
+noInline(negateBigIntSpecializedToInt);
+
+for (let i = 0; i < 100000; i++) {
+    negateBigIntSpecializedToInt(100);
+}
+
+assert(negateBigIntSpecializedToInt(100n), -100n);
+
+// Testing case mixing int and BigInt speculations
+function mixedSpeculationNegateBigInt(n, arr) {
+    return -(-(-n));
+}
+noInline(mixedSpeculationNegateBigInt);
+
+for (let i = 0; i < 100000; i++) {
+    if (i % 2)
+        assert(mixedSpeculationNegateBigInt(100), -100);
+    else
+        assert(mixedSpeculationNegateBigInt(-0x1fffffffffffff01n), 0x1fffffffffffff01n);
+}
+
+if (numberOfDFGCompiles(mixedSpeculationNegateBigInt) > 1)
+    throw "Failed mixedSpeculationNegateBigInt(). We should have compiled a single negate for the BigInt type.";
+
diff --git a/implementation-contributed/javascriptcore/stress/value-add-big-int-and-string.js b/implementation-contributed/javascriptcore/stress/value-add-big-int-and-string.js
new file mode 100644
index 0000000000..eb0a4ead0c
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/value-add-big-int-and-string.js
@@ -0,0 +1,18 @@
+//@ 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);
+
+for (let i = 0; i < 100000; i++) {
+    let out = bigIntOperations(0b1111n, "16");
+    assert(out, "151516");
+}
+
diff --git a/implementation-contributed/javascriptcore/stress/value-add-big-int-prediction-propagation.js b/implementation-contributed/javascriptcore/stress/value-add-big-int-prediction-propagation.js
new file mode 100644
index 0000000000..4463711c98
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/value-add-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, 0x1000000000000000000000000000000n)
+}
+
diff --git a/implementation-contributed/javascriptcore/stress/value-add-big-int-untyped.js b/implementation-contributed/javascriptcore/stress/value-add-big-int-untyped.js
new file mode 100644
index 0000000000..02a66d3b8c
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/value-add-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, 40n);
+}
+
+assert(c, 200000);
+
-- 
GitLab