adjust interrupt handling
we used to spend ~5.8% of the time on getting the next value of the 0..INSTRUCTIONS_PER_INTERRUPT_POLL iterator increment on Wrapping<u8> now only takes ~0.58 of the time
This commit is contained in:
@@ -77,8 +77,6 @@ macro_rules! push_cell {
|
|||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
static INSTRUCTIONS_PER_INTERRUPT_POLL: usize = 256;
|
|
||||||
|
|
||||||
impl MachineState {
|
impl MachineState {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn compare(&mut self) -> CallResult {
|
fn compare(&mut self) -> CallResult {
|
||||||
@@ -1541,8 +1539,13 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn verify_attr_dispatch_loop(&mut self) -> Option<std::process::ExitCode> {
|
fn verify_attr_dispatch_loop(&mut self) -> Option<std::process::ExitCode> {
|
||||||
|
let mut interrupt_counter = std::num::Wrapping(0u8);
|
||||||
'outer: loop {
|
'outer: loop {
|
||||||
for _ in 0..INSTRUCTIONS_PER_INTERRUPT_POLL {
|
loop {
|
||||||
|
interrupt_counter += 1;
|
||||||
|
if interrupt_counter.0 == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
match self.code[self.machine_st.p] {
|
match self.code[self.machine_st.p] {
|
||||||
Instruction::BreakFromDispatchLoop => {
|
Instruction::BreakFromDispatchLoop => {
|
||||||
break 'outer;
|
break 'outer;
|
||||||
@@ -1611,8 +1614,14 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn dispatch_loop(&mut self) -> std::process::ExitCode {
|
pub(super) fn dispatch_loop(&mut self) -> std::process::ExitCode {
|
||||||
|
let mut interrupt_counter = std::num::Wrapping(0u8);
|
||||||
'outer: loop {
|
'outer: loop {
|
||||||
for _ in 0..INSTRUCTIONS_PER_INTERRUPT_POLL {
|
loop {
|
||||||
|
interrupt_counter += 1;
|
||||||
|
if interrupt_counter.0 == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
match &self.code[self.machine_st.p] {
|
match &self.code[self.machine_st.p] {
|
||||||
&Instruction::BreakFromDispatchLoop => {
|
&Instruction::BreakFromDispatchLoop => {
|
||||||
break 'outer;
|
break 'outer;
|
||||||
|
|||||||
Reference in New Issue
Block a user