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.
13asm(".text \n"
14 ".set noreorder \n"
15 ".global PushAllRegistersAndIterateStack \n"
16 ".type PushAllRegistersAndIterateStack, %function \n"
17 ".hidden PushAllRegistersAndIterateStack \n"
18 "PushAllRegistersAndIterateStack: \n"
19 // Push all callee-saved registers and save return address.
20 " daddiu $sp, $sp, -96 \n"
21 " sd $ra, 88($sp) \n"
22 " sd $s8, 80($sp) \n"
23 " sd $sp, 72($sp) \n"
24 " sd $gp, 64($sp) \n"
25 " sd $s7, 56($sp) \n"
26 " sd $s6, 48($sp) \n"
27 " sd $s5, 40($sp) \n"
28 " sd $s4, 32($sp) \n"
29 " sd $s3, 24($sp) \n"
30 " sd $s2, 16($sp) \n"
31 " sd $s1, 8($sp) \n"
32 " sd $s0, 0($sp) \n"
33 // Maintain frame pointer.
34 " move $s8, $sp \n"
35 // Pass 1st parameter (a0) unchanged (Stack*).
36 // Pass 2nd parameter (a1) unchanged (StackVisitor*).
37 // Save 3rd parameter (a2; IterateStackCallback).
38 " move $t9, $a2 \n"
39 // Call the callback.
40 " jalr $t9 \n"
41 // Delay slot: Pass 3rd parameter as sp (stack pointer).
42 " move $a2, $sp \n"
43 // Load return address.
44 " ld $ra, 88($sp) \n"
45 // Restore frame pointer.
46 " ld $s8, 80($sp) \n"
47 " jr $ra \n"
48 // Delay slot: Discard all callee-saved registers.
49 " daddiu $sp, $sp, 96 \n");