cppgc: Maintain frame pointer for x64 stack scan

Maintain a proper frame pointer in rbp when going through the
trampoline. This ensures that e.g. gdb can properly unwind the
stack.

Bug: chromium:1056170
Change-Id: I7a9252316e7ce8d83cf54e1efc801b92476bc4ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2128050
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66920}
This commit is contained in:
Michael Lippautz 2020-03-31 09:39:05 +02:00 committed by Commit Bot
parent 17967c0773
commit 1340412a2d
2 changed files with 16 additions and 8 deletions

View File

@ -27,9 +27,12 @@ PushAllRegistersAndIterateStack:
// on the stack and we push 56 bytes which maintains 16-byte stack alignment // on the stack and we push 56 bytes which maintains 16-byte stack alignment
// at the call. // at the call.
// Source: https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf // Source: https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
//
// rbp is callee-saved. Maintain proper frame pointer for debugging.
push %rbp
mov %rsp, %rbp
push $0xCDCDCD // Dummy for alignment. push $0xCDCDCD // Dummy for alignment.
push %rbx push %rbx
push %rbp
push %r12 push %r12
push %r13 push %r13
push %r14 push %r14
@ -42,7 +45,8 @@ PushAllRegistersAndIterateStack:
mov %rsp, %rdx mov %rsp, %rdx
// Call the callback. // Call the callback.
call *%r8 call *%r8
// Pop the callee-saved registers. None of them were modified so no // Pop the callee-saved registers.
// restoring is needed. add $48, %rsp
add $56, %rsp // Restore rbp as it was used as frame pointer.
pop %rbp
ret ret

View File

@ -16,11 +16,14 @@ PushAllRegistersAndIterateStack:
;; on the stack and we push 72 bytes which maintains 16-byte stack alignment ;; on the stack and we push 72 bytes which maintains 16-byte stack alignment
;; at the call. ;; at the call.
;; Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention ;; Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention
;;
;; rbp is callee-saved. Maintain proper frame pointer for debugging.
push rbp
mov rbp, rsp
push 0CDCDCDh ;; Dummy for alignment. push 0CDCDCDh ;; Dummy for alignment.
push rsi push rsi
push rdi push rdi
push rbx push rbx
push rbp
push r12 push r12
push r13 push r13
push r14 push r14
@ -33,9 +36,10 @@ PushAllRegistersAndIterateStack:
mov r8, rsp mov r8, rsp
;; Call the callback. ;; Call the callback.
call r9 call r9
;; Pop the callee-saved registers. None of them were modified so no ;; Pop the callee-saved registers.
;; restoring is needed. add rsp, 64
add rsp, 72 ;; Restore rbp as it was used as frame pointer.
pop rbp
ret ret
end end