diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-06-06 10:28:14 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-06-07 10:33:31 +0200 |
commit | 3dc8c3bed4cf3a77607edbb0b015e33f8b60fc09 (patch) | |
tree | 9dee56e142638b34f1eccbd0ad88c3bce5377c29 /deps/v8/src/trap-handler/trap-handler.h | |
parent | 91a1bbe3055a660194ca4d403795aa0c03e9d056 (diff) | |
download | node-new-3dc8c3bed4cf3a77607edbb0b015e33f8b60fc09.tar.gz |
deps: update V8 to 5.9.211.32
PR-URL: https://github.com/nodejs/node/pull/13263
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/trap-handler/trap-handler.h')
-rw-r--r-- | deps/v8/src/trap-handler/trap-handler.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h index e6dd9bdca4..5494c5fdb3 100644 --- a/deps/v8/src/trap-handler/trap-handler.h +++ b/deps/v8/src/trap-handler/trap-handler.h @@ -5,10 +5,29 @@ #ifndef V8_TRAP_HANDLER_H_ #define V8_TRAP_HANDLER_H_ +#include <signal.h> +#include <stdint.h> +#include <stdlib.h> + +#include "src/base/build_config.h" +#include "src/flags.h" +#include "src/globals.h" + +#if V8_OS_LINUX +#include <ucontext.h> +#endif + namespace v8 { namespace internal { namespace trap_handler { +// TODO(eholk): Support trap handlers on other platforms. +#if V8_TARGET_ARCH_X64 && V8_OS_LINUX && !V8_OS_ANDROID +#define V8_TRAP_HANDLER_SUPPORTED 1 +#else +#define V8_TRAP_HANDLER_SUPPORTED 0 +#endif + struct ProtectedInstructionData { // The offset of this instruction from the start of its code object. intptr_t instr_offset; @@ -19,6 +38,57 @@ struct ProtectedInstructionData { intptr_t landing_offset; }; +/// Adjusts the base code pointer. +void UpdateHandlerDataCodePointer(int index, void* base); + +/// Adds the handler data to the place where the signal handler will find it. +/// +/// This returns a number that can be used to identify the handler data to +/// UpdateHandlerDataCodePointer and ReleaseHandlerData, or -1 on failure. +int RegisterHandlerData(void* base, size_t size, + size_t num_protected_instructions, + ProtectedInstructionData* protected_instructions); + +/// Removes the data from the master list and frees any memory, if necessary. +void ReleaseHandlerData(int index); + +#if V8_OS_WIN +#define THREAD_LOCAL __declspec(thread) +#elif V8_OS_ANDROID +// TODO(eholk): fix this before enabling for trap handlers for Android. +#define THREAD_LOCAL +#else +#define THREAD_LOCAL __thread +#endif + +inline bool UseTrapHandler() { + return FLAG_wasm_trap_handler && V8_TRAP_HANDLER_SUPPORTED; +} + +extern THREAD_LOCAL bool g_thread_in_wasm_code; + +inline bool IsThreadInWasm() { return g_thread_in_wasm_code; } + +inline void SetThreadInWasm() { + if (UseTrapHandler()) { + DCHECK(!IsThreadInWasm()); + g_thread_in_wasm_code = true; + } +} + +inline void ClearThreadInWasm() { + if (UseTrapHandler()) { + DCHECK(IsThreadInWasm()); + g_thread_in_wasm_code = false; + } +} + +bool RegisterDefaultSignalHandler(); + +#if V8_OS_LINUX +bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context); +#endif // V8_OS_LINUX + } // namespace trap_handler } // namespace internal } // namespace v8 |