Skip to content

Commit

Permalink
x64 backend: Pass guest return address as first argument to guest fun…
Browse files Browse the repository at this point in the history
…ctions.
  • Loading branch information
DrChat committed Aug 26, 2016
1 parent 7683069 commit 52c75c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/xenia/cpu/backend/x64/x64_backend.cc
Expand Up @@ -422,7 +422,7 @@ HostToGuestThunk X64ThunkEmitter::EmitHostToGuestThunk() {

mov(rax, rcx);
mov(rsi, rdx); // context
mov(rdx, r8);
mov(rcx, r8); // return address
call(rax);

movaps(xmm6, qword[rsp + offsetof(StackLayout::Thunk, xmm[0])]);
Expand Down
10 changes: 5 additions & 5 deletions src/xenia/cpu/backend/x64/x64_emitter.cc
Expand Up @@ -169,7 +169,7 @@ bool X64Emitter::Emit(HIRBuilder* builder, size_t* out_stack_size) {
stack_size_ = stack_size;
sub(rsp, (uint32_t)stack_size);
mov(qword[rsp + StackLayout::GUEST_CTX_HOME], GetContextReg());
mov(qword[rsp + StackLayout::GUEST_RET_ADDR], rdx);
mov(qword[rsp + StackLayout::GUEST_RET_ADDR], rcx);
mov(qword[rsp + StackLayout::GUEST_CALL_RET_ADDR], 0);

// Safe now to do some tracing.
Expand Down Expand Up @@ -384,13 +384,13 @@ void X64Emitter::Call(const hir::Instr* instr, GuestFunction* function) {
EmitTraceUserCallReturn();

// Pass the callers return address over.
mov(rdx, qword[rsp + StackLayout::GUEST_RET_ADDR]);
mov(rcx, qword[rsp + StackLayout::GUEST_RET_ADDR]);

add(rsp, static_cast<uint32_t>(stack_size()));
jmp(rax);
} else {
// Return address is from the previous SET_RETURN_ADDRESS.
mov(rdx, qword[rsp + StackLayout::GUEST_CALL_RET_ADDR]);
mov(rcx, qword[rsp + StackLayout::GUEST_CALL_RET_ADDR]);

call(rax);
}
Expand Down Expand Up @@ -427,13 +427,13 @@ void X64Emitter::CallIndirect(const hir::Instr* instr,
EmitTraceUserCallReturn();

// Pass the callers return address over.
mov(rdx, qword[rsp + StackLayout::GUEST_RET_ADDR]);
mov(rcx, qword[rsp + StackLayout::GUEST_RET_ADDR]);

add(rsp, static_cast<uint32_t>(stack_size()));
jmp(rax);
} else {
// Return address is from the previous SET_RETURN_ADDRESS.
mov(rdx, qword[rsp + StackLayout::GUEST_CALL_RET_ADDR]);
mov(rcx, qword[rsp + StackLayout::GUEST_CALL_RET_ADDR]);

call(rax);
}
Expand Down

0 comments on commit 52c75c8

Please sign in to comment.