js/src/jit/AsmJSSignalHandlers.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     7 #ifndef jit_AsmJSSignalHandlers_h
     8 #define jit_AsmJSSignalHandlers_h
    10 struct JSRuntime;
    12 #ifdef XP_MACOSX
    13 # include <mach/mach.h>
    14 # include "jslock.h"
    15 #endif
    17 namespace js {
    19 // Returns whether signal handlers for asm.js and for JitRuntime access
    20 // violations have been installed.
    21 bool
    22 EnsureAsmJSSignalHandlersInstalled(JSRuntime *rt);
    24 // Force any currently-executing asm.js code to call
    25 // js::HandleExecutionInterrupt.
    26 extern void
    27 RequestInterruptForAsmJSCode(JSRuntime *rt);
    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_;
    42     void uninstall();
    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
    53 } // namespace js
    55 #endif // jit_AsmJSSignalHandlers_h

mercurial