Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4812 from jkotas/x64-coop
Browse files Browse the repository at this point in the history
Push proper RBP frame in PUSH_COOP_PINVOKE_FRAME
  • Loading branch information
janvorli committed Oct 27, 2017
2 parents dbd9f5d + 0dcd4a7 commit 35f6894
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Native/Runtime/unix/unixasmmacrosamd64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ C_FUNC(\Name):
DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_RSP

.macro PUSH_COOP_PINVOKE_FRAME trashReg
lea \trashReg, [rsp + 8h]
push_nonvol_reg rbp // push RBP frame
mov rbp, rsp
lea \trashReg, [rsp + 10h]
push_register \trashReg // save caller's RSP
push_nonvol_reg r15 // save preserved registers
push_nonvol_reg r14 // ..
Expand All @@ -317,19 +319,15 @@ DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_RSP
push_nonvol_reg rbx // ..
push_imm DEFAULT_FRAME_SAVE_FLAGS // save the register bitmask
push_register \trashReg // Thread * (unused by stackwalker)
push_nonvol_reg rbp // save caller's RBP
mov \trashReg, [rsp + 9*8] // Find the return address
push_register \trashReg // save m_RIP
mov \trashReg, [rsp + 8*8] // Find and save the callers RBP
push_register \trashReg
mov \trashReg, [rsp + 10*8] // Find and save the return address
push_register \trashReg
lea \trashReg, [rsp] // trashReg == address of frame

// stack alignment
alloc_stack 8
.endm

.macro POP_COOP_PINVOKE_FRAME
// Adjust for stack alignment and discard RIP
free_stack 16

pop_register r10 // discard RIP
pop_nonvol_reg rbp // restore RBP
pop_register r10 // discard thread
pop_register r10 // discard bitmask
Expand All @@ -339,4 +337,5 @@ DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_RSP
pop_nonvol_reg r14
pop_nonvol_reg r15
pop_register r10 // discard caller RSP
pop_register r10 // discard RBP frame
.endm

0 comments on commit 35f6894

Please sign in to comment.