Bug 677079 - Part aa: Expose sizeof(JSContext) in jsfriendapi.h; r=njn
authorMs2ger <ms2ger@gmail.com>
Sun, 15 Jan 2012 09:13:11 +0100
changeset 85704 9f706102086fbbc7b622d1a562d28d107b6ee269
parent 85703 cf1294a14a4c97a3ed2dd1da1ceca715a0d926df
child 85705 dfc618d2f28f4266be01d2aa071c1510053612fa
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs677079
milestone12.0a1
Bug 677079 - Part aa: Expose sizeof(JSContext) in jsfriendapi.h; r=njn
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/xpconnect/src/nsXPConnect.cpp
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -602,9 +602,15 @@ GetRuntimeCompartments(JSRuntime *rt)
 }
 
 JS_FRIEND_API(uintptr_t)
 GetContextStackLimit(const JSContext *cx)
 {
     return cx->stackLimit;
 }
 
+JS_FRIEND_API(size_t)
+SizeOfJSContext()
+{
+    return sizeof(JSContext);
+}
+
 } // namespace js
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -557,16 +557,19 @@ IsContextRunningJS(JSContext *cx);
 extern JS_FRIEND_API(void)
 TriggerOperationCallbacksForActiveContexts(JSRuntime *rt);
 
 class SystemAllocPolicy;
 typedef Vector<JSCompartment*, 0, SystemAllocPolicy> CompartmentVector;
 extern JS_FRIEND_API(const CompartmentVector&)
 GetRuntimeCompartments(JSRuntime *rt);
 
+extern JS_FRIEND_API(size_t)
+SizeOfJSContext();
+
 } /* namespace js */
 
 /*
  * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
  * JSProto_Null, clasp must non-null.
  */
 extern JS_FRIEND_API(JSBool)
 js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -64,18 +64,16 @@
 #include "XPCQuickStubs.h"
 #include "dombindings.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Base64.h"
 
 #include "nsWrapperCacheInlines.h"
 
-#include "jscntxt.h" // sizeof(JSContext)
-
 NS_IMPL_THREADSAFE_ISUPPORTS7(nsXPConnect,
                               nsIXPConnect,
                               nsISupportsWeakReference,
                               nsIThreadObserver,
                               nsIJSRuntimeService,
                               nsIJSContextStack,
                               nsIThreadJSContextStack,
                               nsIJSEngineTelemetryStats)
@@ -997,17 +995,17 @@ public:
     {
         JSContext *cx = static_cast<JSContext*>(n);
 
         // Add outstandingRequests to the count, if there are outstanding
         // requests the context needs to be kept alive and adding unknown
         // edges will ensure that any cycles this context is in won't be
         // collected.
         unsigned refCount = nsXPConnect::GetXPConnect()->GetOutstandingRequests(cx) + 1;
-        NS_IMPL_CYCLE_COLLECTION_DESCRIBE(JSContext, refCount)
+        cb.DescribeRefCountedNode(refCount, js::SizeOfJSContext(), "JSContext");
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[global object]");
         if (JSObject *global = JS_GetGlobalObject(cx)) {
             cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, global);
         }
 
         return NS_OK;
     }
 };