Bug 1536703 - Part 4: Add test cases for storing BigInt values to TypedArray/Objects. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 15 Oct 2019 07:49:17 +0000
changeset 498352 f1e9ada5d498dffe705707895124ba5b325cb0da
parent 498351 e512b7dafc1ff11109b7478b773df33e83872984
child 498353 27c5749f319a58c1a12a1ab71ea7be1f2bf37488
push id98403
push usercsabou@mozilla.com
push dateMon, 21 Oct 2019 11:43:21 +0000
treeherderautoland@f1e9ada5d498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1536703
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1536703 - Part 4: Add test cases for storing BigInt values to TypedArray/Objects. r=jandem Differential Revision: https://phabricator.services.mozilla.com/D48336
js/src/jit-test/tests/cacheir/store-typed-element-bigint-typedobject.js
js/src/jit-test/tests/cacheir/store-typed-element-bigint.js
js/src/jit-test/tests/cacheir/store-typed-object-property-bigint.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/store-typed-element-bigint-typedobject.js
@@ -0,0 +1,105 @@
+// |jit-test| skip-if: !this.hasOwnProperty("TypedObject")
+
+// Different typed object types to ensure we emit a SetProp IC.
+var xs = [
+  new (TypedObject.bigint64.array(10)),
+  new (TypedObject.biguint64.array(10)),
+];
+
+// Store with 0n as rhs.
+function storeConstantZero() {
+  var value = 0n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeConstantZero();
+
+// Store non-negative BigInt using inline digits.
+function storeInlineDigits() {
+  var value = 1n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigits();
+
+// Store negative BigInt using inline digits.
+function storeInlineDigitsNegative() {
+  var value = -1n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigitsNegative();
+
+// Still inline digits, but now two digits on 32-bit platforms
+function storeInlineDigitsTwoDigits() {
+  var value = 4294967296n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigitsTwoDigits();
+
+// Negative case of |storeInlineDigitsTwoDigits|.
+function storeInlineDigitsTwoDigitsNegative() {
+  var value = -4294967296n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigitsTwoDigitsNegative();
+
+// Store BigInt using heap digits.
+function storeHeapDigits() {
+  var value = 2n ** 1000n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeHeapDigits();
+
+// Store negative BigInt using heap digits.
+function storeHeapDigitsNegative() {
+  var value = -(2n ** 1000n);
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeHeapDigitsNegative();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/store-typed-element-bigint.js
@@ -0,0 +1,103 @@
+// Different typed array types to ensure we emit a SetProp IC.
+var xs = [
+  new BigInt64Array(10),
+  new BigUint64Array(10),
+];
+
+// Store with 0n as rhs.
+function storeConstantZero() {
+  var value = 0n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeConstantZero();
+
+// Store non-negative BigInt using inline digits.
+function storeInlineDigits() {
+  var value = 1n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigits();
+
+// Store negative BigInt using inline digits.
+function storeInlineDigitsNegative() {
+  var value = -1n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigitsNegative();
+
+// Still inline digits, but now two digits on 32-bit platforms
+function storeInlineDigitsTwoDigits() {
+  var value = 4294967296n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigitsTwoDigits();
+
+// Negative case of |storeInlineDigitsTwoDigits|.
+function storeInlineDigitsTwoDigitsNegative() {
+  var value = -4294967296n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeInlineDigitsTwoDigitsNegative();
+
+// Store BigInt using heap digits.
+function storeHeapDigits() {
+  var value = 2n ** 1000n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeHeapDigits();
+
+// Store negative BigInt using heap digits.
+function storeHeapDigitsNegative() {
+  var value = -(2n ** 1000n);
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta[0] = value;
+  }
+
+  assertEq(xs[0][0], BigInt.asIntN(64, value));
+  assertEq(xs[1][0], BigInt.asUintN(64, value));
+}
+storeHeapDigitsNegative();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/store-typed-object-property-bigint.js
@@ -0,0 +1,105 @@
+// |jit-test| skip-if: !this.hasOwnProperty("TypedObject")
+
+// Different typed object types to ensure we emit a SetProp IC.
+var xs = [
+  new new TypedObject.StructType({foo: TypedObject.bigint64}),
+  new new TypedObject.StructType({foo: TypedObject.biguint64}),
+];
+
+// Store with 0n as rhs.
+function storeConstantZero() {
+  var value = 0n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeConstantZero();
+
+// Store non-negative BigInt using inline digits.
+function storeInlineDigits() {
+  var value = 1n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeInlineDigits();
+
+// Store negative BigInt using inline digits.
+function storeInlineDigitsNegative() {
+  var value = -1n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeInlineDigitsNegative();
+
+// Still inline digits, but now two digits on 32-bit platforms
+function storeInlineDigitsTwoDigits() {
+  var value = 4294967296n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeInlineDigitsTwoDigits();
+
+// Negative case of |storeInlineDigitsTwoDigits|.
+function storeInlineDigitsTwoDigitsNegative() {
+  var value = -4294967296n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeInlineDigitsTwoDigitsNegative();
+
+// Store BigInt using heap digits.
+function storeHeapDigits() {
+  var value = 2n ** 1000n;
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeHeapDigits();
+
+// Store negative BigInt using heap digits.
+function storeHeapDigitsNegative() {
+  var value = -(2n ** 1000n);
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    ta.foo = value;
+  }
+
+  assertEq(xs[0].foo, BigInt.asIntN(64, value));
+  assertEq(xs[1].foo, BigInt.asUintN(64, value));
+}
+storeHeapDigitsNegative();