michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_AsmJSSignalHandlers_h michael@0: #define jit_AsmJSSignalHandlers_h michael@0: michael@0: struct JSRuntime; michael@0: michael@0: #ifdef XP_MACOSX michael@0: # include michael@0: # include "jslock.h" michael@0: #endif michael@0: michael@0: namespace js { michael@0: michael@0: // Returns whether signal handlers for asm.js and for JitRuntime access michael@0: // violations have been installed. michael@0: bool michael@0: EnsureAsmJSSignalHandlersInstalled(JSRuntime *rt); michael@0: michael@0: // Force any currently-executing asm.js code to call michael@0: // js::HandleExecutionInterrupt. michael@0: extern void michael@0: RequestInterruptForAsmJSCode(JSRuntime *rt); michael@0: michael@0: // On OSX we are forced to use the lower-level Mach exception mechanism instead michael@0: // of Unix signals. Mach exceptions are not handled on the victim's stack but michael@0: // rather require an extra thread. For simplicity, we create one such thread michael@0: // per JSRuntime (upon the first use of asm.js in the JSRuntime). This thread michael@0: // and related resources are owned by AsmJSMachExceptionHandler which is owned michael@0: // by JSRuntime. michael@0: #ifdef XP_MACOSX michael@0: class AsmJSMachExceptionHandler michael@0: { michael@0: bool installed_; michael@0: PRThread *thread_; michael@0: mach_port_t port_; michael@0: michael@0: void uninstall(); michael@0: michael@0: public: michael@0: AsmJSMachExceptionHandler(); michael@0: ~AsmJSMachExceptionHandler() { uninstall(); } michael@0: mach_port_t port() const { return port_; } michael@0: bool installed() const { return installed_; } michael@0: bool install(JSRuntime *rt); michael@0: }; michael@0: #endif michael@0: michael@0: } // namespace js michael@0: michael@0: #endif // jit_AsmJSSignalHandlers_h