diff options
Diffstat (limited to 'deps/v8/src/trap-handler/trap-handler.h')
-rw-r--r-- | deps/v8/src/trap-handler/trap-handler.h | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h index 0e9dbf248c..50fd4de439 100644 --- a/deps/v8/src/trap-handler/trap-handler.h +++ b/deps/v8/src/trap-handler/trap-handler.h @@ -5,7 +5,6 @@ #ifndef V8_TRAP_HANDLER_TRAP_HANDLER_H_ #define V8_TRAP_HANDLER_TRAP_HANDLER_H_ -#include <signal.h> #include <stdint.h> #include <stdlib.h> @@ -13,10 +12,6 @@ #include "src/flags.h" #include "src/globals.h" -#if V8_OS_LINUX -#include <ucontext.h> -#endif - namespace v8 { namespace internal { namespace trap_handler { @@ -24,6 +19,10 @@ 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 true +#elif V8_TARGET_ARCH_X64 && V8_OS_WIN +#define V8_TRAP_HANDLER_SUPPORTED true +#elif V8_TARGET_ARCH_X64 && V8_OS_MACOSX +#define V8_TRAP_HANDLER_SUPPORTED true #else #define V8_TRAP_HANDLER_SUPPORTED false #endif @@ -41,18 +40,18 @@ struct ProtectedInstructionData { const int kInvalidIndex = -1; -/// Adds the handler data to the place where the signal handler will find it. +/// Adds the handler data to the place where the trap handler will find it. /// /// This returns a number that can be used to identify the handler data to /// ReleaseHandlerData, or -1 on failure. -int RegisterHandlerData(Address base, size_t size, - size_t num_protected_instructions, - const ProtectedInstructionData* protected_instructions); +int V8_EXPORT_PRIVATE RegisterHandlerData( + Address base, size_t size, size_t num_protected_instructions, + const ProtectedInstructionData* protected_instructions); /// Removes the data from the master list and frees any memory, if necessary. /// TODO(mtrofin): We can switch to using size_t for index and not need /// kInvalidIndex. -void ReleaseHandlerData(int index); +void V8_EXPORT_PRIVATE ReleaseHandlerData(int index); #if V8_OS_WIN #define THREAD_LOCAL __declspec(thread) @@ -66,9 +65,9 @@ void ReleaseHandlerData(int index); extern bool g_is_trap_handler_enabled; // Enables trap handling for WebAssembly bounds checks. // -// use_v8_signal_handler indicates that V8 should install its own signal handler +// use_v8_handler indicates that V8 should install its own handler // rather than relying on the embedder to do it. -bool EnableTrapHandler(bool use_v8_signal_handler); +bool EnableTrapHandler(bool use_v8_handler); inline bool IsTrapHandlerEnabled() { DCHECK_IMPLIES(g_is_trap_handler_enabled, V8_TRAP_HANDLER_SUPPORTED); @@ -80,11 +79,12 @@ extern THREAD_LOCAL int g_thread_in_wasm_code; // Return the address of the thread-local {g_thread_in_wasm_code} variable. This // pointer can be accessed and modified as long as the thread calling this // function exists. Only use if from the same thread do avoid race conditions. -inline int* GetThreadInWasmThreadLocalAddress() { - return &g_thread_in_wasm_code; -} +V8_NOINLINE V8_EXPORT_PRIVATE int* GetThreadInWasmThreadLocalAddress(); -inline bool IsThreadInWasm() { return g_thread_in_wasm_code; } +// On Windows, asan installs its own exception handler which maps shadow +// memory. Since our exception handler may be executed before the asan exception +// handler, we have to make sure that asan shadow memory is not accessed here. +DISABLE_ASAN inline bool IsThreadInWasm() { return g_thread_in_wasm_code; } inline void SetThreadInWasm() { if (IsTrapHandlerEnabled()) { @@ -101,11 +101,7 @@ inline void ClearThreadInWasm() { } bool RegisterDefaultTrapHandler(); -V8_EXPORT_PRIVATE void RestoreOriginalSignalHandler(); - -#if V8_OS_LINUX -bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context); -#endif // V8_OS_LINUX +V8_EXPORT_PRIVATE void RemoveTrapHandler(); size_t GetRecoveredTrapCount(); |