1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit/AsmJSSignalHandlers.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef jit_AsmJSSignalHandlers_h 1.11 +#define jit_AsmJSSignalHandlers_h 1.12 + 1.13 +struct JSRuntime; 1.14 + 1.15 +#ifdef XP_MACOSX 1.16 +# include <mach/mach.h> 1.17 +# include "jslock.h" 1.18 +#endif 1.19 + 1.20 +namespace js { 1.21 + 1.22 +// Returns whether signal handlers for asm.js and for JitRuntime access 1.23 +// violations have been installed. 1.24 +bool 1.25 +EnsureAsmJSSignalHandlersInstalled(JSRuntime *rt); 1.26 + 1.27 +// Force any currently-executing asm.js code to call 1.28 +// js::HandleExecutionInterrupt. 1.29 +extern void 1.30 +RequestInterruptForAsmJSCode(JSRuntime *rt); 1.31 + 1.32 +// On OSX we are forced to use the lower-level Mach exception mechanism instead 1.33 +// of Unix signals. Mach exceptions are not handled on the victim's stack but 1.34 +// rather require an extra thread. For simplicity, we create one such thread 1.35 +// per JSRuntime (upon the first use of asm.js in the JSRuntime). This thread 1.36 +// and related resources are owned by AsmJSMachExceptionHandler which is owned 1.37 +// by JSRuntime. 1.38 +#ifdef XP_MACOSX 1.39 +class AsmJSMachExceptionHandler 1.40 +{ 1.41 + bool installed_; 1.42 + PRThread *thread_; 1.43 + mach_port_t port_; 1.44 + 1.45 + void uninstall(); 1.46 + 1.47 + public: 1.48 + AsmJSMachExceptionHandler(); 1.49 + ~AsmJSMachExceptionHandler() { uninstall(); } 1.50 + mach_port_t port() const { return port_; } 1.51 + bool installed() const { return installed_; } 1.52 + bool install(JSRuntime *rt); 1.53 +}; 1.54 +#endif 1.55 + 1.56 +} // namespace js 1.57 + 1.58 +#endif // jit_AsmJSSignalHandlers_h