Bug 934526 - Remove unnecessary attempt to instantiate intrinsic values in IonBuilder, r=jandem.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 05 Nov 2013 10:15:51 -0800
changeset 153659 b53c83843c18a1cd47d055658510755c7ed0f628
parent 153658 89b38ee677d21930c4057796fb36e8cca0ebef33
child 153660 f5929e69bc7bc1f0351e65edef88ef8ca89b7566
push id25600
push userkwierso@gmail.com
push dateWed, 06 Nov 2013 01:50:50 +0000
treeherdermozilla-central@ce0d975320e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs934526
milestone28.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 934526 - Remove unnecessary attempt to instantiate intrinsic values in IonBuilder, r=jandem.
js/src/jit/IonBuilder.cpp
js/src/vm/GlobalObject.h
js/src/vm/ObjectImpl.h
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -6366,21 +6366,18 @@ IonBuilder::jsop_intrinsic(PropertyName 
 
         if (!resumeAfter(ins))
             return false;
 
         return pushTypeBarrier(ins, types, true);
     }
 
     // Bake in the intrinsic. Make sure that TI agrees with us on the type.
-    RootedPropertyName nameRoot(cx, name);
-    RootedValue vp(cx, UndefinedValue());
-    if (!cx->global()->getIntrinsicValue(cx, nameRoot, &vp))
-        return false;
-
+    Value vp;
+    JS_ALWAYS_TRUE(script()->global().maybeGetIntrinsicValue(name, &vp));
     JS_ASSERT(types->hasType(types::GetValueType(vp)));
 
     MConstant *ins = MConstant::New(vp);
     current->add(ins);
     current->push(ins);
 
     return true;
 }
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -506,23 +506,32 @@ class GlobalObject : public JSObject
         return &self->getPrototype(JSProto_DataView).toObject();
     }
 
     JSObject *intrinsicsHolder() {
         JS_ASSERT(!getSlotRef(INTRINSICS).isUndefined());
         return &getSlotRef(INTRINSICS).toObject();
     }
 
+    bool maybeGetIntrinsicValue(PropertyName *name, Value *vp) {
+        JSObject *holder = intrinsicsHolder();
+        if (Shape *shape = holder->nativeLookupPure(name)) {
+            *vp = holder->getSlot(shape->slot());
+            return true;
+        }
+        return false;
+    }
+
     bool getIntrinsicValue(JSContext *cx, HandlePropertyName name, MutableHandleValue value) {
-        RootedObject holder(cx, intrinsicsHolder());
-        RootedId id(cx, NameToId(name));
-        if (HasDataProperty(cx, holder, id, value.address()))
+        if (maybeGetIntrinsicValue(name, value.address()))
             return true;
         if (!cx->runtime()->cloneSelfHostedValue(cx, name, value))
             return false;
+        RootedObject holder(cx, intrinsicsHolder());
+        RootedId id(cx, NameToId(name));
         return JS_DefinePropertyById(cx, holder, id, value, nullptr, nullptr, 0);
     }
 
     bool setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value) {
 #ifdef DEBUG
         RootedObject self(cx, this);
         JS_ASSERT(cx->runtime()->isSelfHostingGlobal(self));
 #endif
--- a/js/src/vm/ObjectImpl.h
+++ b/js/src/vm/ObjectImpl.h
@@ -1237,20 +1237,17 @@ class ObjectImpl : public gc::BarrieredC
     }
     bool nativeContains(ExclusiveContext *cx, PropertyName* name) {
         return nativeLookup(cx, name) != nullptr;
     }
     bool nativeContains(ExclusiveContext *cx, Shape* shape) {
         return nativeLookup(cx, shape->propid()) == shape;
     }
 
-    /*
-     * Contextless; can be called from parallel code. Returns false if the
-     * operation would have been effectful.
-     */
+    /* Contextless; can be called from parallel code. */
     Shape *nativeLookupPure(jsid id);
     Shape *nativeLookupPure(PropertyId pid) {
         return nativeLookupPure(pid.asId());
     }
     Shape *nativeLookupPure(PropertyName *name) {
         return nativeLookupPure(NameToId(name));
     }