From 870102d9ded26b0e38f9ccc238ec7ba8e3a78b13 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Sat, 25 Apr 2015 17:51:23 -0700 Subject: [PATCH] Fix I$ simulator hit count Also, improve performance by allowing the soft-ITLB to refill. --- riscv/mmu.cc | 3 ++- riscv/mmu.h | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/riscv/mmu.cc b/riscv/mmu.cc index e6bbbd4..8ebee60 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -67,7 +67,8 @@ void* mmu_t::refill_tlb(reg_t addr, reg_t bytes, bool store, bool fetch) else throw trap_load_access_fault(addr); } - if (unlikely(tracer.interested_in_range(pgbase, pgbase + PGSIZE, store, fetch))) + bool trace = tracer.interested_in_range(pgbase, pgbase + PGSIZE, store, fetch); + if (unlikely(!fetch && trace)) tracer.trace(paddr, bytes, store, fetch); else { diff --git a/riscv/mmu.h b/riscv/mmu.h index a8853d3..4ca9d0a 100644 --- a/riscv/mmu.h +++ b/riscv/mmu.h @@ -85,15 +85,16 @@ public: char* iaddr = (char*)translate(addr, 1, false, true); insn_bits_t insn = *(uint16_t*)iaddr; + int length = insn_length(insn); - if (likely(insn_length(insn) == 4)) { + if (likely(length == 4)) { if (likely(addr % PGSIZE < PGSIZE-2)) insn |= (insn_bits_t)*(int16_t*)(iaddr + 2) << 16; else insn |= (insn_bits_t)*(int16_t*)translate(addr + 2, 1, false, true) << 16; - } else if (insn_length(insn) == 2) { + } else if (length == 2) { insn = (int16_t)insn; - } else if (insn_length(insn) == 6) { + } else if (length == 6) { insn |= (insn_bits_t)*(int16_t*)translate(addr + 4, 1, false, true) << 32; insn |= (insn_bits_t)*(uint16_t*)translate(addr + 2, 1, false, true) << 16; } else { @@ -111,7 +112,7 @@ public: if (!tracer.empty() && tracer.interested_in_range(paddr, paddr + 1, false, true)) { icache[idx].tag = -1; - tracer.trace(paddr, 1, false, true); + tracer.trace(paddr, length, false, true); } return &icache[idx]; } -- 2.30.2