mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 901934 - rm JS_(Set|Clear)RuntimeThread (r=billm)
--HG-- extra : rebase_source : d1127d1a90cfbc3a67b01d8ff7e48605b96e327f
This commit is contained in:
parent
401be3a7a4
commit
d98ace8680
@ -734,10 +734,18 @@ AsmJSMachExceptionHandler::AsmJSMachExceptionHandler()
|
||||
{}
|
||||
|
||||
void
|
||||
AsmJSMachExceptionHandler::release()
|
||||
AsmJSMachExceptionHandler::uninstall()
|
||||
{
|
||||
if (installed_) {
|
||||
clearCurrentThread();
|
||||
thread_port_t thread = mach_thread_self();
|
||||
kern_return_t kret = thread_set_exception_ports(thread,
|
||||
EXC_MASK_BAD_ACCESS,
|
||||
MACH_PORT_NULL,
|
||||
EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES,
|
||||
THREAD_STATE_NONE);
|
||||
mach_port_deallocate(mach_task_self(), thread);
|
||||
if (kret != KERN_SUCCESS)
|
||||
MOZ_CRASH();
|
||||
installed_ = false;
|
||||
}
|
||||
if (thread_ != NULL) {
|
||||
@ -767,40 +775,6 @@ AsmJSMachExceptionHandler::release()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AsmJSMachExceptionHandler::clearCurrentThread()
|
||||
{
|
||||
if (!installed_)
|
||||
return;
|
||||
|
||||
thread_port_t thread = mach_thread_self();
|
||||
kern_return_t kret = thread_set_exception_ports(thread,
|
||||
EXC_MASK_BAD_ACCESS,
|
||||
MACH_PORT_NULL,
|
||||
EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES,
|
||||
THREAD_STATE_NONE);
|
||||
mach_port_deallocate(mach_task_self(), thread);
|
||||
if (kret != KERN_SUCCESS)
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
void
|
||||
AsmJSMachExceptionHandler::setCurrentThread()
|
||||
{
|
||||
if (!installed_)
|
||||
return;
|
||||
|
||||
thread_port_t thread = mach_thread_self();
|
||||
kern_return_t kret = thread_set_exception_ports(thread,
|
||||
EXC_MASK_BAD_ACCESS,
|
||||
port_,
|
||||
EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES,
|
||||
THREAD_STATE_NONE);
|
||||
mach_port_deallocate(mach_task_self(), thread);
|
||||
if (kret != KERN_SUCCESS)
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
bool
|
||||
AsmJSMachExceptionHandler::install(JSRuntime *rt)
|
||||
{
|
||||
@ -839,7 +813,7 @@ AsmJSMachExceptionHandler::install(JSRuntime *rt)
|
||||
return true;
|
||||
|
||||
error:
|
||||
release();
|
||||
uninstall();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,16 +34,14 @@ class AsmJSMachExceptionHandler
|
||||
pthread_t thread_;
|
||||
mach_port_t port_;
|
||||
|
||||
void release();
|
||||
void uninstall();
|
||||
|
||||
public:
|
||||
AsmJSMachExceptionHandler();
|
||||
~AsmJSMachExceptionHandler() { release(); }
|
||||
~AsmJSMachExceptionHandler() { uninstall(); }
|
||||
mach_port_t port() const { return port_; }
|
||||
bool installed() const { return installed_; }
|
||||
bool install(JSRuntime *rt);
|
||||
void clearCurrentThread();
|
||||
void setCurrentThread();
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -6559,26 +6559,6 @@ JS_GetCurrentThread()
|
||||
#endif
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ClearRuntimeThread(JSRuntime *rt)
|
||||
{
|
||||
AssertHeapIsIdle(rt);
|
||||
JS_ASSERT(jsInitState == Running);
|
||||
#ifdef JS_THREADSAFE
|
||||
rt->clearOwnerThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetRuntimeThread(JSRuntime *rt)
|
||||
{
|
||||
AssertHeapIsIdle(rt);
|
||||
JS_ASSERT(jsInitState == Running);
|
||||
#ifdef JS_THREADSAFE
|
||||
rt->setOwnerThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
extern JS_NEVER_INLINE JS_PUBLIC_API(void)
|
||||
JS_AbortIfWrongThread(JSRuntime *rt)
|
||||
{
|
||||
|
@ -5118,37 +5118,11 @@ JS_GetCurrentThread();
|
||||
* thread. Embeddings may check this invariant outside the JS engine by calling
|
||||
* JS_AbortIfWrongThread (which will abort if not on the owner thread, even for
|
||||
* non-debug builds).
|
||||
*
|
||||
* It is possible to "move" a runtime between threads. This is accomplished by
|
||||
* calling JS_ClearRuntimeThread on a runtime's owner thread and then calling
|
||||
* JS_SetRuntimeThread on the new owner thread. The runtime must not be
|
||||
* accessed between JS_ClearRuntimeThread and JS_SetRuntimeThread. Also, the
|
||||
* caller is responsible for synchronizing the calls to Set/Clear.
|
||||
*/
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_AbortIfWrongThread(JSRuntime *rt);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ClearRuntimeThread(JSRuntime *rt);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetRuntimeThread(JSRuntime *rt);
|
||||
|
||||
class JSAutoSetRuntimeThread
|
||||
{
|
||||
JSRuntime *runtime_;
|
||||
|
||||
public:
|
||||
JSAutoSetRuntimeThread(JSRuntime *runtime) : runtime_(runtime) {
|
||||
JS_SetRuntimeThread(runtime_);
|
||||
}
|
||||
|
||||
~JSAutoSetRuntimeThread() {
|
||||
JS_ClearRuntimeThread(runtime_);
|
||||
}
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
|
@ -460,45 +460,9 @@ JSRuntime::~JSRuntime()
|
||||
JS_ASSERT(oldCount > 0);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
clearOwnerThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
void
|
||||
JSRuntime::setOwnerThread()
|
||||
{
|
||||
JS_ASSERT(ownerThread_ == (void *)0xc1ea12); /* "clear" */
|
||||
JS_ASSERT(requestDepth == 0);
|
||||
JS_ASSERT(js::TlsPerThreadData.get() == NULL);
|
||||
ownerThread_ = PR_GetCurrentThread();
|
||||
js::TlsPerThreadData.set(&mainThread);
|
||||
nativeStackBase = GetNativeStackBase();
|
||||
if (nativeStackQuota)
|
||||
JS_SetNativeStackQuota(this, nativeStackQuota);
|
||||
#ifdef XP_MACOSX
|
||||
asmJSMachExceptionHandler.setCurrentThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::clearOwnerThread()
|
||||
{
|
||||
JS_ASSERT(CurrentThreadCanAccessRuntime(this));
|
||||
JS_ASSERT(requestDepth == 0);
|
||||
ownerThread_ = (void *)0xc1ea12; /* "clear" */
|
||||
js::TlsPerThreadData.set(NULL);
|
||||
nativeStackBase = 0;
|
||||
#if JS_STACK_GROWTH_DIRECTION > 0
|
||||
mainThread.nativeStackLimit = UINTPTR_MAX;
|
||||
#else
|
||||
mainThread.nativeStackLimit = 0;
|
||||
#endif
|
||||
#ifdef XP_MACOSX
|
||||
asmJSMachExceptionHandler.clearCurrentThread();
|
||||
#endif
|
||||
}
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
||||
void
|
||||
NewObjectCache::clearNurseryObjects(JSRuntime *rt)
|
||||
|
@ -805,13 +805,9 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
/* Default JSVersion. */
|
||||
JSVersion defaultVersion_;
|
||||
|
||||
/* See comment for JS_AbortIfWrongThread in jsapi.h. */
|
||||
#ifdef JS_THREADSAFE
|
||||
public:
|
||||
void *ownerThread() const { return ownerThread_; }
|
||||
void clearOwnerThread();
|
||||
void setOwnerThread();
|
||||
private:
|
||||
/* See comment for JS_AbortIfWrongThread in jsapi.h. */
|
||||
void *ownerThread_;
|
||||
friend bool js::CurrentThreadCanAccessRuntime(JSRuntime *rt);
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user