PEAK optimisation. 420mips. it's not getting much faster tbh.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#![feature(likely_unlikely)]
|
||||
#![feature(inherent_associated_types)]
|
||||
|
||||
pub mod args;
|
||||
pub mod config;
|
||||
|
||||
@@ -158,7 +158,7 @@ impl<Mem: RandomAccessMemory> Emulator<Mem> {
|
||||
#[cold]
|
||||
fn boot(&mut self) -> Result<(), String> {
|
||||
if !(self.__io_configured && self.__mmap_configured) {
|
||||
return Err("Processor not configured".to_string());
|
||||
return Err("Emulator<Mem> not configured".to_string());
|
||||
}
|
||||
|
||||
if let Some(map) = &self.memory_map {
|
||||
@@ -207,6 +207,10 @@ impl<Mem: RandomAccessMemory> Emulator<Mem> {
|
||||
let mut time = Instant::now();
|
||||
|
||||
'emu: loop {
|
||||
// IMPORTANT
|
||||
// do not change anything about this loop. it's fully optimised afaik.
|
||||
// Check for commands or hardware Interrupts every 32k cycles
|
||||
if unlikely(self.internal_state.clock & 0x7FFF == 0) {
|
||||
// Update UI thread (roughly every 512k cycles targeting 60 UPS)
|
||||
if unlikely(self.internal_state.clock & 0x7FFFF == 0) {
|
||||
if self.shared_state.update_req.load(Ordering::Relaxed) {
|
||||
@@ -214,9 +218,7 @@ impl<Mem: RandomAccessMemory> Emulator<Mem> {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for commands or hardware Interrupts every 32k cycles
|
||||
if self.internal_state.clock % 0x7FFF == 0 {
|
||||
if self.shared_state.running.load(Ordering::Relaxed) == false {
|
||||
if unlikely(!self.shared_state.running.load(Ordering::Relaxed)) {
|
||||
self.idle_wait();
|
||||
}
|
||||
|
||||
@@ -260,6 +262,7 @@ impl<Mem: RandomAccessMemory> Emulator<Mem> {
|
||||
}
|
||||
|
||||
self.mut_reg(Register::Pcx).add_assign(4);
|
||||
|
||||
self.execute(Instruction(instruction));
|
||||
|
||||
// Check if executing the interrupt caused a fault.
|
||||
|
||||
Reference in New Issue
Block a user