From af111c599297b3c4035ccdaafcae424f473cb2c3 Mon Sep 17 00:00:00 2001 From: Mwa Date: Fri, 20 Mar 2026 19:30:00 +0100 Subject: [PATCH] minor interupt on halt responsivity improvement and final Cargo.toml args --- .cargo/config.toml | 2 ++ Cargo.toml | 3 ++- simu/src/cpu.rs | 11 +++++++++-- simu/src/main.rs | 17 ++++++----------- 4 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..03f4879 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-Ctarget-cpu=native"] diff --git a/Cargo.toml b/Cargo.toml index 6388c27..e5a79c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,5 @@ resolver = "3" members = ["simu","asm","bitmap_to_asm"] [profile.release] -debug = "line-tables-only" +opt-level = 2 +# panic = "abort" diff --git a/simu/src/cpu.rs b/simu/src/cpu.rs index 410f2fb..1f7eb91 100644 --- a/simu/src/cpu.rs +++ b/simu/src/cpu.rs @@ -2,7 +2,7 @@ use crate::wait::WaitOnAtomic; #[cfg(feature = "debug")] use std::collections::HashMap; use std::{ - hint::{likely, unlikely, unreachable_unchecked}, + hint::{cold_path, likely, unlikely, unreachable_unchecked}, io::Read, mem::transmute, ops::{Index, IndexMut}, @@ -518,6 +518,7 @@ impl Computer { (&SHARED.external_enabled_interupts) .store(self[reg1], std::sync::atomic::Ordering::Relaxed); } else { + cold_path(); self.serve_interupt(InteruptKind::IllegalOpcode, [next_opcode]); } } @@ -563,6 +564,7 @@ impl Computer { } //guaranted by the inequality and is multiple of 4 _ => { + cold_path(); self.serve_interupt( InteruptKind::IllegalOpcode, [next_opcode], @@ -612,6 +614,7 @@ impl Computer { println!("awaiting interupt..."); } SHARED.external_interupts.wait(0); + return; } self.pc = ((addr + self.pc as u32) & 0x1FFF_FFFF) as usize; } @@ -729,7 +732,11 @@ impl Computer { kind, [rx.0.into(), self[ry], self.resolve(op2), opcode], ), - InteruptKind::IllegalOpcode => self.serve_interupt(kind, [next_opcode]), + InteruptKind::IllegalOpcode => { + cold_path(); + + self.serve_interupt(kind, [next_opcode]) + } _ => unsafe { unreachable_unchecked() }, } } diff --git a/simu/src/main.rs b/simu/src/main.rs index 74bc09a..105a301 100644 --- a/simu/src/main.rs +++ b/simu/src/main.rs @@ -1,9 +1,4 @@ -#![feature( - likely_unlikely, - widening_mul, - sync_unsafe_cell, - int_lowest_highest_one -)] +#![feature(likely_unlikely, widening_mul, int_lowest_highest_one)] #![deny(clippy::all)] use std::env::args; @@ -68,8 +63,9 @@ impl<'a> ApplicationHandler for App<'a> { let size = window.inner_size(); let surface_texture = SurfaceTexture::new(size.width, size.height, window); let pix = PixelsBuilder::new(WIDTH, HEIGHT, surface_texture) - .clear_color(Color::BLACK) - .blend_state(BlendState::REPLACE).build() ; + .clear_color(Color::BLACK) + .blend_state(BlendState::REPLACE) + .build(); self.pixels = Some(pix.unwrap()); } @@ -212,10 +208,9 @@ impl<'a> ApplicationHandler for App<'a> { for (addr, ubgr) in cpu::SHARED.screen_buf.iter().enumerate() { let raw = ubgr.load(std::sync::atomic::Ordering::Relaxed); #[cfg(not(feature = "rgba"))] - let rgba: [u8;4] = raw.to_le_bytes(); + let rgba: [u8; 4] = raw.to_le_bytes(); #[cfg(feature = "rgba")] - let rgba = - raw.to_be_bytes(); + let rgba = raw.to_be_bytes(); for i in 0..4 { screen[addr * 4 + i] = rgba[i]; }