v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
trap-handler-simulator.h
Go to the documentation of this file.
1// Copyright 2021 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#ifndef V8_TRAP_HANDLER_TRAP_HANDLER_SIMULATOR_H_
6#define V8_TRAP_HANDLER_TRAP_HANDLER_SIMULATOR_H_
7
8#include <cstdint>
9
10#include "include/v8config.h"
12
13// This header defines the ProbeMemory function to be used by simulators to
14// trigger a signal at a defined location, before doing an actual memory access.
15
16#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
17
19
20// Probe a memory address by doing a 1-byte read from the given address. If the
21// address is not readable, this will cause a trap as usual, but the trap
22// handler will recognise the address of the instruction doing the access and
23// treat it specially. It will use the given {pc} to look up the respective
24// landing pad and return to this function to return that landing pad. If {pc}
25// is not registered as a protected instruction, the signal will be propagated
26// as usual.
27// If the read at {address} succeeds, this function returns {0} instead.
28uintptr_t ProbeMemory(uintptr_t address, uintptr_t pc)
29// Specify an explicit symbol name (defined in
30// handler-outside-simulator.cc). Just {extern "C"} would produce
31// "ProbeMemory", but we want something more expressive on stack traces.
32#if V8_OS_DARWIN
33 asm("_v8_internal_simulator_ProbeMemory");
34#else
35 asm("v8_internal_simulator_ProbeMemory");
36#endif
37
38} // namespace v8::internal::trap_handler
39
40#endif // V8_TRAP_HANDLER_VIA_SIMULATOR
41
42#endif // V8_TRAP_HANDLER_TRAP_HANDLER_SIMULATOR_H_