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 // PPC ABI source: 15 // http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html 16 17 // AIX Runtime process stack: 18 // https://www.ibm.com/support/knowledgecenter/ssw_aix_71/assembler/idalangref_runtime_process.html 19 asm( 20 #if defined(_AIX) 21 ".globl .PushAllRegistersAndIterateStack, hidden \n" 22 ".csect .text[PR] \n" 23 ".PushAllRegistersAndIterateStack: \n" 24 #else 25 ".globl PushAllRegistersAndIterateStack \n" 26 ".type PushAllRegistersAndIterateStack, %function \n" 27 ".hidden PushAllRegistersAndIterateStack \n" 28 "PushAllRegistersAndIterateStack: \n" 29 #endif 30 // Push all callee-saved registers. 31 // lr, TOC pointer, r16 to r31. 160 bytes. 32 // The parameter save area shall be allocated by the caller. 112 btes. 33 // At anytime, SP (r1) needs to be multiple of 16 (i.e. 16-aligned). 34 " mflr 0 \n" 35 " std 0, 16(1) \n" 36 #if defined(_AIX) 37 " std 2, 40(1) \n" 38 #else 39 " std 2, 24(1) \n" 40 #endif 41 " stdu 1, -256(1) \n" 42 " std 14, 112(1) \n" 43 " std 15, 120(1) \n" 44 " std 16, 128(1) \n" 45 " std 17, 136(1) \n" 46 " std 18, 144(1) \n" 47 " std 19, 152(1) \n" 48 " std 20, 160(1) \n" 49 " std 21, 168(1) \n" 50 " std 22, 176(1) \n" 51 " std 23, 184(1) \n" 52 " std 24, 192(1) \n" 53 " std 25, 200(1) \n" 54 " std 26, 208(1) \n" 55 " std 27, 216(1) \n" 56 " std 28, 224(1) \n" 57 " std 29, 232(1) \n" 58 " std 30, 240(1) \n" 59 " std 31, 248(1) \n" 60 // Pass 1st parameter (r3) unchanged (Stack*). 61 // Pass 2nd parameter (r4) unchanged (StackVisitor*). 62 // Save 3rd parameter (r5; IterateStackCallback). 63 " mr 6, 5 \n" 64 #if defined(_AIX) 65 // Set up TOC for callee. 66 " ld 2,8(5) \n" 67 // AIX uses function descriptors, which means that 68 // pointers to functions do not point to code, but 69 // instead point to metadata about them, hence 70 // need to deterrence. 71 " ld 6,0(6) \n" 72 #endif 73 // Pass 3rd parameter as sp (stack pointer). 74 " mr 5, 1 \n" 75 #if !defined(_AIX) 76 // Set up r12 to be equal to the callee address (in order for TOC 77 // relocation). Only needed on LE Linux. 78 " mr 12, 6 \n" 79 #endif 80 // Call the callback. 81 " mtctr 6 \n" 82 " bctrl \n" 83 // Discard all the registers. 84 " addi 1, 1, 256 \n" 85 // Restore lr. 86 " ld 0, 16(1) \n" 87 " mtlr 0 \n" 88 #if defined(_AIX) 89 // Restore TOC pointer. 90 " ld 2, 40(1) \n" 91 #else 92 " ld 2, 24(1) \n" 93 #endif 94 " blr \n"); 95