Time to regenerate!
authorBenjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 00:16:00 -0400
changeset 164 fa6388d0a0da8b02a6de7c99bb09ca58d2dd2013
parent 163 1124940b811904ccbf0aa91533a7184843788d7b
child 165 aef82785a2308e43efecc8fa9addeb0456d09895
push id37
push userbsmedberg@mozilla.com
push dateSat, 26 Jul 2008 04:16:20 +0000
Time to regenerate!
NS_FORBIDDEN
NS_FORBIDDEN2
series
xpconnect-finalizers
xpconnect-finalizers2
xultemplates-gcobjects
xultemplates-gcobjects2
--- a/NS_FORBIDDEN
+++ b/NS_FORBIDDEN
@@ -1,16 +1,18 @@
+* * *
+
 diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h
 --- a/xpcom/base/nscore.h
 +++ b/xpcom/base/nscore.h
 @@ -473,6 +473,12 @@ typedef PRUint32 nsrefcnt;
  #define NS_UNLIKELY(x)  (!!(x))
  #endif
  
 +#if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
-+#define NS_FORBIDDEN(reason) __attribute__(error(reason))
++#define NS_FORBIDDEN(reason) __attribute__((error(reason)))
 +#else
 +#define NS_FORBIDDEN(reason)
 +#endif
 +
   /*
    * If we're being linked as standalone glue, we don't want a dynamic dependency
    * on NSPR libs, so we skip the debug thread-safety checks, and we cannot use
deleted file mode 100644
--- a/NS_FORBIDDEN2
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h
---- a/xpcom/base/nscore.h
-+++ b/xpcom/base/nscore.h
-@@ -474,7 +474,7 @@ typedef PRUint32 nsrefcnt;
- #endif
- 
- #if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
--#define NS_FORBIDDEN(reason) __attribute__(error(reason))
-+#define NS_FORBIDDEN(reason) __attribute__((error(reason)))
- #else
- #define NS_FORBIDDEN(reason)
- #endif
--- a/series
+++ b/series
@@ -199,11 +199,8 @@ views-unmanaged
 nsProtocolProxyService-FilterLink-gcobject
 TextRunExpiringCache-finalized
 nsFontCache-mContext-unmanaged
 nsJSONWriter-temp-finalizable
 NameSpaceDecl-mOwner-unmanaged
 xbl-gcobjects
 xul-gcobjects
 xultemplates-gcobjects
-NS_FORBIDDEN2
-xpconnect-finalizers2
-xultemplates-gcobjects2
--- a/xpconnect-finalizers
+++ b/xpconnect-finalizers
@@ -1,8 +1,9 @@
+* * *
 * * *
 * * *
 
 diff --git a/js/src/xpconnect/src/nsXPConnect.cpp b/js/src/xpconnect/src/nsXPConnect.cpp
 --- a/js/src/xpconnect/src/nsXPConnect.cpp
 +++ b/js/src/xpconnect/src/nsXPConnect.cpp
 @@ -51,10 +51,12 @@
  #include "jsobj.h"
@@ -603,16 +604,211 @@ diff --git a/js/src/xpconnect/src/xpcwra
 -    // Notify other wrappers in the chain.
 -    if(mNext)
 -        mNext->SystemIsBeingShutDown(rt);
 -}
 -
  /***************************************************************************/
  
  /* readonly attribute nsISimpleEnumerator enumerator; */
+diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp
+--- a/js/src/xpconnect/src/xpcwrappednative.cpp
++++ b/js/src/xpconnect/src/xpcwrappednative.cpp
+@@ -822,191 +822,6 @@ NS_INTERFACE_MAP_END_THREADSAFE
+ 
+ NS_IMPL_THREADSAFE_ADDREF(XPCWrappedNative)
+ NS_IMPL_THREADSAFE_RELEASE(XPCWrappedNative)
+-
+-/*
+- *  Wrapped Native lifetime management is messy!
+- *
+- *  - At creation we push the refcount to 2 (only one of which is owned by
+- *    the native caller that caused the wrapper creation).
+- *  - During the JS GC Mark phase we mark any wrapper with a refcount > 1.
+- *  - The *only* thing that can make the wrapper get destroyed is the
+- *    finalization of mFlatJSObject. And *that* should only happen if the only
+- *    reference is the single extra (internal) reference we hold.
+- *
+- *  - The wrapper has a pointer to the nsISupports 'view' of the wrapped native
+- *    object i.e... mIdentity. This is held until the wrapper's refcount goes
+- *    to zero and the wrapper is released.
+- *
+- *  - The wrapper also has 'tearoffs'. It has one tearoff for each interface
+- *    that is actually used on the native object. 'Used' means we have either
+- *    needed to QueryInterface to verify the availability of that interface
+- *    of that we've had to QueryInterface in order to actually make a call
+- *    into the wrapped object via the pointer for the given interface.
+- *
+- *  - Each tearoff's 'mNative' member (if non-null) indicates one reference
+- *    held by our wrapper on the wrapped native for the given interface
+- *    associated with the tearoff. If we release that reference then we set
+- *    the tearoff's 'mNative' to null.
+- *
+- *  - We use the occasion of the JavaScript GCCallback for the JSGC_MARK_END
+- *    event to scan the tearoffs of all wrappers for non-null mNative members
+- *    that represent unused references. We can tell that a given tearoff's
+- *    mNative is unused by noting that no live XPCCallContexts hold a pointer
+- *    to the tearoff.
+- *
+- *  - As a time/space tradeoff we may decide to not do this scanning on
+- *    *every* JavaScript GC. We *do* want to do this *sometimes* because
+- *    we want to allow for wrapped native's to do their own tearoff patterns.
+- *    So, we want to avoid holding references to interfaces that we don't need.
+- *    At the same time, we don't want to be bracketing every call into a
+- *    wrapped native object with a QueryInterface/Release pair. And we *never*
+- *    make a call into the object except via the correct interface for which
+- *    we've QI'd.
+- *
+- *  - Each tearoff *can* have a mJSObject whose lazily resolved properties
+- *    represent the methods/attributes/constants of that specific interface.
+- *    This is optionally reflected into JavaScript as "foo.nsIFoo" when "foo"
+- *    is the name of mFlatJSObject and "nsIFoo" is the name of the given
+- *    interface associated with the tearoff. When we create the tearoff's
+- *    mJSObject we set it's parent to be mFlatJSObject. This way we know that
+- *    when mFlatJSObject get's collected there are no outstanding reachable
+- *    tearoff mJSObjects. Note that we must clear the private of any lingering
+- *    mJSObjects at this point because we have no guarentee of the *order* of
+- *    finalization within a given gc cycle.
+- */
+-
+-void
+-XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
+-{
+-    if(!IsValid())
+-        return;
+-
+-    // Iterate the tearoffs and null out each of their JSObject's privates.
+-    // This will keep them from trying to access their pointers to the
+-    // dying tearoff object. We can safely assume that those remaining
+-    // JSObjects are about to be finalized too.
+-
+-    XPCWrappedNativeTearOffChunk* chunk;
+-    for(chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
+-    {
+-        XPCWrappedNativeTearOff* to = chunk->mTearOffs;
+-        for(int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
+-        {
+-            JSObject* jso = to->GetJSObject();
+-            if(jso)
+-            {
+-                NS_ASSERTION(JS_IsAboutToBeFinalized(cx, jso), "bad!");
+-                JS_SetPrivate(cx, jso, nsnull);
+-                to->JSObjectFinalized();
+-            }
+-
+-            // We also need to release any native pointers held...
+-            to->SetNative(nsnull);
+-            to->SetInterface(nsnull);
+-        }
+-    }
+-
+-    GetScope()->GetWrapperMap()->Remove(mFlatJSObject);
+-
+-    if(IsWrapperExpired())
+-    {
+-        GetScope()->GetWrappedNativeMap()->Remove(this);
+-
+-        XPCWrappedNativeProto* proto = GetProto();
+-
+-        if(mScriptableInfo &&
+-           (!HasProto() ||
+-            (proto && proto->GetScriptableInfo() != mScriptableInfo)))
+-        {
+-            delete mScriptableInfo;
+-            mScriptableInfo = nsnull;
+-        }
+-
+-        mMaybeScope = nsnull;
+-    }
+-
+-    // This makes IsValid return false from now on...
+-    mFlatJSObject = nsnull;
+-
+-    // Note that it's not safe to touch mNativeWrapper here since it's
+-    // likely that it has already been finalized.
+-}
+-
+-void
+-XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
+-{
+-#ifdef DEBUG_xpc_hacker
+-    {
+-        printf("Removing root for still-live XPCWrappedNative %p wrapping:\n",
+-               static_cast<void*>(this));
+-        for(PRUint16 i = 0, i_end = mSet->GetInterfaceCount(); i < i_end; ++i)
+-        {
+-            nsXPIDLCString name;
+-            mSet->GetInterfaceAt(i)->GetInterfaceInfo()
+-                ->GetName(getter_Copies(name));
+-            printf("  %s\n", name.get());
+-        }
+-    }
+-#endif
+-    DEBUG_TrackShutdownWrapper(this);
+-
+-    if(!IsValid())
+-        return;
+-
+-    // The long standing strategy is to leak some objects still held at shutdown.
+-    // The general problem is that propagating release out of xpconnect at
+-    // shutdown time causes a world of problems.
+-
+-    // We leak mIdentity (see above).
+-
+-    // short circuit future finalization
+-    JS_SetPrivate(cx, mFlatJSObject, nsnull);
+-    mFlatJSObject = nsnull; // This makes 'IsValid()' return false.
+-
+-    XPCWrappedNativeProto* proto = GetProto();
+-
+-    if(HasProto())
+-        proto->SystemIsBeingShutDown(cx);
+-
+-    if(mScriptableInfo &&
+-       (!HasProto() ||
+-        (proto && proto->GetScriptableInfo() != mScriptableInfo)))
+-    {
+-        delete mScriptableInfo;
+-    }
+-
+-    // cleanup the tearoffs...
+-
+-    XPCWrappedNativeTearOffChunk* chunk;
+-    for(chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
+-    {
+-        XPCWrappedNativeTearOff* to = chunk->mTearOffs;
+-        for(int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
+-        {
+-            if(to->GetJSObject())
+-            {
+-                JS_SetPrivate(cx, to->GetJSObject(), nsnull);
+-#ifdef XPC_IDISPATCH_SUPPORT
+-                if(to->IsIDispatch())
+-                    delete to->GetIDispatchInfo();
+-#endif
+-                to->SetJSObject(nsnull);
+-            }
+-            // We leak the tearoff mNative
+-            // (for the same reason we leak mIdentity - see above).
+-            to->SetNative(nsnull);
+-            to->SetInterface(nsnull);
+-        }
+-    }
+-
+-    if(mFirstChunk.mNextChunk)
+-    {
+-        delete mFirstChunk.mNextChunk;
+-        mFirstChunk.mNextChunk = nsnull;
+-    }
+-}
+-
+-/***************************************************************************/
+ 
+ // static
+ nsresult
 diff --git a/js/src/xpconnect/src/xpcwrappednativeinfo.cpp b/js/src/xpconnect/src/xpcwrappednativeinfo.cpp
 --- a/js/src/xpconnect/src/xpcwrappednativeinfo.cpp
 +++ b/js/src/xpconnect/src/xpcwrappednativeinfo.cpp
 @@ -705,21 +705,6 @@ out:
      return set;
  }
  
 -// static 
deleted file mode 100644
--- a/xpconnect-finalizers2
+++ /dev/null
@@ -1,195 +0,0 @@
-diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp
---- a/js/src/xpconnect/src/xpcwrappednative.cpp
-+++ b/js/src/xpconnect/src/xpcwrappednative.cpp
-@@ -822,191 +822,6 @@ NS_INTERFACE_MAP_END_THREADSAFE
- 
- NS_IMPL_THREADSAFE_ADDREF(XPCWrappedNative)
- NS_IMPL_THREADSAFE_RELEASE(XPCWrappedNative)
--
--/*
-- *  Wrapped Native lifetime management is messy!
-- *
-- *  - At creation we push the refcount to 2 (only one of which is owned by
-- *    the native caller that caused the wrapper creation).
-- *  - During the JS GC Mark phase we mark any wrapper with a refcount > 1.
-- *  - The *only* thing that can make the wrapper get destroyed is the
-- *    finalization of mFlatJSObject. And *that* should only happen if the only
-- *    reference is the single extra (internal) reference we hold.
-- *
-- *  - The wrapper has a pointer to the nsISupports 'view' of the wrapped native
-- *    object i.e... mIdentity. This is held until the wrapper's refcount goes
-- *    to zero and the wrapper is released.
-- *
-- *  - The wrapper also has 'tearoffs'. It has one tearoff for each interface
-- *    that is actually used on the native object. 'Used' means we have either
-- *    needed to QueryInterface to verify the availability of that interface
-- *    of that we've had to QueryInterface in order to actually make a call
-- *    into the wrapped object via the pointer for the given interface.
-- *
-- *  - Each tearoff's 'mNative' member (if non-null) indicates one reference
-- *    held by our wrapper on the wrapped native for the given interface
-- *    associated with the tearoff. If we release that reference then we set
-- *    the tearoff's 'mNative' to null.
-- *
-- *  - We use the occasion of the JavaScript GCCallback for the JSGC_MARK_END
-- *    event to scan the tearoffs of all wrappers for non-null mNative members
-- *    that represent unused references. We can tell that a given tearoff's
-- *    mNative is unused by noting that no live XPCCallContexts hold a pointer
-- *    to the tearoff.
-- *
-- *  - As a time/space tradeoff we may decide to not do this scanning on
-- *    *every* JavaScript GC. We *do* want to do this *sometimes* because
-- *    we want to allow for wrapped native's to do their own tearoff patterns.
-- *    So, we want to avoid holding references to interfaces that we don't need.
-- *    At the same time, we don't want to be bracketing every call into a
-- *    wrapped native object with a QueryInterface/Release pair. And we *never*
-- *    make a call into the object except via the correct interface for which
-- *    we've QI'd.
-- *
-- *  - Each tearoff *can* have a mJSObject whose lazily resolved properties
-- *    represent the methods/attributes/constants of that specific interface.
-- *    This is optionally reflected into JavaScript as "foo.nsIFoo" when "foo"
-- *    is the name of mFlatJSObject and "nsIFoo" is the name of the given
-- *    interface associated with the tearoff. When we create the tearoff's
-- *    mJSObject we set it's parent to be mFlatJSObject. This way we know that
-- *    when mFlatJSObject get's collected there are no outstanding reachable
-- *    tearoff mJSObjects. Note that we must clear the private of any lingering
-- *    mJSObjects at this point because we have no guarentee of the *order* of
-- *    finalization within a given gc cycle.
-- */
--
--void
--XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
--{
--    if(!IsValid())
--        return;
--
--    // Iterate the tearoffs and null out each of their JSObject's privates.
--    // This will keep them from trying to access their pointers to the
--    // dying tearoff object. We can safely assume that those remaining
--    // JSObjects are about to be finalized too.
--
--    XPCWrappedNativeTearOffChunk* chunk;
--    for(chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
--    {
--        XPCWrappedNativeTearOff* to = chunk->mTearOffs;
--        for(int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
--        {
--            JSObject* jso = to->GetJSObject();
--            if(jso)
--            {
--                NS_ASSERTION(JS_IsAboutToBeFinalized(cx, jso), "bad!");
--                JS_SetPrivate(cx, jso, nsnull);
--                to->JSObjectFinalized();
--            }
--
--            // We also need to release any native pointers held...
--            to->SetNative(nsnull);
--            to->SetInterface(nsnull);
--        }
--    }
--
--    GetScope()->GetWrapperMap()->Remove(mFlatJSObject);
--
--    if(IsWrapperExpired())
--    {
--        GetScope()->GetWrappedNativeMap()->Remove(this);
--
--        XPCWrappedNativeProto* proto = GetProto();
--
--        if(mScriptableInfo &&
--           (!HasProto() ||
--            (proto && proto->GetScriptableInfo() != mScriptableInfo)))
--        {
--            delete mScriptableInfo;
--            mScriptableInfo = nsnull;
--        }
--
--        mMaybeScope = nsnull;
--    }
--
--    // This makes IsValid return false from now on...
--    mFlatJSObject = nsnull;
--
--    // Note that it's not safe to touch mNativeWrapper here since it's
--    // likely that it has already been finalized.
--}
--
--void
--XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
--{
--#ifdef DEBUG_xpc_hacker
--    {
--        printf("Removing root for still-live XPCWrappedNative %p wrapping:\n",
--               static_cast<void*>(this));
--        for(PRUint16 i = 0, i_end = mSet->GetInterfaceCount(); i < i_end; ++i)
--        {
--            nsXPIDLCString name;
--            mSet->GetInterfaceAt(i)->GetInterfaceInfo()
--                ->GetName(getter_Copies(name));
--            printf("  %s\n", name.get());
--        }
--    }
--#endif
--    DEBUG_TrackShutdownWrapper(this);
--
--    if(!IsValid())
--        return;
--
--    // The long standing strategy is to leak some objects still held at shutdown.
--    // The general problem is that propagating release out of xpconnect at
--    // shutdown time causes a world of problems.
--
--    // We leak mIdentity (see above).
--
--    // short circuit future finalization
--    JS_SetPrivate(cx, mFlatJSObject, nsnull);
--    mFlatJSObject = nsnull; // This makes 'IsValid()' return false.
--
--    XPCWrappedNativeProto* proto = GetProto();
--
--    if(HasProto())
--        proto->SystemIsBeingShutDown(cx);
--
--    if(mScriptableInfo &&
--       (!HasProto() ||
--        (proto && proto->GetScriptableInfo() != mScriptableInfo)))
--    {
--        delete mScriptableInfo;
--    }
--
--    // cleanup the tearoffs...
--
--    XPCWrappedNativeTearOffChunk* chunk;
--    for(chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
--    {
--        XPCWrappedNativeTearOff* to = chunk->mTearOffs;
--        for(int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
--        {
--            if(to->GetJSObject())
--            {
--                JS_SetPrivate(cx, to->GetJSObject(), nsnull);
--#ifdef XPC_IDISPATCH_SUPPORT
--                if(to->IsIDispatch())
--                    delete to->GetIDispatchInfo();
--#endif
--                to->SetJSObject(nsnull);
--            }
--            // We leak the tearoff mNative
--            // (for the same reason we leak mIdentity - see above).
--            to->SetNative(nsnull);
--            to->SetInterface(nsnull);
--        }
--    }
--
--    if(mFirstChunk.mNextChunk)
--    {
--        delete mFirstChunk.mNextChunk;
--        mFirstChunk.mNextChunk = nsnull;
--    }
--}
--
--/***************************************************************************/
- 
- // static
- nsresult
--- a/xultemplates-gcobjects
+++ b/xultemplates-gcobjects
@@ -1,8 +1,10 @@
+* * *
+
 diff --git a/content/xul/templates/src/nsRDFConInstanceTestNode.h b/content/xul/templates/src/nsRDFConInstanceTestNode.h
 --- a/content/xul/templates/src/nsRDFConInstanceTestNode.h
 +++ b/content/xul/templates/src/nsRDFConInstanceTestNode.h
 @@ -77,12 +77,6 @@ public:
  
  
      class Element : public MemoryElement {
 -    protected:
@@ -180,33 +182,36 @@ diff --git a/content/xul/templates/src/n
 -
 -    static PRBool gPoolInited;
 -    static nsFixedSizeAllocator gPool;
 -
 -    virtual void Destroy() = 0;
      virtual const char* Type() const = 0;
      virtual PLHashNumber Hash() const = 0;
      virtual PRBool Equals(const MemoryElement& aElement) const = 0;
-@@ -132,15 +126,7 @@ protected:
-             mElement->Destroy();
+@@ -129,18 +123,9 @@ protected:
+ 
+         ~List() {
+             MOZ_COUNT_DTOR(MemoryElementSet::List);
+-            mElement->Destroy();
              NS_IF_RELEASE(mNext); }
  
 -        PRInt32 AddRef() { return ++mRefCnt; }
 -
 -        PRInt32 Release() {
 -            PRInt32 refcnt = --mRefCnt;
 -            if (refcnt == 0) delete this;
 -            return refcnt; }
 -
          MemoryElement* mElement;
 -        PRInt32        mRefCnt;
          List*          mNext;
      };
  
-@@ -277,21 +263,10 @@ protected:
+@@ -277,21 +262,10 @@ protected:
  protected:
      class List {
      public:
 -        List() { MOZ_COUNT_CTOR(nsAssignmentSet::List); }
 -
 -        ~List() {
 -            MOZ_COUNT_DTOR(nsAssignmentSet::List);
 -            NS_IF_RELEASE(mNext); }
@@ -220,26 +225,26 @@ diff --git a/content/xul/templates/src/n
 +        List(nsIAtom* atom, nsIRDFNode* node) 
 +            : mAssignment(atom, node), mNext(nsnull) { }
  
          nsAssignment mAssignment;
 -        PRInt32 mRefCnt;
          List*   mNext;
      };
  
-@@ -376,7 +351,7 @@ public:
+@@ -376,7 +350,7 @@ public:
       * @return NS_OK if all is well, NS_ERROR_OUT_OF_MEMORY if memory
       *   could not be allocated for the addition.
       */
 -    nsresult Add(const nsAssignment& aElement);
 +    nsresult Add(nsIAtom* aVariable, nsIRDFNode* aValue);
  
      /**
       * Determine if the assignment set contains the specified variable
-@@ -484,7 +459,7 @@ public:
+@@ -484,7 +458,7 @@ public:
       *   is not enough memory to perform the operation
       */
      nsresult AddAssignment(nsIAtom* aVariable, nsIRDFNode* aValue) {
 -        mAssignments.Add(nsAssignment(aVariable, aValue));
 +        mAssignments.Add(aVariable, aValue);
          return NS_OK; }
  
      /**
deleted file mode 100644
--- a/xultemplates-gcobjects2
+++ /dev/null
@@ -1,11 +0,0 @@
-diff --git a/content/xul/templates/src/nsRuleNetwork.h b/content/xul/templates/src/nsRuleNetwork.h
---- a/content/xul/templates/src/nsRuleNetwork.h
-+++ b/content/xul/templates/src/nsRuleNetwork.h
-@@ -123,7 +123,6 @@ protected:
- 
-         ~List() {
-             MOZ_COUNT_DTOR(MemoryElementSet::List);
--            mElement->Destroy();
-             NS_IF_RELEASE(mNext); }
- 
-         MemoryElement* mElement;