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