Bug 1527897 - Optimize js::getProperty on bigint values to not create wrapper object r=jandem
authorAndy Wingo <wingo@igalia.com>
Wed, 27 Feb 2019 12:03:04 +0000
changeset 519322 9527be2c6bcf17765a6b526c114b91ea338e20c7
parent 519321 e2bb36fb5eadbe96efb263ca1624343c043f7e71
child 519323 91686a9fe2bc21861ce2c4d72ab0cd9954a37e39
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)
reviewersjandem
bugs1527897
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 1527897 - Optimize js::getProperty on bigint values to not create wrapper object r=jandem Differential Revision: https://phabricator.services.mozilla.com/D21221
js/src/vm/GlobalObject.h
js/src/vm/Interpreter.cpp
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -363,16 +363,24 @@ class GlobalObject : public NativeObject
   static NativeObject* getOrCreateSymbolPrototype(
       JSContext* cx, Handle<GlobalObject*> global) {
     if (!ensureConstructor(cx, global, JSProto_Symbol)) {
       return nullptr;
     }
     return &global->getPrototype(JSProto_Symbol).toObject().as<NativeObject>();
   }
 
+  static NativeObject* getOrCreateBigIntPrototype(
+      JSContext* cx, Handle<GlobalObject*> global) {
+    if (!ensureConstructor(cx, global, JSProto_BigInt)) {
+      return nullptr;
+    }
+    return &global->getPrototype(JSProto_BigInt).toObject().as<NativeObject>();
+  }
+
   static NativeObject* getOrCreatePromisePrototype(
       JSContext* cx, Handle<GlobalObject*> global) {
     if (!ensureConstructor(cx, global, JSProto_Promise)) {
       return nullptr;
     }
     return &global->getPrototype(JSProto_Promise).toObject().as<NativeObject>();
   }
 
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -4403,24 +4403,26 @@ bool js::GetProperty(JSContext* cx, Hand
     // Fast path for strings, arrays and arguments.
     if (GetLengthProperty(v, vp)) {
       return true;
     }
   }
 
   // Optimize common cases like (2).toString() or "foo".valueOf() to not
   // create a wrapper object.
-  if (v.isPrimitive() && !v.isNullOrUndefined() && !v.isBigInt()) {
+  if (v.isPrimitive() && !v.isNullOrUndefined()) {
     NativeObject* proto;
     if (v.isNumber()) {
       proto = GlobalObject::getOrCreateNumberPrototype(cx, cx->global());
     } else if (v.isString()) {
       proto = GlobalObject::getOrCreateStringPrototype(cx, cx->global());
     } else if (v.isBoolean()) {
       proto = GlobalObject::getOrCreateBooleanPrototype(cx, cx->global());
+    } else if (v.isBigInt()) {
+      proto = GlobalObject::getOrCreateBigIntPrototype(cx, cx->global());
     } else {
       MOZ_ASSERT(v.isSymbol());
       proto = GlobalObject::getOrCreateSymbolPrototype(cx, cx->global());
     }
     if (!proto) {
       return false;
     }