Bug 1330018, part 1 - Add a common function to check if dead CPOWs are being debugged. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Thu, 12 Jan 2017 15:42:08 -0800
changeset 460326 37a2d8a9d9c65932fd21b24934841f9c5cf377ed
parent 457660 2977ca1224525680cbfb5c3ce3018818b6dfd8f2
child 460327 1325512d023c68d5d6b70500181a7aa902d5d4a6
push id41372
push userbmo:continuation@gmail.com
push dateFri, 13 Jan 2017 00:06:08 +0000
reviewersmrbkap
bugs1330018
milestone53.0a1
Bug 1330018, part 1 - Add a common function to check if dead CPOWs are being debugged. r=mrbkap MozReview-Commit-ID: H4veAIm3Gl6
js/ipc/CrossProcessObjectWrappers.h
js/ipc/JavaScriptShared.cpp
js/ipc/WrapperAnswer.cpp
--- a/js/ipc/CrossProcessObjectWrappers.h
+++ b/js/ipc/CrossProcessObjectWrappers.h
@@ -87,12 +87,15 @@ PJavaScriptChild*
 NewJavaScriptChild();
 
 void
 ReleaseJavaScriptChild(PJavaScriptChild* child);
 
 void
 AfterProcessTask();
 
+bool
+DeadCPOWDebuggingEnabled();
+
 } // namespace jsipc
 } // namespace mozilla
 
 #endif // mozilla_jsipc_CrossProcessObjectWrappers_h__
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -740,8 +740,20 @@ mozilla::jsipc::CPOWManagerFor(PJavaScri
     return static_cast<JavaScriptParent*>(aParent);
 }
 
 CPOWManager*
 mozilla::jsipc::CPOWManagerFor(PJavaScriptChild* aChild)
 {
     return static_cast<JavaScriptChild*>(aChild);
 }
+
+bool
+mozilla::jsipc::DeadCPOWDebuggingEnabled()
+{
+    static bool sEnvVarInitialized = false;
+    static bool sDebugDeadCPOWs = false;
+
+    if (!sEnvVarInitialized)
+        sDebugDeadCPOWs = !!PR_GetEnv("MOZ_DEBUG_DEAD_CPOWS");
+
+    return sDebugDeadCPOWs;
+}
--- a/js/ipc/WrapperAnswer.cpp
+++ b/js/ipc/WrapperAnswer.cpp
@@ -25,23 +25,17 @@ using namespace mozilla::jsipc;
 // plan is to have the JS engine throw if it encounters script when it isn't
 // expecting it.
 using mozilla::dom::AutoJSAPI;
 using mozilla::dom::AutoEntryScript;
 
 static void
 MaybeForceDebugGC()
 {
-    static bool sEnvVarInitialized = false;
-    static bool sDebugGCs = false;
-
-    if (!sEnvVarInitialized)
-        sDebugGCs = !!PR_GetEnv("MOZ_DEBUG_DEAD_CPOWS");
-
-    if (sDebugGCs) {
+    if (DeadCPOWDebuggingEnabled()) {
         JSContext* cx = nsXPConnect::GetContextInstance()->Context();
         PrepareForFullGC(cx);
         GCForReason(cx, GC_NORMAL, gcreason::COMPONENT_UTILS);
     }
 }
 
 bool
 WrapperAnswer::fail(AutoJSAPI& jsapi, ReturnStatus* rs)