summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index efea55811..503fad158 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -583,23 +583,15 @@ void JitCompiler::Compile_END(Instruction instr) {
583} 583}
584 584
585void JitCompiler::Compile_CALL(Instruction instr) { 585void JitCompiler::Compile_CALL(Instruction instr) {
586 // Need to advance the return address past the proceeding instructions, this is the number of bytes to skip
587 constexpr unsigned SKIP = 21;
588 const uintptr_t start = reinterpret_cast<uintptr_t>(GetCodePtr());
589
590 // Push return address - not using CALL because we also want to push the offset of the return before jumping
591 MOV(64, R(RAX), ImmPtr(GetCodePtr() + SKIP));
592 PUSH(RAX);
593
594 // Push offset of the return 586 // Push offset of the return
595 PUSH(32, Imm32(instr.flow_control.dest_offset + instr.flow_control.num_instructions)); 587 PUSH(64, Imm32(instr.flow_control.dest_offset + instr.flow_control.num_instructions));
596 588
597 // Jump 589 // Call the subroutine
598 FixupBranch b = J(true); 590 FixupBranch b = CALL();
599 fixup_branches.push_back({ b, instr.flow_control.dest_offset }); 591 fixup_branches.push_back({ b, instr.flow_control.dest_offset });
600 592
601 // Make sure that if the above code changes, SKIP gets updated 593 // Skip over the return offset that's on the stack
602 ASSERT(reinterpret_cast<ptrdiff_t>(GetCodePtr()) - start == SKIP); 594 ADD(64, R(RSP), Imm32(8));
603} 595}
604 596
605void JitCompiler::Compile_CALLC(Instruction instr) { 597void JitCompiler::Compile_CALLC(Instruction instr) {
@@ -758,14 +750,12 @@ void JitCompiler::Compile_Block(unsigned end) {
758 750
759void JitCompiler::Compile_Return() { 751void JitCompiler::Compile_Return() {
760 // Peek return offset on the stack and check if we're at that offset 752 // Peek return offset on the stack and check if we're at that offset
761 MOV(64, R(RAX), MDisp(RSP, 0)); 753 MOV(64, R(RAX), MDisp(RSP, 8));
762 CMP(32, R(RAX), Imm32(program_counter)); 754 CMP(32, R(RAX), Imm32(program_counter));
763 755
764 // If so, jump back to before CALL 756 // If so, jump back to before CALL
765 FixupBranch b = J_CC(CC_NZ, true); 757 FixupBranch b = J_CC(CC_NZ, true);
766 ADD(64, R(RSP), Imm32(8)); // Ignore return offset that's on the stack 758 RET();
767 POP(RAX); // Pop off return address
768 JMPptr(R(RAX));
769 SetJumpTarget(b); 759 SetJumpTarget(b);
770} 760}
771 761