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.
15//
16// Calling convention source:
17// https://en.wikipedia.org/wiki/Calling_convention#ARM_(A64)
18
19asm(
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#ifdef V8_ENABLE_CONTROL_FLOW_INTEGRITY
35 // Sign return address.
36 " paciasp \n"
37#endif
38 // x19-x29 are callee-saved.
39 " stp x19, x20, [sp, #-16]! \n"
40 " stp x21, x22, [sp, #-16]! \n"
41 " stp x23, x24, [sp, #-16]! \n"
42 " stp x25, x26, [sp, #-16]! \n"
43 " stp x27, x28, [sp, #-16]! \n"
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 // Drop all callee-saved registers.
57 " add sp, sp, #80 \n"
58#ifdef V8_ENABLE_CONTROL_FLOW_INTEGRITY
59 // Authenticate return address.
60 " autiasp \n"
61#endif
62 " ret \n"
63#if !defined(__APPLE__) && !defined(_WIN64)
64 ".Lfunc_end0: \n"
65 ".size PushAllRegistersAndIterateStack, "
66 ".Lfunc_end0-PushAllRegistersAndIterateStack\n"
67#endif // !defined(__APPLE__) && !defined(_WIN64)
68 );