Skip to content

Commit 019ad1f

Browse files
committed
Remove slow mem path placeholder opcodes
1 parent 5ba9b5d commit 019ad1f

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/jit/emitter/emit_transfer.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::core::memory::regions::VRAM_OFFSET;
12
use crate::core::thread_regs::ThreadRegs;
23
use crate::core::CpuType;
34
use crate::jit::assembler::block_asm::{BlockAsm, CPSR_TMP_REG, GUEST_REGS_PTR_REG};
@@ -153,6 +154,8 @@ impl JitAsm<'_> {
153154

154155
block_asm.ensure_emit_for(64);
155156
let fast_mem_start = if !inst.op.is_write_mem_transfer() && op1 == Reg::PC && !transfer.write_back() && op2.as_imm().is_some() {
157+
let consider_slow_mem = block_asm.current_pc & 0xFF000000 == VRAM_OFFSET;
158+
156159
let imm = op2.as_imm().unwrap();
157160
let pc = if block_asm.thumb { block_asm.current_pc + 4 } else { block_asm.current_pc + 8 };
158161
let mut imm_addr = if transfer.add() { pc + imm } else { pc - imm };
@@ -161,22 +164,26 @@ impl JitAsm<'_> {
161164
imm_addr &= !0x3;
162165
}
163166

164-
block_asm.ldr2(Reg::R2, imm_addr);
167+
if consider_slow_mem {
168+
block_asm.ldr2(Reg::R2, imm_addr);
169+
block_asm.ensure_emit_for(64);
170+
}
165171

166172
let func = get_read_func!(size, transfer.signed());
167173

168-
block_asm.ensure_emit_for(64);
169174
let fast_mem_start = block_asm.get_cursor_offset();
170175

171176
block_asm.ldr2(Reg::R1, (imm_addr & !(0xF0000000 | (size as u32 - 1))) + self.cpu.mmu_tcm_addr() as u32);
172177

173-
block_asm.guest_inst_metadata(
174-
self.jit_buf.insts_cycle_counts[inst_index],
175-
&self.jit_buf.insts[inst_index],
176-
fast_mem_start,
177-
value_reg,
178-
dirty_guest_regs,
179-
);
178+
if consider_slow_mem {
179+
block_asm.guest_inst_metadata(
180+
self.jit_buf.insts_cycle_counts[inst_index],
181+
&self.jit_buf.insts[inst_index],
182+
fast_mem_start,
183+
value_reg,
184+
dirty_guest_regs,
185+
);
186+
}
180187
let mem_operand = Reg::R1.into();
181188
func(block_asm, value_reg, &mem_operand);
182189
let shift = (imm_addr & 0x3) << 3;
@@ -187,6 +194,10 @@ impl JitAsm<'_> {
187194
func(block_asm, next_value_reg, &(Reg::R1, 4).into());
188195
}
189196

197+
if !consider_slow_mem {
198+
return;
199+
}
200+
190201
fast_mem_start
191202
} else {
192203
let op1_mapped = block_asm.get_guest_map(op1);

0 commit comments

Comments
 (0)