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