Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions crates/inspector/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ where
// Call Inspector step.
inspector.step(interpreter, context);
if interpreter.bytecode.is_end() {
inspector.step_end(interpreter, context);
break;
}

Expand All @@ -215,18 +216,18 @@ where
log_num = new_log;
}

// if loops is ending, break the loop so we can revert to the previous pointer and then call step_end.
if interpreter.bytecode.is_end() {
break;
}
// // if loops is ending, break the loop so we can revert to the previous pointer and then call step_end.
// if interpreter.bytecode.is_end() {
// break;
// }

// Call step_end.
inspector.step_end(interpreter, context);
}

interpreter.bytecode.revert_to_previous_pointer();
// call step_end again to handle the last instruction
inspector.step_end(interpreter, context);
// // call step_end again to handle the last instruction
// inspector.step_end(interpreter, context);

let next_action = interpreter.take_next_action();

Expand Down
30 changes: 18 additions & 12 deletions crates/interpreter/src/interpreter/ext_bytecode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{Immediates, Jumps, LegacyBytecode};
use crate::{interpreter_types::LoopControl, InterpreterAction};
use bytecode::{utils::read_u16, Bytecode};
use core::{ops::Deref, ptr};
use core::ops::Deref;
use primitives::B256;

#[cfg(feature = "serde")]
Expand All @@ -17,9 +17,11 @@ pub struct ExtBytecode {
/// The base bytecode.
base: Bytecode,
/// The previous instruction pointer.
previous_pointer: Option<*const u8>,
//previous_pointer: Option<*const u8>,
/// The current instruction pointer.
instruction_pointer: *const u8,
/// End flag that stop execution.
end_flag: bool,
}

impl Deref for ExtBytecode {
Expand Down Expand Up @@ -47,7 +49,8 @@ impl ExtBytecode {
instruction_pointer,
bytecode_hash: None,
action: None,
previous_pointer: None,
//previous_pointer: None,
end_flag: false,
}
}

Expand All @@ -59,7 +62,8 @@ impl ExtBytecode {
instruction_pointer,
bytecode_hash: Some(hash),
action: None,
previous_pointer: None,
//previous_pointer: None,
end_flag: false,
}
}

Expand All @@ -79,23 +83,25 @@ impl ExtBytecode {
impl LoopControl for ExtBytecode {
#[inline]
fn is_end(&self) -> bool {
self.instruction_pointer.is_null()
self.end_flag
}

#[inline]
fn revert_to_previous_pointer(&mut self) {
if let Some(previous_pointer) = self.previous_pointer {
self.instruction_pointer = previous_pointer;
}
self.end_flag = false;
// if let Some(previous_pointer) = self.previous_pointer {
// self.instruction_pointer = previous_pointer;
// }
}

#[inline]
fn set_action(&mut self, action: InterpreterAction) {
self.action = Some(action);
self.previous_pointer = Some(core::mem::replace(
&mut self.instruction_pointer,
ptr::null(),
));
self.end_flag = true;
// self.previous_pointer = Some(core::mem::replace(
// &mut self.instruction_pointer,
// ptr::null(),
// ));
}

#[inline]
Expand Down
Loading