Bug 1449985 - Remove js::IsDelegate, rename IsDelegateOfObject to IsPrototypeOf. r=jandem
authorAshley Hauck <khyperia@mozilla.com>
Fri, 24 Aug 2018 07:55:00 +0300
changeset 488640 ba637657bbf8a6b52fa42a565ec8555997ccd936
parent 488639 e4521c7a8ade622bf979a2eb7f76992f02a3c0c9
child 488641 4e65beb5c22617498520374366b9391ac416565a
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
bugs1449985
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 1449985 - Remove js::IsDelegate, rename IsDelegateOfObject to IsPrototypeOf. r=jandem
js/src/builtin/Object.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/IonBuilder.cpp
js/src/vm/JSFunction.cpp
js/src/vm/JSObject.cpp
js/src/vm/JSObject.h
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -936,20 +936,20 @@ obj_isPrototypeOf(JSContext* cx, unsigne
     }
 
     /* Step 2. */
     RootedObject obj(cx, ToObject(cx, args.thisv()));
     if (!obj)
         return false;
 
     /* Step 3. */
-    bool isDelegate;
-    if (!IsDelegate(cx, obj, args[0], &isDelegate))
+    bool isPrototype;
+    if (!IsPrototypeOf(cx, obj, &args[0].toObject(), &isPrototype))
         return false;
