Bug 1453011 - Remove PostCreatePrototype. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 22 Mar 2018 11:31:05 +0100
changeset 418364 54f9cde9b0c43f2ea45657e3bb291be808842678
parent 418363 b4b82cd86014c1ccdbf3cfc1479be70f4815ed66
child 418365 d72ffedf30cd98552e8d55506c4c37fd00bb7edf
push id33999
push userdluca@mozilla.com
push dateTue, 15 May 2018 21:54:51 +0000
treeherdermozilla-central@380cf87c1ee3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1453011
milestone62.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 1453011 - Remove PostCreatePrototype. r=bz.
js/xpconnect/idl/nsIXPCScriptable.idl
js/xpconnect/public/xpc_map_end.h
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeProto.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/idl/nsIXPCScriptable.idl
+++ b/js/xpconnect/idl/nsIXPCScriptable.idl
@@ -95,18 +95,16 @@ interface nsIXPCScriptable : nsISupports
     boolean construct(in nsIXPConnectWrappedNative wrapper,
                      in JSContextPtr cx, in JSObjectPtr obj,
                      in JSCallArgsRef args);
 
     boolean hasInstance(in nsIXPConnectWrappedNative wrapper,
                        in JSContextPtr cx, in JSObjectPtr obj,
                        in jsval val, out boolean bp);
 
