v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
push_registers_asm.cc
Go to the documentation of this file.
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
20asm(
21#ifdef _WIN32
22 ".att_syntax \n"
23 ".globl _PushAllRegistersAndIterateStack \n"
24 "_PushAllRegistersAndIterateStack: \n"
25#else // !_WIN32
26 ".globl PushAllRegistersAndIterateStack \n"
27 ".type PushAllRegistersAndIterateStack, %function \n"
28 ".hidden PushAllRegistersAndIterateStack \n"
29 "PushAllRegistersAndIterateStack: \n"
30#endif // !_WIN32
31 // [ IterateStackCallback ]
32 // [ StackVisitor* ]
33 // [ Stack* ]
34 // [ ret ]
35 // ebp is callee-saved. Maintain proper frame pointer for debugging.
36 " push %ebp \n"
37 " movl %esp, %ebp \n"
38 " push %ebx \n"
39 " push %esi \n"
40 " push %edi \n"
41 // Save 3rd parameter (IterateStackCallback).
42 " movl 28(%esp), %ecx \n"
43 // Pass 3rd parameter as esp (stack pointer).
44 " push %esp \n"
45 // Pass 2nd parameter (StackVisitor*).
46 " push 28(%esp) \n"
47 // Pass 1st parameter (Stack*).
48 " push 28(%esp) \n"
49 " call *%ecx \n"
50 // Pop the callee-saved registers.
51 " addl $24, %esp \n"
52 // Restore rbp as it was used as frame pointer.
53 " pop %ebp \n"
54 " ret \n"
55#if !defined(__APPLE__) && !defined(_WIN32)
56 ".Lfunc_end0: \n"
57 ".size PushAllRegistersAndIterateStack, "
58 ".Lfunc_end0-PushAllRegistersAndIterateStack\n"
59#endif // !defined(__APPLE__) && !defined(_WIN32)
60 );