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 at calls. There is an 4-byte return address 15 // on the stack and we push 28 bytes which maintains 16-byte stack alignment 16 // at the call. 17 // 18 // The following assumes cdecl calling convention. 19 // Source: https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl 20 asm( 21 #ifdef _WIN32 22 ".globl _PushAllRegistersAndIterateStack \n" 23 "_PushAllRegistersAndIterateStack: \n" 24 #else // !_WIN32 25 ".globl PushAllRegistersAndIterateStack \n" 26 ".type PushAllRegistersAndIterateStack, %function \n" 27 ".hidden PushAllRegistersAndIterateStack \n" 28 "PushAllRegistersAndIterateStack: \n" 29 #endif // !_WIN32 30 // [ IterateStackCallback ] 31 // [ StackVisitor* ] 32 // [ Stack* ] 33 // [ ret ] 34 // ebp is callee-saved. Maintain proper frame pointer for debugging. 35 " push %ebp \n" 36 " movl %esp, %ebp \n" 37 " push %ebx \n" 38 " push %esi \n" 39 " push %edi \n" 40 // Save 3rd parameter (IterateStackCallback). 41 " movl 28(%esp), %ecx \n" 42 // Pass 3rd parameter as esp (stack pointer). 43 " push %esp \n" 44 // Pass 2nd parameter (StackVisitor*). 45 " push 28(%esp) \n" 46 // Pass 1st parameter (Stack*). 47 " push 28(%esp) \n" 48 " call *%ecx \n" 49 // Pop the callee-saved registers. 50 " addl $24, %esp \n" 51 // Restore rbp as it was used as frame pointer. 52 " pop %ebp \n" 53 " ret \n"); 54