|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_AsmJSSignalHandlers_h |
|
8 #define jit_AsmJSSignalHandlers_h |
|
9 |
|
10 struct JSRuntime; |
|
11 |
|
12 #ifdef XP_MACOSX |
|
13 # include <mach/mach.h> |
|
14 # include "jslock.h" |
|
15 #endif |
|
16 |
|
17 namespace js { |
|
18 |
|
19 // Returns whether signal handlers for asm.js and for JitRuntime access |
|
20 // violations have been installed. |
|
21 bool |
|
22 EnsureAsmJSSignalHandlersInstalled(JSRuntime *rt); |
|
23 |
|
24 // Force any currently-executing asm.js code to call |
|
25 // js::HandleExecutionInterrupt. |
|
26 extern void |
|
27 RequestInterruptForAsmJSCode(JSRuntime *rt); |
|
28 |
|
29 // On OSX we are forced to use the lower-level Mach exception mechanism instead |
|
30 // of Unix signals. Mach exceptions are not handled on the victim's stack but |
|
31 // rather require an extra thread. For simplicity, we create one such thread |
|
32 // per JSRuntime (upon the first use of asm.js in the JSRuntime). This thread |
|
33 // and related resources are owned by AsmJSMachExceptionHandler which is owned |
|
34 // by JSRuntime. |
|
35 #ifdef XP_MACOSX |
|
36 class AsmJSMachExceptionHandler |
|
37 { |
|
38 bool installed_; |
|
39 PRThread *thread_; |
|
40 mach_port_t port_; |
|
41 |
|
42 void uninstall(); |
|
43 |
|
44 public: |
|
45 AsmJSMachExceptionHandler(); |
|
46 ~AsmJSMachExceptionHandler() { uninstall(); } |
|
47 mach_port_t port() const { return port_; } |
|
48 bool installed() const { return installed_; } |
|
49 bool install(JSRuntime *rt); |
|
50 }; |
|
51 #endif |
|
52 |
|
53 } // namespace js |
|
54 |
|
55 #endif // jit_AsmJSSignalHandlers_h |