xpconnect-scope-finalizer-assertions
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 81 c44369c08f6589473ff14827f7c0001428eae19e
permissions -rw-r--r--
State as of now

diff --git a/js/src/xpconnect/src/xpcmaps.cpp b/js/src/xpconnect/src/xpcmaps.cpp
--- a/js/src/xpconnect/src/xpcmaps.cpp
+++ b/js/src/xpconnect/src/xpcmaps.cpp
@@ -843,4 +843,18 @@ WrappedNative2WrapperMap::DyingUnmapper(
     return JS_DHASH_REMOVE;
 }
 
-/***************************************************************************/
+// The following debug-only function allows you to enumerate the entries
+// of a hashtable from within a debugger
+#ifdef DEBUG
+JSDHashOperator
+PrintLiveEntries(JSDHashTable *table,
+                 JSDHashEntryHdr *hdr,
+                 uint32 number,
+                 void *arg)
+{
+    fprintf(stderr, "Live hashtable entry #%i: %p\n", number, hdr);
+    return JS_DHASH_NEXT;
+}
+#endif
+
+/***************************************************************************/
diff --git a/js/src/xpconnect/src/xpcwrappednativescope.cpp b/js/src/xpconnect/src/xpcwrappednativescope.cpp
--- a/js/src/xpconnect/src/xpcwrappednativescope.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativescope.cpp
@@ -296,14 +296,13 @@ XPCWrappedNativeScope::FinishedMarkPhase
         cur;
         prev = cur, cur = cur->mNext)
     {
-        if(NS_GetGC()->GetMark(cur))
-        {
-            // If the scope is marked, regulate its maps
-            cur->UnmapDyingNatives();
-        }
-        else
-        {
-            // If the scope is not marked, remove it from our linked list
+        // This is technically not necessary for dying scopes... but
+        // it allows us to assert that the scopes are empty, which is
+        // useful. We should ifdef this out for release builds, I think
+        cur->UnmapDyingNatives();
+
+        if(!NS_GetGC()->GetMark(cur))
+        {
             if(prev)
                 prev->mNext = cur->mNext;
             else