-    void postCreatePrototype(in JSContextPtr cx, in JSObjectPtr proto);
-
 %{ C++
     #define GET_IT(f_, c_) \
     bool f_() { \
         return 0 != (GetScriptableFlags() & XPC_SCRIPTABLE_##c_); \
     }
 
     GET_IT(WantPreCreate,                WANT_PRECREATE)
     GET_IT(WantEnumerate,                WANT_ENUMERATE)
--- a/js/xpconnect/public/xpc_map_end.h
+++ b/js/xpconnect/public/xpc_map_end.h
@@ -94,16 +94,13 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::Constru
     {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
 #endif
 
 #if !((XPC_MAP_FLAGS) & XPC_SCRIPTABLE_WANT_HASINSTANCE)
 NS_IMETHODIMP XPC_MAP_CLASSNAME::HasInstance(nsIXPConnectWrappedNative* wrapper, JSContext * cx, JSObject * obj, JS::HandleValue val, bool* bp, bool* _retval)
     {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
 #endif
 
-NS_IMETHODIMP XPC_MAP_CLASSNAME::PostCreatePrototype(JSContext* cx, JSObject* proto)
-    {return NS_OK;}
-
 /**************************************************************/
 
 #undef XPC_MAP_CLASSNAME
 #undef XPC_MAP_QUOTED_CLASSNAME
 #undef XPC_MAP_FLAGS
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -193,18 +193,17 @@ XPCWrappedNative::WrapNewGlobal(xpcObjec
     // If requested, initialize the standard classes on the global.
     if (initStandardClasses && ! JS_InitStandardClasses(cx, global))
         return NS_ERROR_FAILURE;
 
     // Make a proto.
     XPCWrappedNativeProto* proto =
         XPCWrappedNativeProto::GetNewOrUsed(scope,
                                             nativeHelper.GetClassInfo(),
-                                            scrProto,
-                                            /* callPostCreatePrototype = */ false);
+                                            scrProto);
     if (!proto)
         return NS_ERROR_FAILURE;
 
     // Set up the prototype on the global.
     MOZ_ASSERT(proto->GetJSProtoObject());
     RootedObject protoObj(cx, proto->GetJSProtoObject());
     bool success = JS_SplicePrototype(cx, global, protoObj);
     if (!success)
--- a/js/xpconnect/src/XPCWrappedNativeProto.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeProto.cpp
@@ -45,59 +45,34 @@ XPCWrappedNativeProto::~XPCWrappedNative
 #endif
 
     // Note that our weak ref to mScope is not to be trusted at this point.
 
     XPCNativeSet::ClearCacheEntryForClassInfo(mClassInfo);
 }
 
 bool
-XPCWrappedNativeProto::Init(nsIXPCScriptable* scriptable,
-                            bool callPostCreatePrototype)
+XPCWrappedNativeProto::Init(nsIXPCScriptable* scriptable)
 {
     AutoJSContext cx;
     mScriptable = scriptable;
 
     JS::RootedObject global(cx, mScope->GetGlobalJSObject());
     JS::RootedObject proto(cx, JS_GetObjectPrototype(cx, global));
     mJSProtoObject = JS_NewObjectWithUniqueType(cx, js::Jsvalify(&XPC_WN_Proto_JSClass),
                                                 proto);
 
     bool success = !!mJSProtoObject;
     if (success) {
         JS_SetPrivate(mJSProtoObject, this);
-        if (callPostCreatePrototype)
-            success = CallPostCreatePrototype();
     }
 
     return success;
 }
 
-bool
-XPCWrappedNativeProto::CallPostCreatePrototype()
-{
-    AutoJSContext cx;
-
-    // Nothing to do if we don't have a scriptable callback.
-    if (!mScriptable)
-        return true;
-
-    // Call the helper. This can handle being called if it's not implemented,
-    // so we don't have to check any sort of "want" here. See xpc_map_end.h.
-    nsresult rv = mScriptable->PostCreatePrototype(cx, mJSProtoObject);
-    if (NS_FAILED(rv)) {
-        JS_SetPrivate(mJSProtoObject, nullptr);
-        mJSProtoObject = nullptr;
-        XPCThrower::Throw(rv, cx);
-        return false;
-    }
-
-    return true;
-}
-
 void
 XPCWrappedNativeProto::JSProtoObjectFinalized(js::FreeOp* fop, JSObject* obj)
 {
     MOZ_ASSERT(obj == mJSProtoObject, "huh?");
 
 #ifdef DEBUG
     // Check that this object has already been swept from the map.
     ClassInfo2WrappedNativeProtoMap* map = GetScope()->GetWrappedNativeProtoMap();
@@ -128,18 +103,17 @@ XPCWrappedNativeProto::SystemIsBeingShut
         mJSProtoObject = nullptr;
     }
 }
 
 // static
 XPCWrappedNativeProto*
 XPCWrappedNativeProto::GetNewOrUsed(XPCWrappedNativeScope* scope,
                                     nsIClassInfo* classInfo,
-                                    nsIXPCScriptable* scriptable,
-                                    bool callPostCreatePrototype)
+                                    nsIXPCScriptable* scriptable)
 {
     AutoJSContext cx;
     MOZ_ASSERT(scope, "bad param");
     MOZ_ASSERT(classInfo, "bad param");
 
     AutoMarkingWrappedNativeProtoPtr proto(cx);
     ClassInfo2WrappedNativeProtoMap* map = nullptr;
 
@@ -149,17 +123,17 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCW
         return proto;
 
     RefPtr<XPCNativeSet> set = XPCNativeSet::GetNewOrUsed(classInfo);
     if (!set)
         return nullptr;
 
     proto = new XPCWrappedNativeProto(scope, classInfo, set.forget());
 
-    if (!proto || !proto->Init(scriptable, callPostCreatePrototype)) {
+    if (!proto || !proto->Init(scriptable)) {
         delete proto.get();
         return nullptr;
     }
 
     map->Add(classInfo, proto);
 
     return proto;
 }
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1262,18 +1262,17 @@ class XPCNativeSet final
 // for XPCWrappedNative whose native objects expose nsIClassInfo.
 
 class XPCWrappedNativeProto final
 {
 public:
     static XPCWrappedNativeProto*
     GetNewOrUsed(XPCWrappedNativeScope* scope,
                  nsIClassInfo* classInfo,
-                 nsIXPCScriptable* scriptable,
-                 bool callPostCreatePrototype = true);
+                 nsIXPCScriptable* scriptable);
 
     XPCWrappedNativeScope*
     GetScope()   const {return mScope;}
 
     XPCJSRuntime*
     GetRuntime() const {return mScope->GetRuntime();}
 
     JSObject*
@@ -1286,17 +1285,16 @@ public:
     GetClassInfo()     const {return mClassInfo;}
 
     XPCNativeSet*
     GetSet()           const {return mSet;}
 
     nsIXPCScriptable*
     GetScriptable() const { return mScriptable; }
 
-    bool CallPostCreatePrototype();
     void JSProtoObjectFinalized(js::FreeOp* fop, JSObject* obj);
     void JSProtoObjectMoved(JSObject* obj, const JSObject* old);
 
     void SystemIsBeingShutDown();
 
     void DebugDump(int16_t depth);
 
     void TraceSelf(JSTracer* trc) {
@@ -1330,17 +1328,17 @@ protected:
     XPCWrappedNativeProto(const XPCWrappedNativeProto& r) = delete;
     XPCWrappedNativeProto& operator= (const XPCWrappedNativeProto& r) = delete;
 
     // hide ctor
     XPCWrappedNativeProto(XPCWrappedNativeScope* Scope,
                           nsIClassInfo* ClassInfo,
                           already_AddRefed<XPCNativeSet>&& Set);
 
-    bool Init(nsIXPCScriptable* scriptable, bool callPostCreatePrototype);
+    bool Init(nsIXPCScriptable* scriptable);
 
 private:
 #ifdef DEBUG
     static int32_t gDEBUG_LiveProtoCount;
 #endif
 
 private:
     XPCWrappedNativeScope*   mScope;