mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 714458 - Part b: Provide the thread-related APIs xpcprivate.h needs; r=igor
This introduces a JS_GetCurrentThread to go with the existing JS_GetContextThread, as well as a js::GetContextThread to get at the actual JSThread object, and inlines the only use of JS_THREAD_ID.
This commit is contained in:
parent
38fbde8026
commit
fab1325ed4
@ -6587,6 +6587,12 @@ JS_ThrowStopIteration(JSContext *cx)
|
||||
return js_ThrowStopIteration(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(intptr_t)
|
||||
JS_GetCurrentThread()
|
||||
{
|
||||
return reinterpret_cast<intptr_t>(js_CurrentThreadId());
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the owning thread id of a context. Returns 0 if the context is not
|
||||
* owned by any thread.
|
||||
@ -6595,7 +6601,7 @@ JS_PUBLIC_API(intptr_t)
|
||||
JS_GetContextThread(JSContext *cx)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
return reinterpret_cast<intptr_t>(JS_THREAD_ID(cx));
|
||||
return cx->thread() ? reinterpret_cast<intptr_t>(cx->thread()->id) : 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -4929,6 +4929,9 @@ JS_ThrowReportedError(JSContext *cx, const char *message,
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_ThrowStopIteration(JSContext *cx);
|
||||
|
||||
extern JS_PUBLIC_API(intptr_t)
|
||||
JS_GetCurrentThread();
|
||||
|
||||
/*
|
||||
* Associate the current thread with the given context. This is done
|
||||
* implicitly by JS_NewContext.
|
||||
|
@ -1310,10 +1310,6 @@ struct JSContext
|
||||
|
||||
namespace js {
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
# define JS_THREAD_ID(cx) ((cx)->thread() ? (cx)->thread()->id : 0)
|
||||
#endif
|
||||
|
||||
#if defined JS_THREADSAFE && defined DEBUG
|
||||
|
||||
class AutoCheckRequestDepth {
|
||||
|
@ -458,3 +458,15 @@ js::DumpHeapComplete(JSContext *cx, FILE *fp)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace js {
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
JSThread *
|
||||
GetContextThread(const JSContext *cx)
|
||||
{
|
||||
return cx->thread();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace js
|
||||
|
@ -445,6 +445,11 @@ GetPCCountScriptSummary(JSContext *cx, size_t script);
|
||||
JS_FRIEND_API(JSString *)
|
||||
GetPCCountScriptContents(JSContext *cx, size_t script);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
JS_FRIEND_API(JSThread *)
|
||||
GetContextThread(const JSContext *cx);
|
||||
#endif
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
/*
|
||||
|
@ -423,7 +423,7 @@ XPCPerThreadData::GetDataImpl(JSContext *cx)
|
||||
}
|
||||
|
||||
if (cx && !sMainJSThread && NS_IsMainThread()) {
|
||||
sMainJSThread = cx->thread();
|
||||
sMainJSThread = js::GetContextThread(cx);
|
||||
|
||||
sMainThreadData = data;
|
||||
|
||||
|
@ -552,7 +552,7 @@ GetContextFromObject(JSObject *obj)
|
||||
|
||||
if (xpcc) {
|
||||
JSContext *cx = xpcc->GetJSContext();
|
||||
if (cx->thread()->id == js_CurrentThreadId())
|
||||
if (JS_GetContextThread(cx) == JS_GetCurrentThread())
|
||||
return cx;
|
||||
}
|
||||
|
||||
|
@ -3646,9 +3646,9 @@ public:
|
||||
static inline XPCPerThreadData* GetData(JSContext *cx)
|
||||
{
|
||||
if (cx) {
|
||||
NS_ASSERTION(cx->thread(), "Uh, JS context w/o a thread?");
|
||||
NS_ASSERTION(js::GetContextThread(cx), "Uh, JS context w/o a thread?");
|
||||
|
||||
if (cx->thread() == sMainJSThread)
|
||||
if (js::GetContextThread(cx) == sMainJSThread)
|
||||
return sMainThreadData;
|
||||
} else if (sMainThreadData && sMainThreadData->mThread == PR_GetCurrentThread()) {
|
||||
return sMainThreadData;
|
||||
@ -3751,7 +3751,7 @@ public:
|
||||
{sMainJSThread = nsnull; sMainThreadData = nsnull;}
|
||||
|
||||
static bool IsMainThread(JSContext *cx)
|
||||
{ return cx->thread() == sMainJSThread; }
|
||||
{ return js::GetContextThread(cx) == sMainJSThread; }
|
||||
|
||||
private:
|
||||
XPCPerThreadData();
|
||||
|
Loading…
Reference in New Issue
Block a user