Commit 936debb5 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[traphandler] Fix ProbeMemory on Mac release builds

For some reason, the "ret" instruction goes missing on Mac release
builds, probably because the compiler decides to split the inline
assembly block and move the "v8_probe_memory_continuation" block
somewhere else. This CL fixes that by adding another explicit "ret" at
the end of "ProbeMemory".

Also, we remove the "v8_probe_memory_address" symbol (which is identical
to just "ProbeMemory"), to prevent the compiler from splitting
"ProbeMemory" and "v8_probe_memory_address".

R=ahaas@chromium.org

Bug: v8:11955
Change-Id: I2e63b2db94206e329be214ab7b553ab502d6ecc2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3071202Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76091}
parent d4711df3
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
#include "src/trap-handler/trap-handler-internal.h" #include "src/trap-handler/trap-handler-internal.h"
#include "src/trap-handler/trap-handler.h" #include "src/trap-handler/trap-handler.h"
#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
#include "src/trap-handler/trap-handler-simulator.h"
#endif
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace trap_handler { namespace trap_handler {
...@@ -83,9 +87,8 @@ class UnmaskOobSignalScope { ...@@ -83,9 +87,8 @@ class UnmaskOobSignalScope {
}; };
#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR #ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
// These are addresses inside the "ProbeMemory" function, defined in // This is the address where we continue on a failed "ProbeMemory". It's defined
// "handler-outside-simulators.cc". // in "handler-outside-simulators.cc".
extern "C" char v8_probe_memory_address[];
extern "C" char v8_probe_memory_continuation[]; extern "C" char v8_probe_memory_continuation[];
#endif // V8_TRAP_HANDLER_VIA_SIMULATOR #endif // V8_TRAP_HANDLER_VIA_SIMULATOR
...@@ -132,7 +135,7 @@ bool TryHandleSignal(int signum, siginfo_t* info, void* context) { ...@@ -132,7 +135,7 @@ bool TryHandleSignal(int signum, siginfo_t* info, void* context) {
#ifdef V8_TRAP_HANDLER_VIA_SIMULATOR #ifdef V8_TRAP_HANDLER_VIA_SIMULATOR
// Only handle signals triggered by the load in {ProbeMemory}. // Only handle signals triggered by the load in {ProbeMemory}.
if (fault_addr != reinterpret_cast<uintptr_t>(&v8_probe_memory_address)) { if (fault_addr != reinterpret_cast<uintptr_t>(&ProbeMemory)) {
return false; return false;
} }
......
...@@ -14,16 +14,15 @@ ...@@ -14,16 +14,15 @@
// Define the ProbeMemory function declared in trap-handler-simulators.h. // Define the ProbeMemory function declared in trap-handler-simulators.h.
asm( asm(
".globl " SYMBOL(ProbeMemory) " \n" ".globl " SYMBOL(ProbeMemory) " \n"
".globl " SYMBOL(v8_probe_memory_address) " \n"
".globl " SYMBOL(v8_probe_memory_continuation) "\n"
SYMBOL(ProbeMemory) ": \n" SYMBOL(ProbeMemory) ": \n"
// First parameter (address) passed in %rdi. // First parameter (address) passed in %rdi.
// The second parameter (pc) is unused here. It is read by the trap handler // The second parameter (pc) is unused here. It is read by the trap handler
// instead. // instead.
SYMBOL(v8_probe_memory_address) ": \n"
" movb (%rdi), %al \n" " movb (%rdi), %al \n"
// Return 0 on success. // Return 0 on success.
" xorl %eax, %eax \n" " xorl %eax, %eax \n"
" ret \n"
".globl " SYMBOL(v8_probe_memory_continuation) "\n"
SYMBOL(v8_probe_memory_continuation) ": \n" SYMBOL(v8_probe_memory_continuation) ": \n"
// If the trap handler continues here, it wrote the landing pad in %rax. // If the trap handler continues here, it wrote the landing pad in %rax.
" ret \n"); " ret \n");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment