1 // Copyright 2020 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 // Push all callee-saved registers to get them on the stack for conservative 6 // stack scanning. 7 // 8 // See asm/x64/push_registers_clang.cc for why the function is not generated 9 // using clang. 10 // 11 // Do not depend on V8_TARGET_OS_* defines as some embedders may override the 12 // GN toolchain (e.g. ChromeOS) and not provide them. 13 14 // We maintain 16-byte alignment. 15 // 16 // Calling convention source: 17 // https://en.wikipedia.org/wiki/Calling_convention#ARM_(A64) 18 19 asm( 20 #if defined(__APPLE__) 21 ".globl _PushAllRegistersAndIterateStack \n" 22 ".private_extern _PushAllRegistersAndIterateStack \n" 23 ".p2align 2 \n" 24 "_PushAllRegistersAndIterateStack: \n" 25 #else // !defined(__APPLE__) 26 ".globl PushAllRegistersAndIterateStack \n" 27 #if !defined(_WIN64) 28 ".type PushAllRegistersAndIterateStack, %function \n" 29 ".hidden PushAllRegistersAndIterateStack \n" 30 #endif // !defined(_WIN64) 31 ".p2align 2 \n" 32 "PushAllRegistersAndIterateStack: \n" 33 #endif // !defined(__APPLE__) 34 // x19-x29 are callee-saved. 35 " stp x19, x20, [sp, #-16]! \n" 36 " stp x21, x22, [sp, #-16]! \n" 37 " stp x23, x24, [sp, #-16]! \n" 38 " stp x25, x26, [sp, #-16]! \n" 39 " stp x27, x28, [sp, #-16]! \n" 40 #ifdef V8_ENABLE_CONTROL_FLOW_INTEGRITY 41 // Sign return address. 42 " paciasp \n" 43 #endif 44 " stp fp, lr, [sp, #-16]! \n" 45 // Maintain frame pointer. 46 " mov fp, sp \n" 47 // Pass 1st parameter (x0) unchanged (Stack*). 48 // Pass 2nd parameter (x1) unchanged (StackVisitor*). 49 // Save 3rd parameter (x2; IterateStackCallback) 50 " mov x7, x2 \n" 51 // Pass 3rd parameter as sp (stack pointer). 52 " mov x2, sp \n" 53 " blr x7 \n" 54 // Load return address and frame pointer. 55 " ldp fp, lr, [sp], #16 \n" 56 #ifdef V8_ENABLE_CONTROL_FLOW_INTEGRITY 57 // Authenticate return address. 58 " autiasp \n" 59 #endif 60 // Drop all callee-saved registers. 61 " add sp, sp, #80 \n" 62 " ret \n"); 63