mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 722348 - eliminate JSRuntime::requestCount. r=luke
This commit is contained in:
parent
43d7327463
commit
cbdb18c744
@ -1061,6 +1061,7 @@ XPCShellEnvironment::~XPCShellEnvironment()
|
||||
|
||||
JSRuntime* rt = gOldContextCallback ? JS_GetRuntime(mCx) : NULL;
|
||||
|
||||
JS_EndRequest(mCx);
|
||||
JS_DestroyContext(mCx);
|
||||
|
||||
if (gOldContextCallback) {
|
||||
|
@ -765,7 +765,6 @@ JSRuntime::JSRuntime()
|
||||
data(NULL),
|
||||
#ifdef JS_THREADSAFE
|
||||
gcLock(NULL),
|
||||
requestCount(0),
|
||||
gcHelperThread(thisFromCtor()),
|
||||
#endif
|
||||
debuggerMutations(0),
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -1037,13 +1035,8 @@ 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);
|
||||
}
|
||||
if (rt->activityCallback)
|
||||
rt->activityCallback(rt->activityCallbackArg, false);
|
||||
}
|
||||
}
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
@ -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) {
|
||||
@ -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
|
||||
@ -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.
|
||||
@ -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)
|
||||
js_GC(cx, NULL, GC_NORMAL, gcreason::DESTROY_CONTEXT);
|
||||
else if (mode == JSDCM_MAYBE_GC)
|
||||
JS_MaybeGC(cx);
|
||||
|
||||
JS_LOCK_GC(rt);
|
||||
} else if (mode == JSDCM_FORCE_GC) {
|
||||
js_GC(cx, NULL, GC_NORMAL, gcreason::DESTROY_CONTEXT);
|
||||
} else if (mode == JSDCM_MAYBE_GC) {
|
||||
JS_MaybeGC(cx);
|
||||
}
|
||||
JS_LOCK_GC(rt);
|
||||
}
|
||||
#ifdef JS_THREADSAFE
|
||||
rt->gcHelperThread.waitBackgroundSweepEnd();
|
||||
@ -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
|
||||
|
@ -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 */
|
||||
@ -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);
|
||||
|
@ -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…
Reference in New Issue
Block a user