Bug 1536702 - Part 4: Add test cases for loading BigInt values from TypedArray/Objects. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 21 Oct 2019 11:27:10 +0000
changeset 498357 f473602d0d244b9b50b08cd909c3a0fe3f8ec148
parent 498356 1398fdc0f7e9ec2b693412eb636b74bed0ffdc9e
child 498358 f1453e41758bef4f4e9318c89adb8d7d1e6cd93b
push id36717
push usernbeleuzu@mozilla.com
push dateMon, 21 Oct 2019 21:51:55 +0000
treeherdermozilla-central@563f437f24b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1536702
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 1536702 - Part 4: Add test cases for loading BigInt values from TypedArray/Objects. r=jandem Differential Revision: https://phabricator.services.mozilla.com/D48341
js/src/jit-test/tests/cacheir/load-typed-element-bigint-typedobject.js
js/src/jit-test/tests/cacheir/load-typed-element-bigint.js
js/src/jit-test/tests/cacheir/load-typed-object-property-bigint.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/load-typed-element-bigint-typedobject.js
@@ -0,0 +1,102 @@
+// |jit-test| skip-if: !this.hasOwnProperty("TypedObject")
+
+// Different typed object types to ensure we emit a GetProp IC.
+var xs = [
+  new (TypedObject.bigint64.array(10)),
+  new (TypedObject.biguint64.array(10)),
+];
+
+// Load 0n value.
+function loadConstantZero() {
+  var value = 0n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadConstantZero();
+
+// Load non-negative BigInt using inline digits.
+function loadInlineDigits() {
+  var value = 1n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigits();
+
+// Load negative BigInt using inline digits.
+function loadInlineDigitsNegative() {
+  var value = -1n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigitsNegative();
+
+// Still inline digits, but now two digits on 32-bit platforms
+function loadInlineDigitsTwoDigits() {
+  var value = 4294967296n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigitsTwoDigits();
+
+// Negative case of |storeInlineDigitsTwoDigits|.
+function loadInlineDigitsTwoDigitsNegative() {
+  var value = -4294967296n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigitsTwoDigitsNegative();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/load-typed-element-bigint.js
@@ -0,0 +1,100 @@
+// Different typed array types to ensure we emit a GetProp IC.
+var xs = [
+  new BigInt64Array(10),
+  new BigUint64Array(10),
+];
+
+// Load 0n value.
+function loadConstantZero() {
+  var value = 0n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadConstantZero();
+
+// Load non-negative BigInt using inline digits.
+function loadInlineDigits() {
+  var value = 1n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigits();
+
+// Load negative BigInt using inline digits.
+function loadInlineDigitsNegative() {
+  var value = -1n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigitsNegative();
+
+// Still inline digits, but now two digits on 32-bit platforms
+function loadInlineDigitsTwoDigits() {
+  var value = 4294967296n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigitsTwoDigits();
+
+// Negative case of |storeInlineDigitsTwoDigits|.
+function loadInlineDigitsTwoDigitsNegative() {
+  var value = -4294967296n;
+
+  xs[0][0] = value;
+  xs[1][0] = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta[0], ys[i & 1]);
+  }
+}
+loadInlineDigitsTwoDigitsNegative();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/load-typed-object-property-bigint.js
@@ -0,0 +1,102 @@
+// |jit-test| skip-if: !this.hasOwnProperty("TypedObject")
+
+// Different typed object types to ensure we emit a GetProp IC.
+var xs = [
+  new new TypedObject.StructType({foo: TypedObject.bigint64}),
+  new new TypedObject.StructType({foo: TypedObject.biguint64}),
+];
+
+// Load 0n value.
+function loadConstantZero() {
+  var value = 0n;
+
+  xs[0].foo = value;
+  xs[1].foo = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta.foo, ys[i & 1]);
+  }
+}
+loadConstantZero();
+
+// Load non-negative BigInt using inline digits.
+function loadInlineDigits() {
+  var value = 1n;
+
+  xs[0].foo = value;
+  xs[1].foo = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta.foo, ys[i & 1]);
+  }
+}
+loadInlineDigits();
+
+// Load negative BigInt using inline digits.
+function loadInlineDigitsNegative() {
+  var value = -1n;
+
+  xs[0].foo = value;
+  xs[1].foo = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta.foo, ys[i & 1]);
+  }
+}
+loadInlineDigitsNegative();
+
+// Still inline digits, but now two digits on 32-bit platforms
+function loadInlineDigitsTwoDigits() {
+  var value = 4294967296n;
+
+  xs[0].foo = value;
+  xs[1].foo = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta.foo, ys[i & 1]);
+  }
+}
+loadInlineDigitsTwoDigits();
+
+// Negative case of |storeInlineDigitsTwoDigits|.
+function loadInlineDigitsTwoDigitsNegative() {
+  var value = -4294967296n;
+
+  xs[0].foo = value;
+  xs[1].foo = value;
+
+  var ys = [
+    BigInt.asIntN(64, value),
+    BigInt.asUintN(64, value),
+  ];
+
+  for (var i = 0; i < 100; ++i) {
+    var ta = xs[i & 1];
+    assertEq(ta.foo, ys[i & 1]);
+  }
+}
+loadInlineDigitsTwoDigitsNegative();