5 #ifndef V8_TRAP_HANDLER_TRAP_HANDLER_H_ 6 #define V8_TRAP_HANDLER_TRAP_HANDLER_H_ 11 #include "src/base/build_config.h" 12 #include "src/flags.h" 13 #include "src/globals.h" 17 namespace trap_handler {
20 #if V8_TARGET_ARCH_X64 && V8_OS_LINUX && !V8_OS_ANDROID 21 #define V8_TRAP_HANDLER_SUPPORTED true 22 #elif V8_TARGET_ARCH_X64 && V8_OS_WIN 23 #define V8_TRAP_HANDLER_SUPPORTED true 24 #elif V8_TARGET_ARCH_X64 && V8_OS_MACOSX 25 #define V8_TRAP_HANDLER_SUPPORTED true 27 #define V8_TRAP_HANDLER_SUPPORTED false 41 const int kInvalidIndex = -1;
47 int RegisterHandlerData(Address base,
size_t size,
48 size_t num_protected_instructions,
54 void ReleaseHandlerData(
int index);
57 #define THREAD_LOCAL __declspec(thread) 62 #define THREAD_LOCAL __thread 65 extern bool g_is_trap_handler_enabled;
70 bool EnableTrapHandler(
bool use_v8_handler);
72 inline bool IsTrapHandlerEnabled() {
73 DCHECK_IMPLIES(g_is_trap_handler_enabled, V8_TRAP_HANDLER_SUPPORTED);
74 return g_is_trap_handler_enabled;
77 extern THREAD_LOCAL
int g_thread_in_wasm_code;
82 inline int* GetThreadInWasmThreadLocalAddress() {
83 return &g_thread_in_wasm_code;
89 DISABLE_ASAN
inline bool IsThreadInWasm() {
return g_thread_in_wasm_code; }
91 inline void SetThreadInWasm() {
92 if (IsTrapHandlerEnabled()) {
93 DCHECK(!IsThreadInWasm());
94 g_thread_in_wasm_code =
true;
98 inline void ClearThreadInWasm() {
99 if (IsTrapHandlerEnabled()) {
100 DCHECK(IsThreadInWasm());
101 g_thread_in_wasm_code =
false;
105 bool RegisterDefaultTrapHandler();
106 V8_EXPORT_PRIVATE
void RemoveTrapHandler();
108 size_t GetRecoveredTrapCount();
114 #endif // V8_TRAP_HANDLER_TRAP_HANDLER_H_