propertycache-gc-assert
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 153 cd96178a2e472dc6cd10443a56a3cedf9e8e1140
permissions -rw-r--r--
State as of now

Bug 429978 - Assertion failure: JS_PROPERTY_CACHE(cx).disabled >= 0 ... seems to work, but don't know if it's correct!

diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -911,6 +911,8 @@ JSGC::enterExclusiveGC()
 {
     JSContext *cx;
 #ifdef JS_THREADSAFE
+    JSContext *acx, *iter;
+
     JSThread *thread = js_GetCurrentThread(rt);
 
     JS_ASSERT_IF(thread->gcPendingContext,
@@ -941,26 +943,13 @@ JSGC::enterExclusiveGC()
      */
     if (rt->gcKind & GC_KEEP_ATOMS)
         JS_KEEP_ATOMS(rt);
-}
 
-void
-JSGC::enterExclusiveGCNoLock()
-{
-    JSContext *cx = rt->gcContext;
-#ifdef JS_THREADSAFE
-    JSContext *acx, *iter;
-#endif
 
-    /* Reset malloc counter. */
-    rt->gcMallocBytes = 0;
-
-#ifdef JS_DUMP_SCOPE_METERS
-  { extern void js_DumpScopeMeters(JSRuntime *rt);
-    js_DumpScopeMeters(rt);
-  }
-#endif
-
-    /* Clean property cache weak references */
+    /*
+     * Clear property cache weak references and disable the cache so nothing
+     * can fill it during GC (this is paranoia, since scripts should not run
+     * during GC).
+     */
     js_FlushPropertyCache(cx);
 
 #ifdef JS_THREADSAFE
@@ -976,12 +965,26 @@ JSGC::enterExclusiveGCNoLock()
         if (!acx->thread || acx->thread == cx->thread)
             continue;
         GSN_CACHE_CLEAR(&acx->thread->gsnCache);
-        js_DisablePropertyCache(acx);
         js_FlushPropertyCache(acx);
     }
 #else
     /* The thread-unsafe case just has to clear the runtime's GSN cache. */
     GSN_CACHE_CLEAR(&rt->gsnCache);
+#endif
+}
+
+void
+JSGC::enterExclusiveGCNoLock()
+{
+    JSContext *cx = rt->gcContext;
+
+    /* Reset malloc counter. */
+    rt->gcMallocBytes = 0;
+
+#ifdef JS_DUMP_SCOPE_METERS
+  { extern void js_DumpScopeMeters(JSRuntime *rt);
+    js_DumpScopeMeters(rt);
+  }
 #endif
 
     rt->gcNumber++;
@@ -998,29 +1001,6 @@ void
 void
 JSGC::leaveExclusiveGC()
 {
-    JSContext *cx = rt->gcContext;
-#ifdef JS_THREADSAFE
-    JSContext *iter;
-    JSContext *acx;
-#endif
-
-    if (rt->shapeGen & SHAPE_OVERFLOW_BIT) {
-        /*
-         * FIXME bug 440834: The shape id space has overflowed. Currently we
-         * cope badly with this. Every call to js_GenerateShape does GC, and
-         * we never re-enable the property cache.
-         */
-        js_DisablePropertyCache(cx);
-#ifdef JS_THREADSAFE
-        iter = NULL;
-        while ((acx = js_ContextIterator(rt, JS_FALSE, &iter)) != NULL) {
-            if (!acx->thread || acx->thread == cx->thread)
-                continue;
-            js_DisablePropertyCache(acx);
-        }
-#endif
-    }
-
     if (rt->gcKind & GC_KEEP_ATOMS)
         JS_UNKEEP_ATOMS(rt);
     rt->gcKind = GC_NOT_RUNNING;