[traphandler] Enable arm64 simulator support for Mac
This ports https://crrev.com/c/3040844 to also work on Mac. All that's needed is minor tweaks to the inline assembly. The inline assembly is stripped down to what's actually needed. I didn't find documentation on ".pushsection" and ".popsection" on Mac. Since we do not have this on other inline assembly (e.g. src/heap/base/asm/x64/push_registers_asm.cc) removing this here does not regress the status quo. If this ever causes problems, we will have to consistently add it everywhere. The new code paths are tested by the v8_mac_arm64* CQ bots, and the "V8 Mac - arm64 - sim - {debug,release}" waterfall bots. R=ahaas@chromium.org, mseaborn@chromium.org Bug: v8:11955 Change-Id: If0b78a2d2a8b365c1c77b171de0591452e4bbeec Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3063500 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#76060}
This commit is contained in:
parent
ce8cef36aa
commit
11a15e7feb
14
BUILD.gn
14
BUILD.gn
@ -3391,12 +3391,13 @@ v8_header_set("v8_internal_headers") {
|
||||
sources += [ "src/execution/arm64/pointer-authentication-arm64.h" ]
|
||||
}
|
||||
if (v8_enable_webassembly) {
|
||||
# Trap handling is enabled on arm64 Mac and in simulators on x64 on Linux.
|
||||
# Trap handling is enabled on arm64 Mac and in simulators on x64 on Linux
|
||||
# and Mac.
|
||||
if ((current_cpu == "arm64" && is_mac) ||
|
||||
(current_cpu == "x64" && (is_linux || is_chromeos))) {
|
||||
(current_cpu == "x64" && (is_linux || is_chromeos || is_mac))) {
|
||||
sources += [ "src/trap-handler/handler-inside-posix.h" ]
|
||||
}
|
||||
if (current_cpu == "x64" && (is_linux || is_chromeos)) {
|
||||
if (current_cpu == "x64" && (is_linux || is_chromeos || is_mac)) {
|
||||
sources += [ "src/trap-handler/trap-handler-simulator.h" ]
|
||||
}
|
||||
}
|
||||
@ -4298,15 +4299,16 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/regexp/arm64/regexp-macro-assembler-arm64.cc",
|
||||
]
|
||||
if (v8_enable_webassembly) {
|
||||
# Trap handling is enabled on arm64 Mac and in simulators on x64 on Linux.
|
||||
# Trap handling is enabled on arm64 Mac and in simulators on x64 on Linux
|
||||
# and Mac.
|
||||
if ((current_cpu == "arm64" && is_mac) ||
|
||||
(current_cpu == "x64" && (is_linux || is_chromeos))) {
|
||||
(current_cpu == "x64" && (is_linux || is_chromeos || is_mac))) {
|
||||
sources += [
|
||||
"src/trap-handler/handler-inside-posix.cc",
|
||||
"src/trap-handler/handler-outside-posix.cc",
|
||||
]
|
||||
}
|
||||
if (current_cpu == "x64" && (is_linux || is_chromeos)) {
|
||||
if (current_cpu == "x64" && (is_linux || is_chromeos || is_mac)) {
|
||||
sources += [ "src/trap-handler/handler-outside-simulator.cc" ]
|
||||
}
|
||||
}
|
||||
|
@ -5,26 +5,25 @@
|
||||
#include "include/v8config.h"
|
||||
#include "src/trap-handler/trap-handler-simulator.h"
|
||||
|
||||
#if !V8_OS_LINUX
|
||||
#error "The inline assembly only works on Linux so far."
|
||||
#endif
|
||||
#if V8_OS_MACOSX
|
||||
#define SYMBOL(name) "_" #name
|
||||
#else // !V8_OS_MACOSX
|
||||
#define SYMBOL(name) #name
|
||||
#endif // !V8_OS_MACOSX
|
||||
|
||||
// Define the ProbeMemory function declared in trap-handler-simulators.h.
|
||||
asm(
|
||||
// Define the ProbeMemory function declared in trap-handler-simulators.h.
|
||||
".pushsection .text \n"
|
||||
".globl ProbeMemory \n"
|
||||
".type ProbeMemory, %function \n"
|
||||
".globl v8_probe_memory_address \n"
|
||||
".globl v8_probe_memory_continuation \n"
|
||||
"ProbeMemory: \n"
|
||||
".globl " SYMBOL(ProbeMemory) " \n"
|
||||
".globl " SYMBOL(v8_probe_memory_address) " \n"
|
||||
".globl " SYMBOL(v8_probe_memory_continuation) "\n"
|
||||
SYMBOL(ProbeMemory) ": \n"
|
||||
// First parameter (address) passed in %rdi.
|
||||
// The second parameter (pc) is unused here. It is read by the trap handler
|
||||
// instead.
|
||||
"v8_probe_memory_address: \n"
|
||||
SYMBOL(v8_probe_memory_address) ": \n"
|
||||
" movb (%rdi), %al \n"
|
||||
// Return 0 on success.
|
||||
" xorl %eax, %eax \n"
|
||||
"v8_probe_memory_continuation: \n"
|
||||
SYMBOL(v8_probe_memory_continuation) ": \n"
|
||||
// If the trap handler continues here, it wrote the landing pad in %rax.
|
||||
" ret \n"
|
||||
".popsection \n");
|
||||
" ret \n");
|
||||
|
@ -25,8 +25,8 @@ namespace trap_handler {
|
||||
// Arm64 (non-simulator) on Mac.
|
||||
#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && V8_OS_MACOSX
|
||||
#define V8_TRAP_HANDLER_SUPPORTED true
|
||||
// Arm64 simulator on x64 on Linux.
|
||||
#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && V8_OS_LINUX
|
||||
// Arm64 simulator on x64 on Linux or Mac.
|
||||
#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && (V8_OS_LINUX || V8_OS_MACOSX)
|
||||
#define V8_TRAP_HANDLER_VIA_SIMULATOR
|
||||
#define V8_TRAP_HANDLER_SUPPORTED true
|
||||
// Everything else is unsupported.
|
||||
|
Loading…
Reference in New Issue
Block a user