Bug 751454 - Use automarker for XPCNativeScriptableInfo (r=bholley,a=lsblakk)
authorBill McCloskey <wmccloskey@mozilla.com>
Mon, 21 May 2012 10:56:17 -0700
changeset 95808 f4121274b38555528c17e88edd9cddaf4327378e
parent 95807 c064693c724c18e2f0fe206f08efb13493cb3751
child 95809 6ba8f41fc10d41001a6cb6d829dca3ab9ac832cc
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, lsblakk
bugs751454
milestone14.0a2
Bug 751454 - Use automarker for XPCNativeScriptableInfo (r=bholley,a=lsblakk)
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -358,18 +358,19 @@ XPCWrappedNative::WrapNewGlobal(XPCCallC
     XPCNativeScriptableCreateInfo sciProto;
     XPCNativeScriptableCreateInfo sciMaybe;
     const XPCNativeScriptableCreateInfo& sciWrapper =
         GatherScriptableCreateInfo(identity, nativeHelper.GetClassInfo(),
                                    sciProto, sciMaybe);
 
     // ...and then ScriptableInfo. We need all this stuff now because it's going
     // to tell us the JSClass of the object we're going to create.
-    XPCNativeScriptableInfo *si = XPCNativeScriptableInfo::Construct(ccx, &sciWrapper);
-    MOZ_ASSERT(si);
+    AutoMarkingNativeScriptableInfoPtr
+        si(ccx, XPCNativeScriptableInfo::Construct(ccx, &sciWrapper));
+    MOZ_ASSERT(si.get());
 
     // Finally, we get to the JSClass.
     JSClass *clasp = si->GetJSClass();
     MOZ_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL);
 
     // Create the global.
     JSObject *global;
     JSCompartment *compartment;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2140,17 +2140,23 @@ public:
     void
     SetCallback(nsIXPCScriptable* s) {mCallback = s;}
     void
     SetCallback(already_AddRefed<nsIXPCScriptable> s) {mCallback = s;}
 
     void
     SetScriptableShared(XPCNativeScriptableShared* shared) {mShared = shared;}
 
-    void Mark() {if (mShared) mShared->Mark();}
+    void Mark() {
+        if (mShared)
+            mShared->Mark();
+    }
+
+    void TraceJS(JSTracer *trc) {}
+    void AutoTrace(JSTracer *trc) {}
 
 protected:
     XPCNativeScriptableInfo(nsIXPCScriptable* scriptable = nsnull,
                             XPCNativeScriptableShared* shared = nsnull)
         : mCallback(scriptable), mShared(shared)
                                {MOZ_COUNT_CTOR(XPCNativeScriptableInfo);}
 public:
     ~XPCNativeScriptableInfo() {MOZ_COUNT_DTOR(XPCNativeScriptableInfo);}
@@ -4157,16 +4163,17 @@ protected:                              
 // Use the macro above to define our AutoMarking types...
 
 DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingNativeInterfacePtr, XPCNativeInterface)
 DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingNativeSetPtr, XPCNativeSet)
 DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingWrappedNativePtr, XPCWrappedNative)
 DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingWrappedNativeTearOffPtr, XPCWrappedNativeTearOff)
 DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingWrappedNativeProtoPtr, XPCWrappedNativeProto)
 DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingJSVal, XPCMarkableJSVal)
+DEFINE_AUTO_MARKING_PTR_TYPE(AutoMarkingNativeScriptableInfoPtr, XPCNativeScriptableInfo)
 
 #define DEFINE_AUTO_MARKING_ARRAY_PTR_TYPE(class_, type_)                     \
 class class_ : public AutoMarkingPtr                                          \
 {                                                                             \
 public:                                                                       \
     class_ (XPCCallContext& ccx)                                              \
         : AutoMarkingPtr(ccx), mPtr(nsnull), mCount(0) {}                     \
     class_ (XPCCallContext& ccx, type_** aPtr, PRUint32 aCount,               \