minor interupt on halt responsivity improvement and final Cargo.toml args

This commit is contained in:
Mwa
2026-03-20 19:30:00 +01:00
parent b5962c6b50
commit af111c5992
4 changed files with 19 additions and 14 deletions

2
.cargo/config.toml Normal file
View File

@@ -0,0 +1,2 @@
[build]
rustflags = ["-Ctarget-cpu=native"]

View File

@@ -3,4 +3,5 @@ resolver = "3"
members = ["simu","asm","bitmap_to_asm"] members = ["simu","asm","bitmap_to_asm"]
[profile.release] [profile.release]
debug = "line-tables-only" opt-level = 2
# panic = "abort"

View File

@@ -2,7 +2,7 @@ use crate::wait::WaitOnAtomic;
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
use std::collections::HashMap; use std::collections::HashMap;
use std::{ use std::{
hint::{likely, unlikely, unreachable_unchecked}, hint::{cold_path, likely, unlikely, unreachable_unchecked},
io::Read, io::Read,
mem::transmute, mem::transmute,
ops::{Index, IndexMut}, ops::{Index, IndexMut},
@@ -518,6 +518,7 @@ impl Computer {
(&SHARED.external_enabled_interupts) (&SHARED.external_enabled_interupts)
.store(self[reg1], std::sync::atomic::Ordering::Relaxed); .store(self[reg1], std::sync::atomic::Ordering::Relaxed);
} else { } else {
cold_path();
self.serve_interupt(InteruptKind::IllegalOpcode, [next_opcode]); self.serve_interupt(InteruptKind::IllegalOpcode, [next_opcode]);
} }
} }
@@ -563,6 +564,7 @@ impl Computer {
} }
//guaranted by the inequality and is multiple of 4 //guaranted by the inequality and is multiple of 4
_ => { _ => {
cold_path();
self.serve_interupt( self.serve_interupt(
InteruptKind::IllegalOpcode, InteruptKind::IllegalOpcode,
[next_opcode], [next_opcode],
@@ -612,6 +614,7 @@ impl Computer {
println!("awaiting interupt..."); println!("awaiting interupt...");
} }
SHARED.external_interupts.wait(0); SHARED.external_interupts.wait(0);
return;
} }
self.pc = ((addr + self.pc as u32) & 0x1FFF_FFFF) as usize; self.pc = ((addr + self.pc as u32) & 0x1FFF_FFFF) as usize;
} }
@@ -729,7 +732,11 @@ impl Computer {
kind, kind,
[rx.0.into(), self[ry], self.resolve(op2), opcode], [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() }, _ => unsafe { unreachable_unchecked() },
} }
} }

View File

@@ -1,9 +1,4 @@
#![feature( #![feature(likely_unlikely, widening_mul, int_lowest_highest_one)]
likely_unlikely,
widening_mul,
sync_unsafe_cell,
int_lowest_highest_one
)]
#![deny(clippy::all)] #![deny(clippy::all)]
use std::env::args; use std::env::args;
@@ -68,8 +63,9 @@ impl<'a> ApplicationHandler for App<'a> {
let size = window.inner_size(); let size = window.inner_size();
let surface_texture = SurfaceTexture::new(size.width, size.height, window); let surface_texture = SurfaceTexture::new(size.width, size.height, window);
let pix = PixelsBuilder::new(WIDTH, HEIGHT, surface_texture) let pix = PixelsBuilder::new(WIDTH, HEIGHT, surface_texture)
.clear_color(Color::BLACK) .clear_color(Color::BLACK)
.blend_state(BlendState::REPLACE).build() ; .blend_state(BlendState::REPLACE)
.build();
self.pixels = Some(pix.unwrap()); 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() { for (addr, ubgr) in cpu::SHARED.screen_buf.iter().enumerate() {
let raw = ubgr.load(std::sync::atomic::Ordering::Relaxed); let raw = ubgr.load(std::sync::atomic::Ordering::Relaxed);
#[cfg(not(feature = "rgba"))] #[cfg(not(feature = "rgba"))]
let rgba: [u8;4] = raw.to_le_bytes(); let rgba: [u8; 4] = raw.to_le_bytes();
#[cfg(feature = "rgba")] #[cfg(feature = "rgba")]
let rgba = let rgba = raw.to_be_bytes();
raw.to_be_bytes();
for i in 0..4 { for i in 0..4 {
screen[addr * 4 + i] = rgba[i]; screen[addr * 4 + i] = rgba[i];
} }