From 5ae9fcbd384c9ac712e5f060cd86353e213c560b Mon Sep 17 00:00:00 2001 From: dingusdev <52434309+dingusdev@users.noreply.github.com> Date: Wed, 18 Sep 2024 07:15:14 -0700 Subject: [PATCH] More fixes 4% speedup reported in the benchmark Co-Authored-By: joevt <950609+joevt@users.noreply.github.com> --- cpu/ppc/ppcexec.cpp | 14 +++++++------- cpu/ppc/ppcmmu.cpp | 12 ++++++------ cpu/ppc/ppcmmu.h | 2 +- debugger/debugger.cpp | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cpu/ppc/ppcexec.cpp b/cpu/ppc/ppcexec.cpp index 98e100f..5bff6bd 100644 --- a/cpu/ppc/ppcexec.cpp +++ b/cpu/ppc/ppcexec.cpp @@ -390,7 +390,7 @@ static void ppc_exec_inner() eb_start = ppc_next_instruction_address; if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) { pc_real += (int)eb_start - (int)ppc_state.pc; - ppc_set_cur_instruction(pc_real); + instr = ppc_set_cur_instruction(pc_real); } else { page_start = eb_start & PPC_PAGE_MASK; eb_end = page_start + PPC_PAGE_SIZE - 1; @@ -401,8 +401,8 @@ static void ppc_exec_inner() exec_flags = 0; } else { ppc_state.pc += 4; - pc_real += 4; - ppc_set_cur_instruction(pc_real); + pc_real += 4; + instr = ppc_set_cur_instruction(pc_real); } } } @@ -485,7 +485,7 @@ static void ppc_exec_until_inner(const uint32_t goal_addr) eb_start = ppc_next_instruction_address; if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) { pc_real += (int)eb_start - (int)ppc_state.pc; - ppc_set_cur_instruction(pc_real); + instr = ppc_set_cur_instruction(pc_real); } else { page_start = eb_start & PPC_PAGE_MASK; eb_end = page_start + PPC_PAGE_SIZE - 1; @@ -497,7 +497,7 @@ static void ppc_exec_until_inner(const uint32_t goal_addr) } else { ppc_state.pc += 4; pc_real += 4; - ppc_set_cur_instruction(pc_real); + instr = ppc_set_cur_instruction(pc_real); } if (ppc_state.pc == goal_addr) @@ -556,7 +556,7 @@ static void ppc_exec_dbg_inner(const uint32_t start_addr, const uint32_t size) eb_start = ppc_next_instruction_address; if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) { pc_real += (int)eb_start - (int)ppc_state.pc; - ppc_set_cur_instruction(pc_real); + instr = ppc_set_cur_instruction(pc_real); } else { page_start = eb_start & PPC_PAGE_MASK; eb_end = page_start + PPC_PAGE_SIZE - 1; @@ -568,7 +568,7 @@ static void ppc_exec_dbg_inner(const uint32_t start_addr, const uint32_t size) } else { ppc_state.pc += 4; pc_real += 4; - ppc_set_cur_instruction(pc_real); + instr = ppc_set_cur_instruction(pc_real); } } } diff --git a/cpu/ppc/ppcmmu.cpp b/cpu/ppc/ppcmmu.cpp index bc71d97..05d9d35 100644 --- a/cpu/ppc/ppcmmu.cpp +++ b/cpu/ppc/ppcmmu.cpp @@ -1425,7 +1425,7 @@ public: }; #endif -uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t instr, uint32_t size) { +uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size) { uint32_t save_dsisr, save_dar; uint64_t ret_val; @@ -1437,19 +1437,19 @@ uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t instr, uint32_t size) { try { switch (size) { case 1: - ret_val = mmu_read_vmem(virt_addr, instr); + ret_val = mmu_read_vmem(virt_addr, 0); break; case 2: - ret_val = mmu_read_vmem(virt_addr, instr); + ret_val = mmu_read_vmem(virt_addr, 0); break; case 4: - ret_val = mmu_read_vmem(virt_addr, instr); + ret_val = mmu_read_vmem(virt_addr, 0); break; case 8: - ret_val = mmu_read_vmem(virt_addr, instr); + ret_val = mmu_read_vmem(virt_addr, 0); break; default: - ret_val = mmu_read_vmem(virt_addr, instr); + ret_val = mmu_read_vmem(virt_addr, 0); } } catch (std::invalid_argument& exc) { /* restore MMU-related CPU state */ diff --git a/cpu/ppc/ppcmmu.h b/cpu/ppc/ppcmmu.h index 7dfaaf7..0035e1c 100644 --- a/cpu/ppc/ppcmmu.h +++ b/cpu/ppc/ppcmmu.h @@ -125,7 +125,7 @@ extern void mmu_change_mode(void); extern void mmu_pat_ctx_changed(); extern void tlb_flush_entry(uint32_t ea); -extern uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t instr, uint32_t size); +extern uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size); uint8_t *mmu_translate_imem(uint32_t vaddr, uint32_t *paddr = nullptr); bool mmu_translate_dbg(uint32_t guest_va, uint32_t &guest_pa); diff --git a/debugger/debugger.cpp b/debugger/debugger.cpp index 3a4b165..55f47bb 100644 --- a/debugger/debugger.cpp +++ b/debugger/debugger.cpp @@ -124,7 +124,7 @@ static uint32_t disasm_68k(uint32_t count, uint32_t address) { for (; power_on && count > 0; count--) { /* prefetch opcode bytes (a 68k instruction can occupy 2...10 bytes) */ for (int i = 0; i < sizeof(code); i++) { - code[i] = mem_read_dbg(address + i, 0, 1); + code[i] = mem_read_dbg(address + i, 1); } const uint8_t *code_ptr = code; @@ -174,7 +174,7 @@ void exec_single_68k(uint32_t instr) /* calculate address of the current opcode table entry as follows: get_word(68k_PC) * entry_size + table_base */ - cur_instr_tab_entry = mmu_read_vmem(((cur_68k_pc) * 8 + emu_table_virt), instr); + cur_instr_tab_entry = mmu_read_vmem(cur_68k_pc, 0) * 8 + emu_table_virt; /* grab the PPC PC too */ ppc_pc = get_reg(string("PC")); @@ -314,7 +314,7 @@ static void dump_mem(string& params) { cout << endl; chars_per_line = 0; } - val = mem_read_dbg(addr, 0, cell_size); + val = mem_read_dbg(addr, cell_size); if (is_char) { cout << (char)val; chars_per_line += cell_size;