v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
handler-outside-win.cc
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// PLEASE READ BEFORE CHANGING THIS FILE!
6//
7// This file implements the support code for the out of bounds trap handler.
8// Nothing in here actually runs in the trap handler, but the code here
9// manipulates data structures used by the trap handler so we still need to be
10// careful. In order to minimize this risk, here are some rules to follow.
11//
12// 1. Avoid introducing new external dependencies. The files in src/trap-handler
13// should be as self-contained as possible to make it easy to audit the code.
14//
15// 2. Any changes must be reviewed by someone from the crash reporting
16// or security team. Se OWNERS for suggested reviewers.
17//
18// For more information, see https://goo.gl/yMeyUY.
19//
20// For the code that runs in the trap handler itself, see handler-inside.cc.
21
22#include <windows.h>
23
26
27namespace v8 {
28namespace internal {
29namespace trap_handler {
30
31#if V8_TRAP_HANDLER_SUPPORTED
32
33namespace {
34
35// A handle to our registered exception handler, so that we can remove it
36// again later.
37void* g_registered_handler = nullptr;
38
39} // namespace
40
42 constexpr ULONG first = TRUE;
43 TH_CHECK(g_registered_handler == nullptr);
44 g_registered_handler = AddVectoredExceptionHandler(first, HandleWasmTrap);
45
46 return nullptr != g_registered_handler;
47}
48
49void RemoveTrapHandler() {
50 if (!g_registered_handler) return;
51
52 RemoveVectoredExceptionHandler(g_registered_handler);
53 g_registered_handler = nullptr;
54}
55
56#endif // V8_TRAP_HANDLER_SUPPORTED
57
58} // namespace trap_handler
59} // namespace internal
60} // namespace v8
LONG WINAPI HandleWasmTrap(EXCEPTION_POINTERS *exception)
#define TH_CHECK(condition)