1 // Copyright 2021 The Chromium Authors 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 // We maintain 16-byte alignment. 12 // 13 // Calling convention source: 14 // https://en.wikipedia.org/wiki/Calling_convention#ARM_(A64) 15 16 asm( 17 #if defined(__APPLE__) 18 ".globl _PAPushAllRegistersAndIterateStack \n" 19 ".private_extern _PAPushAllRegistersAndIterateStack \n" 20 ".p2align 2 \n" 21 "_PAPushAllRegistersAndIterateStack: \n" 22 #else // !defined(__APPLE__) 23 ".globl PAPushAllRegistersAndIterateStack \n" 24 #if !defined(_WIN64) 25 ".type PAPushAllRegistersAndIterateStack, %function \n" 26 ".hidden PAPushAllRegistersAndIterateStack \n" 27 #endif // !defined(_WIN64) 28 ".p2align 2 \n" 29 "PAPushAllRegistersAndIterateStack: \n" 30 #endif // !defined(__APPLE__) 31 // x19-x29 are callee-saved. 32 " stp x19, x20, [sp, #-16]! \n" 33 " stp x21, x22, [sp, #-16]! \n" 34 " stp x23, x24, [sp, #-16]! \n" 35 " stp x25, x26, [sp, #-16]! \n" 36 " stp x27, x28, [sp, #-16]! \n" 37 " stp fp, lr, [sp, #-16]! \n" 38 // Maintain frame pointer. 39 " mov fp, sp \n" 40 // Pass 1st parameter (x0) unchanged (Stack*). 41 // Pass 2nd parameter (x1) unchanged (StackVisitor*). 42 // Save 3rd parameter (x2; IterateStackCallback) 43 " mov x7, x2 \n" 44 // Pass 3rd parameter as sp (stack pointer). 45 " mov x2, sp \n" 46 " blr x7 \n" 47 // Load return address and frame pointer. 48 " ldp fp, lr, [sp], #16 \n" 49 // Drop all callee-saved registers. 50 " add sp, sp, #80 \n" 51 " ret \n"); 52