Loading ipc/testshell/XPCShellEnvironment.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -1061,6 +1061,7 @@ XPCShellEnvironment::~XPCShellEnvironment() JSRuntime* rt = gOldContextCallback ? JS_GetRuntime(mCx) : NULL; JS_EndRequest(mCx); JS_DestroyContext(mCx); if (gOldContextCallback) { Loading js/src/jsapi.cpp +3 −10 Original line number Diff line number Diff line Loading @@ -765,7 +765,6 @@ JSRuntime::JSRuntime() data(NULL), #ifdef JS_THREADSAFE gcLock(NULL), requestCount(0), gcHelperThread(thisFromCtor()), #endif debuggerMutations(0), Loading Loading @@ -1013,10 +1012,9 @@ StartRequest(JSContext *cx) AutoLockGC lock(rt); /* Indicate that a request is running. */ rt->requestCount++; rt->requestDepth = 1; if (rt->requestCount == 1 && rt->activityCallback) if (rt->activityCallback) rt->activityCallback(rt->activityCallbackArg, true); } } Loading @@ -1037,15 +1035,10 @@ StopRequest(JSContext *cx) rt->requestDepth = 0; /* Give the GC a chance to run if this was the last request running. */ JS_ASSERT(rt->requestCount > 0); rt->requestCount--; if (rt->requestCount == 0) { if (rt->activityCallback) rt->activityCallback(rt->activityCallbackArg, false); } } } #endif /* JS_THREADSAFE */ JS_PUBLIC_API(void) Loading js/src/jscntxt.cpp +7 −54 Original line number Diff line number Diff line Loading @@ -245,13 +245,7 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) JS_ASSERT(!cx->enumerators); #ifdef JS_THREADSAFE /* * For API compatibility we support destroying contexts with non-zero * cx->outstandingRequests but we assume that all JS_BeginRequest calls * on this cx contributes to cx->thread->data.requestDepth and there is no * JS_SuspendRequest calls that set aside the counter. */ JS_ASSERT(cx->outstandingRequests <= cx->runtime->requestDepth); JS_ASSERT(cx->outstandingRequests == 0); #endif if (mode != JSDCM_NEW_FAILED) { Loading @@ -268,11 +262,7 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) JS_LOCK_GC(rt); JS_REMOVE_LINK(&cx->link); bool last = !rt->hasContexts(); if (last || mode == JSDCM_FORCE_GC || mode == JSDCM_MAYBE_GC #ifdef JS_THREADSAFE || cx->outstandingRequests != 0 #endif ) { if (last || mode == JSDCM_FORCE_GC || mode == JSDCM_MAYBE_GC) { JS_ASSERT(!rt->gcRunning); #ifdef JS_THREADSAFE Loading @@ -281,16 +271,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) JS_UNLOCK_GC(rt); if (last) { #ifdef JS_THREADSAFE /* * If this thread is not in a request already, begin one now so * that we wait for any racing GC started on a not-last context to * finish, before we plow ahead and unpin atoms. */ if (cx->runtime->requestDepth == 0) JS_BeginRequest(cx); #endif /* * Dump remaining type inference results first. This printing * depends on atoms still existing. Loading @@ -308,27 +288,15 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) for (CompartmentsIter c(rt); !c.done(); c.next()) c->clearTraps(cx); JS_ClearAllWatchPoints(cx); } #ifdef JS_THREADSAFE /* Destroying a context implicitly calls JS_EndRequest(). */ while (cx->outstandingRequests != 0) JS_EndRequest(cx); #endif if (last) { js_GC(cx, NULL, GC_NORMAL, gcreason::LAST_CONTEXT); /* Take the runtime down, now that it has no contexts or atoms. */ JS_LOCK_GC(rt); } else { if (mode == JSDCM_FORCE_GC) } else if (mode == JSDCM_FORCE_GC) { js_GC(cx, NULL, GC_NORMAL, gcreason::DESTROY_CONTEXT); else if (mode == JSDCM_MAYBE_GC) } else if (mode == JSDCM_MAYBE_GC) { JS_MaybeGC(cx); JS_LOCK_GC(rt); } JS_LOCK_GC(rt); } #ifdef JS_THREADSAFE rt->gcHelperThread.waitBackgroundSweepEnd(); Loading @@ -352,21 +320,6 @@ js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp) return cx; } JS_FRIEND_API(JSContext *) js_NextActiveContext(JSRuntime *rt, JSContext *cx) { JSContext *iter = cx; #ifdef JS_THREADSAFE while ((cx = js_ContextIterator(rt, JS_FALSE, &iter)) != NULL) { if (cx->outstandingRequests && cx->runtime->requestDepth) break; } return cx; #else return js_ContextIterator(rt, JS_FALSE, &iter); #endif } namespace js { bool Loading js/src/jscntxt.h +0 −9 Original line number Diff line number Diff line Loading @@ -453,7 +453,6 @@ struct JSRuntime #ifdef JS_THREADSAFE /* These combine to interlock the GC and new requests. */ PRLock *gcLock; uint32_t requestCount; js::GCHelperThread gcHelperThread; #endif /* JS_THREADSAFE */ Loading Loading @@ -1364,14 +1363,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode); extern JSContext * js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp); /* * Iterate through contexts with active requests. The caller must be holding * rt->gcLock in case of a thread-safe build, or otherwise guarantee that the * context list is not alternated asynchroniously. */ extern JS_FRIEND_API(JSContext *) js_NextActiveContext(JSRuntime *, JSContext *); #ifdef va_start extern JSBool js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap); Loading js/xpconnect/shell/xpcshell.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -2012,6 +2012,7 @@ main(int argc, char **argv, char **envp) cxstack = nsnull; JS_GC(cx); } //this scopes the JSAutoCrossCompartmentCall JS_EndRequest(cx); JS_DestroyContext(cx); } // this scopes the nsCOMPtrs Loading Loading
ipc/testshell/XPCShellEnvironment.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -1061,6 +1061,7 @@ XPCShellEnvironment::~XPCShellEnvironment() JSRuntime* rt = gOldContextCallback ? JS_GetRuntime(mCx) : NULL; JS_EndRequest(mCx); JS_DestroyContext(mCx); if (gOldContextCallback) { Loading
js/src/jsapi.cpp +3 −10 Original line number Diff line number Diff line Loading @@ -765,7 +765,6 @@ JSRuntime::JSRuntime() data(NULL), #ifdef JS_THREADSAFE gcLock(NULL), requestCount(0), gcHelperThread(thisFromCtor()), #endif debuggerMutations(0), Loading Loading @@ -1013,10 +1012,9 @@ StartRequest(JSContext *cx) AutoLockGC lock(rt); /* Indicate that a request is running. */ rt->requestCount++; rt->requestDepth = 1; if (rt->requestCount == 1 && rt->activityCallback) if (rt->activityCallback) rt->activityCallback(rt->activityCallbackArg, true); } } Loading @@ -1037,15 +1035,10 @@ StopRequest(JSContext *cx) rt->requestDepth = 0; /* Give the GC a chance to run if this was the last request running. */ JS_ASSERT(rt->requestCount > 0); rt->requestCount--; if (rt->requestCount == 0) { if (rt->activityCallback) rt->activityCallback(rt->activityCallbackArg, false); } } } #endif /* JS_THREADSAFE */ JS_PUBLIC_API(void) Loading
js/src/jscntxt.cpp +7 −54 Original line number Diff line number Diff line Loading @@ -245,13 +245,7 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) JS_ASSERT(!cx->enumerators); #ifdef JS_THREADSAFE /* * For API compatibility we support destroying contexts with non-zero * cx->outstandingRequests but we assume that all JS_BeginRequest calls * on this cx contributes to cx->thread->data.requestDepth and there is no * JS_SuspendRequest calls that set aside the counter. */ JS_ASSERT(cx->outstandingRequests <= cx->runtime->requestDepth); JS_ASSERT(cx->outstandingRequests == 0); #endif if (mode != JSDCM_NEW_FAILED) { Loading @@ -268,11 +262,7 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) JS_LOCK_GC(rt); JS_REMOVE_LINK(&cx->link); bool last = !rt->hasContexts(); if (last || mode == JSDCM_FORCE_GC || mode == JSDCM_MAYBE_GC #ifdef JS_THREADSAFE || cx->outstandingRequests != 0 #endif ) { if (last || mode == JSDCM_FORCE_GC || mode == JSDCM_MAYBE_GC) { JS_ASSERT(!rt->gcRunning); #ifdef JS_THREADSAFE Loading @@ -281,16 +271,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) JS_UNLOCK_GC(rt); if (last) { #ifdef JS_THREADSAFE /* * If this thread is not in a request already, begin one now so * that we wait for any racing GC started on a not-last context to * finish, before we plow ahead and unpin atoms. */ if (cx->runtime->requestDepth == 0) JS_BeginRequest(cx); #endif /* * Dump remaining type inference results first. This printing * depends on atoms still existing. Loading @@ -308,27 +288,15 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode) for (CompartmentsIter c(rt); !c.done(); c.next()) c->clearTraps(cx); JS_ClearAllWatchPoints(cx); } #ifdef JS_THREADSAFE /* Destroying a context implicitly calls JS_EndRequest(). */ while (cx->outstandingRequests != 0) JS_EndRequest(cx); #endif if (last) { js_GC(cx, NULL, GC_NORMAL, gcreason::LAST_CONTEXT); /* Take the runtime down, now that it has no contexts or atoms. */ JS_LOCK_GC(rt); } else { if (mode == JSDCM_FORCE_GC) } else if (mode == JSDCM_FORCE_GC) { js_GC(cx, NULL, GC_NORMAL, gcreason::DESTROY_CONTEXT); else if (mode == JSDCM_MAYBE_GC) } else if (mode == JSDCM_MAYBE_GC) { JS_MaybeGC(cx); JS_LOCK_GC(rt); } JS_LOCK_GC(rt); } #ifdef JS_THREADSAFE rt->gcHelperThread.waitBackgroundSweepEnd(); Loading @@ -352,21 +320,6 @@ js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp) return cx; } JS_FRIEND_API(JSContext *) js_NextActiveContext(JSRuntime *rt, JSContext *cx) { JSContext *iter = cx; #ifdef JS_THREADSAFE while ((cx = js_ContextIterator(rt, JS_FALSE, &iter)) != NULL) { if (cx->outstandingRequests && cx->runtime->requestDepth) break; } return cx; #else return js_ContextIterator(rt, JS_FALSE, &iter); #endif } namespace js { bool Loading
js/src/jscntxt.h +0 −9 Original line number Diff line number Diff line Loading @@ -453,7 +453,6 @@ struct JSRuntime #ifdef JS_THREADSAFE /* These combine to interlock the GC and new requests. */ PRLock *gcLock; uint32_t requestCount; js::GCHelperThread gcHelperThread; #endif /* JS_THREADSAFE */ Loading Loading @@ -1364,14 +1363,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode); extern JSContext * js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp); /* * Iterate through contexts with active requests. The caller must be holding * rt->gcLock in case of a thread-safe build, or otherwise guarantee that the * context list is not alternated asynchroniously. */ extern JS_FRIEND_API(JSContext *) js_NextActiveContext(JSRuntime *, JSContext *); #ifdef va_start extern JSBool js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap); Loading
js/xpconnect/shell/xpcshell.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -2012,6 +2012,7 @@ main(int argc, char **argv, char **envp) cxstack = nsnull; JS_GC(cx); } //this scopes the JSAutoCrossCompartmentCall JS_EndRequest(cx); JS_DestroyContext(cx); } // this scopes the nsCOMPtrs Loading