Bug 956899 - Use js::Thread for WasmSignalHandler; r=luke

--HG--
extra : rebase_source : 2698dd65c4a1f33a93c86fb6c3682a92031cd629
This commit is contained in:
Terrence Cole 2016-05-11 18:03:56 -07:00
Родитель cf0624b1b4
Коммит 824042d11c
2 изменённых файлов: 6 добавлений и 10 удалений

Просмотреть файл

@ -958,9 +958,8 @@ static const mach_msg_id_t sExceptionId = 2405;
static const mach_msg_id_t sQuitId = 42;
static void
MachExceptionHandlerThread(void* threadArg)
MachExceptionHandlerThread(JSRuntime* rt)
{
JSRuntime* rt = reinterpret_cast<JSRuntime*>(threadArg);
mach_port_t port = rt->wasmMachExceptionHandler.port();
kern_return_t kret;
@ -1012,7 +1011,6 @@ MachExceptionHandlerThread(void* threadArg)
MachExceptionHandler::MachExceptionHandler()
: installed_(false),
thread_(nullptr),
port_(MACH_PORT_NULL)
{}
@ -1031,7 +1029,7 @@ MachExceptionHandler::uninstall()
MOZ_CRASH();
installed_ = false;
}
if (thread_ != nullptr) {
if (thread_.joinable()) {
// Break the handler thread out of the mach_msg loop.
mach_msg_header_t msg;
msg.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
@ -1048,8 +1046,7 @@ MachExceptionHandler::uninstall()
}
// Wait for the handler thread to complete before deallocating the port.
PR_JoinThread(thread_);
thread_ = nullptr;
thread_.join();
}
if (port_ != MACH_PORT_NULL) {
DebugOnly<kern_return_t> kret = mach_port_destroy(mach_task_self(), port_);
@ -1074,9 +1071,7 @@ MachExceptionHandler::install(JSRuntime* rt)
goto error;
// Create a thread to block on reading port_.
thread_ = PR_CreateThread(PR_USER_THREAD, MachExceptionHandlerThread, rt,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
if (!thread_)
if (!thread_.init(MachExceptionHandlerThread, rt))
goto error;
// Direct exceptions on this thread to port_ (and thus our handler thread).

Просмотреть файл

@ -25,6 +25,7 @@
# include <mach/mach.h>
# include "jslock.h"
#endif
#include "threading/Thread.h"
struct JSRuntime;
@ -53,7 +54,7 @@ EnsureSignalHandlersInstalled(JSRuntime* rt);
class MachExceptionHandler
{
bool installed_;
PRThread* thread_;
js::Thread thread_;
mach_port_t port_;
void uninstall();