Commit 1340412a authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

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/+/2128050Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66920}
parent 17967c07
......@@ -27,9 +27,12 @@ PushAllRegistersAndIterateStack:
// on the stack and we push 56 bytes which maintains 16-byte stack alignment
// at the call.
// 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 %rbx
push %rbp
push %r12
push %r13
push %r14
......@@ -42,7 +45,8 @@ PushAllRegistersAndIterateStack:
mov %rsp, %rdx
// Call the callback.
call *%r8
// Pop the callee-saved registers. None of them were modified so no
// restoring is needed.
add $56, %rsp
// Pop the callee-saved registers.
add $48, %rsp
// Restore rbp as it was used as frame pointer.
pop %rbp
ret
......@@ -16,11 +16,14 @@ PushAllRegistersAndIterateStack:
;; on the stack and we push 72 bytes which maintains 16-byte stack alignment
;; at the call.
;; 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 rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
......@@ -33,9 +36,10 @@ PushAllRegistersAndIterateStack:
mov r8, rsp
;; Call the callback.
call r9
;; Pop the callee-saved registers. None of them were modified so no
;; restoring is needed.
add rsp, 72
;; Pop the callee-saved registers.
add rsp, 64
;; Restore rbp as it was used as frame pointer.
pop rbp
ret
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment