Fix performance bug when CSR accesses are common
authorAndrew Waterman <waterman@cs.berkeley.edu>
Sun, 31 May 2015 22:47:11 +0000 (15:47 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 1 Jun 2015 01:29:45 +0000 (18:29 -0700)
processor_t::step was returning without doing much work, causing the HTIF
to be ticked far more often than necessary.

riscv/processor.cc

index b8e848bd61cbeae8eb1a9e5423bb0ceaa66e1809..7162a393b30b407022922a1cff9fc45b48b1df8c 100644 (file)
@@ -280,6 +280,10 @@ void processor_t::step(size_t n)
   }
 
   update_timer(&state, instret);
+
+  // tail-recurse if we didn't execute as many instructions as we'd hoped
+  if (instret < n)
+    step(n - instret);
 }
 
 void processor_t::push_privilege_stack()