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