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;
|
JSRuntime* rt = gOldContextCallback ? JS_GetRuntime(mCx) : NULL;
|
||||||
|
|
||||||
|
JS_EndRequest(mCx);
|
||||||
JS_DestroyContext(mCx);
|
JS_DestroyContext(mCx);
|
||||||
|
|
||||||
if (gOldContextCallback) {
|
if (gOldContextCallback) {
|
||||||
|
@ -765,7 +765,6 @@ JSRuntime::JSRuntime()
|
|||||||
data(NULL),
|
data(NULL),
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
gcLock(NULL),
|
gcLock(NULL),
|
||||||
requestCount(0),
|
|
||||||
gcHelperThread(thisFromCtor()),
|
gcHelperThread(thisFromCtor()),
|
||||||
#endif
|
#endif
|
||||||
debuggerMutations(0),
|
debuggerMutations(0),
|
||||||
@ -1013,10 +1012,9 @@ StartRequest(JSContext *cx)
|
|||||||
AutoLockGC lock(rt);
|
AutoLockGC lock(rt);
|
||||||
|
|
||||||
/* Indicate that a request is running. */
|
/* Indicate that a request is running. */
|
||||||
rt->requestCount++;
|
|
||||||
rt->requestDepth = 1;
|
rt->requestDepth = 1;
|
||||||
|
|
||||||
if (rt->requestCount == 1 && rt->activityCallback)
|
if (rt->activityCallback)
|
||||||
rt->activityCallback(rt->activityCallbackArg, true);
|
rt->activityCallback(rt->activityCallbackArg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1037,13 +1035,8 @@ StopRequest(JSContext *cx)
|
|||||||
|
|
||||||
rt->requestDepth = 0;
|
rt->requestDepth = 0;
|
||||||
|
|
||||||
/* Give the GC a chance to run if this was the last request running. */
|
if (rt->activityCallback)
|
||||||
JS_ASSERT(rt->requestCount > 0);
|
rt->activityCallback(rt->activityCallbackArg, false);
|
||||||
rt->requestCount--;
|
|
||||||
if (rt->requestCount == 0) {
|
|
||||||
if (rt->activityCallback)
|
|
||||||
rt->activityCallback(rt->activityCallbackArg, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* JS_THREADSAFE */
|
#endif /* JS_THREADSAFE */
|
||||||
|
@ -245,13 +245,7 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode)
|
|||||||
JS_ASSERT(!cx->enumerators);
|
JS_ASSERT(!cx->enumerators);
|
||||||
|
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
/*
|
JS_ASSERT(cx->outstandingRequests == 0);
|
||||||
* 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);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mode != JSDCM_NEW_FAILED) {
|
if (mode != JSDCM_NEW_FAILED) {
|
||||||
@ -268,11 +262,7 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode)
|
|||||||
JS_LOCK_GC(rt);
|
JS_LOCK_GC(rt);
|
||||||
JS_REMOVE_LINK(&cx->link);
|
JS_REMOVE_LINK(&cx->link);
|
||||||
bool last = !rt->hasContexts();
|
bool last = !rt->hasContexts();
|
||||||
if (last || mode == JSDCM_FORCE_GC || mode == JSDCM_MAYBE_GC
|
if (last || mode == JSDCM_FORCE_GC || mode == JSDCM_MAYBE_GC) {
|
||||||
#ifdef JS_THREADSAFE
|
|
||||||
|| cx->outstandingRequests != 0
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
JS_ASSERT(!rt->gcRunning);
|
JS_ASSERT(!rt->gcRunning);
|
||||||
|
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
@ -281,16 +271,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode)
|
|||||||
JS_UNLOCK_GC(rt);
|
JS_UNLOCK_GC(rt);
|
||||||
|
|
||||||
if (last) {
|
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
|
* Dump remaining type inference results first. This printing
|
||||||
* depends on atoms still existing.
|
* depends on atoms still existing.
|
||||||
@ -308,27 +288,15 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode)
|
|||||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||||
c->clearTraps(cx);
|
c->clearTraps(cx);
|
||||||
JS_ClearAllWatchPoints(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);
|
js_GC(cx, NULL, GC_NORMAL, gcreason::LAST_CONTEXT);
|
||||||
|
|
||||||
/* Take the runtime down, now that it has no contexts or atoms. */
|
} else if (mode == JSDCM_FORCE_GC) {
|
||||||
JS_LOCK_GC(rt);
|
js_GC(cx, NULL, GC_NORMAL, gcreason::DESTROY_CONTEXT);
|
||||||
} else {
|
} else if (mode == JSDCM_MAYBE_GC) {
|
||||||
if (mode == JSDCM_FORCE_GC)
|
JS_MaybeGC(cx);
|
||||||
js_GC(cx, NULL, GC_NORMAL, gcreason::DESTROY_CONTEXT);
|
|
||||||
else if (mode == JSDCM_MAYBE_GC)
|
|
||||||
JS_MaybeGC(cx);
|
|
||||||
|
|
||||||
JS_LOCK_GC(rt);
|
|
||||||
}
|
}
|
||||||
|
JS_LOCK_GC(rt);
|
||||||
}
|
}
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
rt->gcHelperThread.waitBackgroundSweepEnd();
|
rt->gcHelperThread.waitBackgroundSweepEnd();
|
||||||
@ -352,21 +320,6 @@ js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp)
|
|||||||
return cx;
|
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 {
|
namespace js {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -453,7 +453,6 @@ struct JSRuntime
|
|||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
/* These combine to interlock the GC and new requests. */
|
/* These combine to interlock the GC and new requests. */
|
||||||
PRLock *gcLock;
|
PRLock *gcLock;
|
||||||
uint32_t requestCount;
|
|
||||||
|
|
||||||
js::GCHelperThread gcHelperThread;
|
js::GCHelperThread gcHelperThread;
|
||||||
#endif /* JS_THREADSAFE */
|
#endif /* JS_THREADSAFE */
|
||||||
@ -1364,14 +1363,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode);
|
|||||||
extern JSContext *
|
extern JSContext *
|
||||||
js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp);
|
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
|
#ifdef va_start
|
||||||
extern JSBool
|
extern JSBool
|
||||||
js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap);
|
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;
|
cxstack = nsnull;
|
||||||
JS_GC(cx);
|
JS_GC(cx);
|
||||||
} //this scopes the JSAutoCrossCompartmentCall
|
} //this scopes the JSAutoCrossCompartmentCall
|
||||||
|
JS_EndRequest(cx);
|
||||||
JS_DestroyContext(cx);
|
JS_DestroyContext(cx);
|
||||||
} // this scopes the nsCOMPtrs
|
} // this scopes the nsCOMPtrs
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user