@@ -587,7 +587,6 @@ pub struct MipsExecutor<T: Tlb, C: MipsCache> {
587587 local_cycles : u64 ,
588588 /// Cached external interrupt word — reloaded every 16 instructions.
589589 cached_pending : u64 ,
590- interrupt_check_counter : u8 ,
591590}
592591
593592// ---- translate_fn wrappers (one per privilege × addressing-mode combination) ---------------
@@ -781,7 +780,6 @@ For R4000SC/MC CPUs:
781780 fpr_write_w : crate :: mips_core:: write_fpr_w_fr0,
782781 local_cycles : 0 ,
783782 cached_pending : 0 ,
784- interrupt_check_counter : 0 ,
785783 } ;
786784
787785 executor. rebind_atomic_ptrs ( ) ;
@@ -893,23 +891,22 @@ For R4000SC/MC CPUs:
893891 /// Flush local cycle counter to the shared atomic.
894892 #[ inline( always) ]
895893 pub fn flush_cycles ( & mut self ) {
896- if self . local_cycles > 0 {
897- unsafe { & * self . cycles_ptr } . fetch_add ( self . local_cycles , Ordering :: Relaxed ) ;
898- self . local_cycles = 0 ;
899- }
894+ unsafe { & * self . cycles_ptr } . store ( self . local_cycles , Ordering :: Relaxed ) ;
900895 }
901896
902897 pub fn step ( & mut self ) -> ExecStatus {
903898 // Increment local cycle counter (flushed to atomic by outer loop)
904- self . local_cycles += 1 ;
899+ self . local_cycles = self . local_cycles . wrapping_add ( 1 ) ;
905900
901+ /*
906902 // Reload external interrupt state every 16 instructions
907- self . interrupt_check_counter = self . interrupt_check_counter . wrapping_sub ( 1 ) ;
908- if self . interrupt_check_counter == 0 {
909- self . interrupt_check_counter = 16 ;
903+ if self.local_cycles & 0xF == 0 {
910904 self.cached_pending = unsafe { &*self.interrupts_ptr }.load(Ordering::Relaxed);
911905 }
912906 let pending = self.cached_pending;
907+ */
908+ // this seems to be a wash or slightly better without a branch, relaxed atomic loads are essentially MOV
909+ let pending = unsafe { & * self . interrupts_ptr } . load ( Ordering :: Relaxed ) ;
913910
914911 let pc = self . core . pc ;
915912 #[ cfg( not( feature = "lightning" ) ) ]
0 commit comments