set-default-jscontext
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 65 5674a3e586f318223a76af5d678101ee58d80805
permissions -rw-r--r--
State as of now

diff --git a/xpcom/base/nsTraceRefcntImpl.cpp b/xpcom/base/nsTraceRefcntImpl.cpp
--- a/xpcom/base/nsTraceRefcntImpl.cpp
+++ b/xpcom/base/nsTraceRefcntImpl.cpp
@@ -146,7 +146,8 @@ NS_LogInit()
     // the GC's allocator.
     JS_SetGCParameter(gJSRuntime, JSGC_MAX_BYTES, 0xffffffff);
 
-    NS_BeginRequest();
+    JSContext *cx = ns_BeginRequest();
+    JS_SetGCDefaultContext(cx);
   }
 }
 
diff --git a/xpcom/threads/nsXPCOMRequests.cpp b/xpcom/threads/nsXPCOMRequests.cpp
--- a/xpcom/threads/nsXPCOMRequests.cpp
+++ b/xpcom/threads/nsXPCOMRequests.cpp
@@ -20,6 +20,12 @@ NS_COM void
 NS_COM void
 NS_BeginRequest()
 {
+  (void) ns_BeginRequest();
+}
+
+NS_HIDDEN_(JSContext*)
+ns_BeginRequest()
+{
   NS_ASSERTION(gJSRuntime, "XPCOM logging not initialized.");
 
   if (gXPCOMRequestThreadIndex == kINVALID_TPI) {
@@ -35,6 +41,7 @@ NS_BeginRequest()
   PR_SetThreadPrivate(gXPCOMRequestThreadIndex, cx);
 
   JS_BeginRequest(cx);
+  return cx;
 }
 
 NS_COM void
diff --git a/xpcom/threads/nsXPCOMRequests.h b/xpcom/threads/nsXPCOMRequests.h
--- a/xpcom/threads/nsXPCOMRequests.h
+++ b/xpcom/threads/nsXPCOMRequests.h
@@ -16,6 +16,10 @@ NS_BeginRequest();
 
 NS_COM void
 NS_EndRequest();
+
+// private versions of NS_BeginRequest that gives access to the JSContext*
+NS_HIDDEN_(JSContext*)
+ns_BeginRequest();
 
 // Temporarily yield a request so GC may proceed if necessary,
 // but immediately re-enter the request