Bug 1530406 - Make HashableValue comparison of BigInts infallible r=wingo,jwalden
authorRobin Templeton <robin@igalia.com>
Wed, 27 Feb 2019 15:50:04 +0000
changeset 519361 d209ceb7588c9060ac427ffc76abacce9cdffb02
parent 519360 f769684a0f39c3ddbba7ca56f3682b435be251eb
child 519362 85c4d0c94938bca534fce92b1ed55a658fdb98dd
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswingo, jwalden
bugs1530406
milestone67.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 1530406 - Make HashableValue comparison of BigInts infallible r=wingo,jwalden Differential Revision: https://phabricator.services.mozilla.com/D21032
js/src/builtin/MapObject.cpp
--- a/js/src/builtin/MapObject.cpp
+++ b/js/src/builtin/MapObject.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/MapObject.h"
 
 #include "ds/OrderedHashTable.h"
 #include "gc/FreeOp.h"
 #include "js/PropertySpec.h"
 #include "js/Utility.h"
+#include "vm/BigIntType.h"
 #include "vm/EqualityOperations.h"  // js::SameValue
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSContext.h"
 #include "vm/JSObject.h"
 #include "vm/SelfHosting.h"
 #include "vm/SymbolType.h"
@@ -95,23 +96,19 @@ HashNumber HashableValue::hash(const moz
   return HashValue(value, hcs);
 }
 
 bool HashableValue::operator==(const HashableValue& other) const {
   // Two HashableValues are equal if they have equal bits.
   bool b = (value.asRawBits() == other.value.asRawBits());
 
   // BigInt values are considered equal if they represent the same
-  // integer. This test should use a comparison function that doesn't
-  // require a JSContext once one is defined in the BigInt class.
+  // mathematical value.
   if (!b && (value.isBigInt() && other.value.isBigInt())) {
-    JSContext* cx = TlsContext.get();
-    RootedValue valueRoot(cx, value);
-    RootedValue otherRoot(cx, other.value);
-    SameValue(cx, valueRoot, otherRoot, &b);
+    b = BigInt::equal(value.toBigInt(), other.value.toBigInt());
   }
 
 #ifdef DEBUG
   bool same;
   JSContext* cx = TlsContext.get();
   RootedValue valueRoot(cx, value);
   RootedValue otherRoot(cx, other.value);
   MOZ_ASSERT(SameValue(cx, valueRoot, otherRoot, &same));