bug 1486173 - Part 3: Implement BigInt support for equality operators. r=jandem
authorRobin Templeton <robin@igalia.com>
Fri, 24 Aug 2018 20:43:00 +0300
changeset 488661 be6163ba4a6a0b8491ccb1ba16aaabcffb448f37
parent 488660 c62f40111003f108aa6bef93af6b289688ea1d97
child 488662 5092029dac4e2fd24b985c0a438437879e333b07
push id9734
push usershindli@mozilla.com
push dateThu, 30 Aug 2018 12:18:07 +0000
treeherdermozilla-beta@71c71ab3afae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1486173
milestone63.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 1486173 - Part 3: Implement BigInt support for equality operators. r=jandem
js/src/vm/Interpreter.cpp
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -862,16 +862,22 @@ EqualGivenSameType(JSContext* cx, Handle
     MOZ_ASSERT(SameType(lval, rval));
 
     if (lval.isString())
         return EqualStrings(cx, lval.toString(), rval.toString(), equal);
     if (lval.isDouble()) {
         *equal = (lval.toDouble() == rval.toDouble());
         return true;
     }
+#ifdef ENABLE_BIGINT
+    if (lval.isBigInt()) {
+        *equal = BigInt::equal(lval.toBigInt(), rval.toBigInt());
+        return true;
+    }
+#endif
     if (lval.isGCThing()) {  // objects or symbols
         *equal = (lval.toGCThing() == rval.toGCThing());
         return true;
     }
     *equal = lval.get().payloadAsRawUint32() == rval.get().payloadAsRawUint32();
     MOZ_ASSERT_IF(lval.isUndefined() || lval.isNull(), *equal);
     return true;
 }
@@ -965,16 +971,34 @@ js::LooselyEqual(JSContext* cx, HandleVa
     // Step 11.
     if (lval.isObject() && (rval.isString() || rval.isNumber() || rval.isSymbol())) {
         RootedValue lvalue(cx, lval);
         if (!ToPrimitive(cx, &lvalue))
             return false;
         return LooselyEqual(cx, lvalue, rval, result);
     }
 
+#ifdef ENABLE_BIGINT
+    if (lval.isBigInt()) {
+        RootedBigInt lbi(cx, lval.toBigInt());
+        bool tmpResult;
+        JS_TRY_VAR_OR_RETURN_FALSE(cx, tmpResult, BigInt::looselyEqual(cx, lbi, rval));
+        *result = tmpResult;
+        return true;
+    }
+
+    if (rval.isBigInt()) {
+        RootedBigInt rbi(cx, rval.toBigInt());
+        bool tmpResult;
+        JS_TRY_VAR_OR_RETURN_FALSE(cx, tmpResult, BigInt::looselyEqual(cx, rbi, lval));
+        *result = tmpResult;
+        return true;
+    }
+#endif
+
     // Step 12.
     *result = false;
     return true;
 }
 
 bool
 js::StrictlyEqual(JSContext* cx, HandleValue lval, HandleValue rval, bool* equal)
 {