-    args.rval().setBoolean(isDelegate);
+    args.rval().setBoolean(isPrototype);
     return true;
 }
 
 PlainObject*
 js::ObjectCreateImpl(JSContext* cx, HandleObject proto, NewObjectKind newKind,
                      HandleObjectGroup group)
 {
     // Give the new object a small number of fixed slots, like we do for empty
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -12030,26 +12030,19 @@ CodeGenerator::visitInstanceOfO(LInstanc
 }
 
 void
 CodeGenerator::visitInstanceOfV(LInstanceOfV* ins)
 {
     emitInstanceOf(ins, ins->mir()->prototypeObject());
 }
 
-// Wrap IsDelegateOfObject, which takes a JSObject*, not a HandleObject
-static bool
-IsDelegateObject(JSContext* cx, HandleObject protoObj, HandleObject obj, bool* res)
-{
-    return IsDelegateOfObject(cx, protoObj, obj, res);
-}
-
-typedef bool (*IsDelegateObjectFn)(JSContext*, HandleObject, HandleObject, bool*);
-static const VMFunction IsDelegateObjectInfo =
-    FunctionInfo<IsDelegateObjectFn>(IsDelegateObject, "IsDelegateObject");
+typedef bool (*IsPrototypeOfFn)(JSContext*, HandleObject, JSObject*, bool*);
+static const VMFunction IsPrototypeOfInfo =
+    FunctionInfo<IsPrototypeOfFn>(IsPrototypeOf, "IsPrototypeOf");
 
 void
 CodeGenerator::emitInstanceOf(LInstruction* ins, JSObject* prototypeObject)
 {
     // This path implements fun_hasInstance when the function's prototype is
     // known to be prototypeObject.
 
     Label done;
@@ -12065,17 +12058,17 @@ CodeGenerator::emitInstanceOf(LInstructi
         masm.jump(&done);
         masm.bind(&isObject);
         objReg = masm.extractObject(lhsValue, output);
     } else {
         objReg = ToRegister(ins->toInstanceOfO()->lhs());
     }
 
     // Crawl the lhs's prototype chain in a loop to search for prototypeObject.
-    // This follows the main loop of js::IsDelegate, though additionally breaks
+    // This follows the main loop of js::IsPrototypeOf, though additionally breaks
     // out of the loop on Proxy::LazyProto.
 
     // Load the lhs's prototype.
     masm.loadObjProto(objReg, output);
 
     Label testLazy;
     {
         Label loopPrototypeChain;
@@ -12100,17 +12093,17 @@ CodeGenerator::emitInstanceOf(LInstructi
     }
 
     // Make a VM call if an object with a lazy proto was found on the prototype
     // chain. This currently occurs only for cross compartment wrappers, which
     // we do not expect to be compared with non-wrapper functions from this
     // compartment. Otherwise, we stopped on a nullptr prototype and the output
     // register is already correct.
 
-    OutOfLineCode* ool = oolCallVM(IsDelegateObjectInfo, ins,
+    OutOfLineCode* ool = oolCallVM(IsPrototypeOfInfo, ins,
                                    ArgList(ImmGCPtr(prototypeObject), objReg),
                                    StoreRegisterTo(output));
 
     // Regenerate the original lhs object for the VM call.
     Label regenerate, *lazyEntry;
     if (objReg != output) {
         lazyEntry = ool->entry();
     } else {
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -12973,17 +12973,17 @@ IonBuilder::hasOnProtoChain(TypeSet::Obj
     }
 
     MOZ_CRASH("Unreachable");
 }
 
 AbortReasonOr<Ok>
 IonBuilder::tryFoldInstanceOf(bool* emitted, MDefinition* lhs, JSObject* protoObject)
 {
-    // Try to fold the js::IsDelegate part of the instanceof operation.
+    // Try to fold the js::IsPrototypeOf part of the instanceof operation.
     MOZ_ASSERT(*emitted == false);
 
     if (!lhs->mightBeType(MIRType::Object)) {
         // If the lhs is a primitive, the result is false.
         lhs->setImplicitlyUsedUnchecked();
         pushConstant(BooleanValue(false));
         *emitted = true;
         return Ok();
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -767,20 +767,20 @@ JS::OrdinaryHasInstance(JSContext* cx, H
          */
         RootedValue val(cx, ObjectValue(*obj));
         ReportValueError(cx, JSMSG_BAD_PROTOTYPE, -1, val, nullptr);
         return false;
     }
 
     /* Step 6. */
     RootedObject pobj(cx, &pval.toObject());
-    bool isDelegate;
-    if (!IsDelegate(cx, pobj, v, &isDelegate))
+    bool isPrototype;
+    if (!IsPrototypeOf(cx, pobj, &v.toObject(), &isPrototype))
         return false;
-    *bp = isDelegate;
+    *bp = isPrototype;
     return true;
 }
 
 inline void
 JSFunction::trace(JSTracer* trc)
 {
     if (isExtended()) {
         TraceRange(trc, ArrayLength(toExtended()->extendedSlots),
--- a/js/src/vm/JSObject.cpp
+++ b/js/src/vm/JSObject.cpp
@@ -3168,27 +3168,17 @@ js::ToPropertyKeySlow(JSContext* cx, Han
 
     // Steps 3-4.
     return ValueToId<CanGC>(cx, key, result);
 }
 
 /* * */
 
 bool
-js::IsDelegate(JSContext* cx, HandleObject obj, const js::Value& v, bool* result)
-{
-    if (v.isPrimitive()) {
-        *result = false;
-        return true;
-    }
-    return IsDelegateOfObject(cx, obj, &v.toObject(), result);
-}
-
-bool
-js::IsDelegateOfObject(JSContext* cx, HandleObject protoObj, JSObject* obj, bool* result)
+js::IsPrototypeOf(JSContext* cx, HandleObject protoObj, JSObject* obj, bool* result)
 {
     RootedObject obj2(cx, obj);
     for (;;) {
         if (!GetPrototype(cx, obj2, &obj2))
             return false;
         if (!obj2) {
             *result = false;
             return true;
--- a/js/src/vm/JSObject.h
+++ b/js/src/vm/JSObject.h
@@ -1176,23 +1176,20 @@ GetOwnPropertyDescriptor(JSContext* cx, 
  * Use JS::FromPropertyDescriptor for getOwnPropertyDescriptor, since desc.object()
  * is used to indicate whether a result was found or not.  Use this instead for
  * defineProperty: it would be senseless to define a "missing" property.
  */
 extern bool
 FromPropertyDescriptorToObject(JSContext* cx, Handle<JS::PropertyDescriptor> desc,
                                MutableHandleValue vp);
 
-extern bool
-IsDelegate(JSContext* cx, HandleObject obj, const Value& v, bool* result);
-
 // obj is a JSObject*, but we root it immediately up front. We do it
 // that way because we need a Rooted temporary in this method anyway.
 extern bool
-IsDelegateOfObject(JSContext* cx, HandleObject protoObj, JSObject* obj, bool* result);
+IsPrototypeOf(JSContext* cx, HandleObject protoObj, JSObject* obj, bool* result);
 
 /* Wrap boolean, number or string as Boolean, Number or String object. */
 extern JSObject*
 PrimitiveToObject(JSContext* cx, const Value& v);
 
 } /* namespace js */
 
 namespace js {