Bug 534676. Fix object hashtable lifetime management. r=timeless
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 14 Dec 2009 21:31:59 -0800
changeset 36192 f4e5b9438d17e0995de12ceed374bb218b9cbfc4
parent 36191 925595f3c08634cc42e33158ea6858bb55623ef7
child 36193 d029f744960d8fc26efe4b9584e10922d63a4306
push id10705
push userbzbarsky@mozilla.com
push dateTue, 15 Dec 2009 05:32:38 +0000
treeherdermozilla-central@f4e5b9438d17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimeless
bugs534676
milestone1.9.3a1pre
Bug 534676. Fix object hashtable lifetime management. r=timeless
js/jsd/jsd.h
js/jsd/jsd_obj.c
js/jsd/jsdebug.c
--- a/js/jsd/jsd.h
+++ b/js/jsd/jsd.h
@@ -1037,16 +1037,19 @@ jsd_TopLevelCallHook(JSContext *cx, JSSt
 
 extern JSBool
 jsd_InitObjectManager(JSDContext* jsdc);
 
 extern void
 jsd_DestroyObjectManager(JSDContext* jsdc);
 
 extern void
+jsd_DestroyObjects(JSDContext* jsdc);
+
+extern void
 jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure);
 
 extern void
 jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
                  JSStackFrame *fp);
 
 extern JSDObject*
 jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
--- a/js/jsd/jsd_obj.c
+++ b/js/jsd/jsd_obj.c
@@ -234,20 +234,28 @@ jsd_InitObjectManager(JSDContext* jsdc)
                                          JS_CompareValues, JS_CompareValues,
                                          NULL, NULL);
     return (JSBool) jsdc->objectsTable;
 }
 
 void
 jsd_DestroyObjectManager(JSDContext* jsdc)
 {
+    jsd_DestroyObjects(jsdc);
+    JSD_LOCK_OBJECTS(jsdc);
+    JS_HashTableDestroy(jsdc->objectsTable);
+    JSD_UNLOCK_OBJECTS(jsdc);
+}
+
+void
+jsd_DestroyObjects(JSDContext* jsdc)
+{
     JSD_LOCK_OBJECTS(jsdc);
     while( !JS_CLIST_IS_EMPTY(&jsdc->objectsList) )
         _destroyJSDObject(jsdc, (JSDObject*)JS_NEXT_LINK(&jsdc->objectsList));
-    JS_HashTableDestroy(jsdc->objectsTable);
     JSD_UNLOCK_OBJECTS(jsdc);
 }
 
 JSDObject*
 jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp)
 {
     JSDObject *jsdobj = *iterp;
 
--- a/js/jsd/jsdebug.c
+++ b/js/jsd/jsdebug.c
@@ -135,28 +135,27 @@ JSD_ClearAllProfileData(JSDContext *jsdc
 JSD_PUBLIC_API(void)
 JSD_SetContextFlags(JSDContext *jsdc, uint32 flags)
 {
     uint32 oldFlags = jsdc->flags;
     JSD_ASSERT_VALID_CONTEXT(jsdc);
     jsdc->flags = flags;
     if ((flags & JSD_COLLECT_PROFILE_DATA) ||
         !(flags & JSD_DISABLE_OBJECT_TRACE)) {
-        // Need to reenable our call hooks now
+        /* Need to reenable our call hooks now */
         JS_SetExecuteHook(jsdc->jsrt, jsd_TopLevelCallHook, jsdc);
         JS_SetCallHook(jsdc->jsrt, jsd_FunctionCallHook, jsdc);
     }
     if ((oldFlags ^ flags) & JSD_DISABLE_OBJECT_TRACE) {
-        // Changing our JSD_DISABLE_OBJECT_TRACE flag
+        /* Changing our JSD_DISABLE_OBJECT_TRACE flag */
         if (!(flags & JSD_DISABLE_OBJECT_TRACE)) {
-            // Need to reenable our object hooks now
-            if (jsd_InitObjectManager(jsdc))
-                JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
+            /* Need to reenable our object hooks now */
+            JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
         } else {
-            jsd_DestroyObjectManager(jsdc);
+            jsd_DestroyObjects(jsdc);
             JS_SetObjectHook(jsdc->jsrt, NULL, NULL);
         }
     }
 }
 
 JSD_PUBLIC_API(uint32)
 JSD_GetContextFlags(JSDContext *jsdc)
 {