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 " addiu $sp, $sp, -48 \n" 20 " sw $ra, 44($sp) \n" 21 " sw $s8, 40($sp) \n" 22 " sw $sp, 36($sp) \n" 23 " sw $gp, 32($sp) \n" 24 " sw $s7, 28($sp) \n" 25 " sw $s6, 24($sp) \n" 26 " sw $s5, 20($sp) \n" 27 " sw $s4, 16($sp) \n" 28 " sw $s3, 12($sp) \n" 29 " sw $s2, 8($sp) \n" 30 " sw $s1, 4($sp) \n" 31 " sw $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 " lw $ra, 44($sp) \n" 44 // Restore frame pointer. 45 " lw $s8, 40($sp) \n" 46 " jr $ra \n" 47 // Delay slot: Discard all callee-saved registers. 48 " addiu $sp, $sp, 48 \n"); 49