v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
handler-outside-simulator.cc
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#include "include/v8config.h"
8
9#if V8_TRAP_HANDLER_SUPPORTED
10
11#if V8_OS_DARWIN
12#define SYMBOL(name) "_" #name
13#else // !V8_OS_DARWIN
14#define SYMBOL(name) #name
15#endif // !V8_OS_DARWIN
16
17// Define the v8::internal::trap_handler::ProbeMemory function declared in
18// trap-handler-simulators.h.
19asm(".att_syntax \n"
20 ".globl " SYMBOL(v8_internal_simulator_ProbeMemory) " \n"
21 SYMBOL(v8_internal_simulator_ProbeMemory) ": \n"
22// First parameter (address) passed in %rdi on Linux/Mac, and %rcx on Windows.
23// The second parameter (pc) is unused here. It is read by the trap handler
24// instead.
25#if V8_OS_WIN
26 " movb (%rcx), %al \n"
27#else
28 " movb (%rdi), %al \n"
29#endif // V8_OS_WIN
30 // Return 0 on success.
31 " xorl %eax, %eax \n"
32 // Place an additional "ret" here instead of falling through to the one
33 // below, because (some) toolchain(s) on Mac set ".subsections_via_symbols",
34 // which can cause the "ret" below to be placed elsewhere. An alternative
35 // prevention would be to add ".alt_entry" (see
36 // https://reviews.llvm.org/D79926), but just adding a "ret" is simpler.
37 " ret \n"
38 ".globl " SYMBOL(v8_simulator_probe_memory_continuation) " \n"
39 SYMBOL(v8_simulator_probe_memory_continuation) ": \n"
40 // If the trap handler continues here, it wrote the landing pad in %rax.
41 " ret \n");
42
43#endif