33#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
39namespace trap_handler {
41#if V8_TRAP_HANDLER_SUPPORTED
55 PVOID thread_local_storage_pointer;
58#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
61extern char probe_memory_continuation[]
asm(
62 "v8_simulator_probe_memory_continuation");
76 if (exception->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION) {
86 TEB* pteb =
reinterpret_cast<TEB*
>(NtCurrentTeb());
87 if (!pteb->thread_local_storage_pointer)
return false;
99 const EXCEPTION_RECORD*
record = exception->ExceptionRecord;
101 uintptr_t fault_addr =
reinterpret_cast<uintptr_t
>(
record->ExceptionAddress);
103#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
105 if (fault_addr !=
reinterpret_cast<uintptr_t
>(&ProbeMemory))
return false;
108 uintptr_t simulated_ip = exception->ContextRecord->Rdx;
115 exception->ContextRecord->Rip =
116 reinterpret_cast<uintptr_t
>(&probe_memory_continuation);
124 exception->ContextRecord->R10 = fault_addr;
125#elif V8_HOST_ARCH_ARM64
127 exception->ContextRecord->X16 = fault_addr;
129#error Unsupported architecture
139 return EXCEPTION_CONTINUE_EXECUTION;
141 return EXCEPTION_CONTINUE_SEARCH;
bool IsFaultAddressCovered(uintptr_t fault_addr)
TH_DISABLE_ASAN bool TryHandleWasmTrap(EXCEPTION_POINTERS *exception)
thread_local int g_thread_in_wasm_code
LONG WINAPI HandleWasmTrap(EXCEPTION_POINTERS *exception)
std::atomic< uintptr_t > gLandingPad
TH_DISABLE_ASAN bool IsThreadInWasm()
#define TH_DCHECK(condition)