wasm_interp: bring back debug output

This commit is contained in:
Brian Carroll 2022-12-10 00:50:52 +00:00
parent 74bb8cc843
commit 06c675703a
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
2 changed files with 18 additions and 14 deletions

View file

@ -10,7 +10,7 @@ use roc_wasm_module::{Value, ValueType};
use crate::call_stack::CallStack;
use crate::value_stack::ValueStack;
use crate::{Error, ImportDispatcher};
use crate::{pc_to_fn_index, Error, ImportDispatcher};
#[derive(Debug)]
pub enum Action {
@ -459,7 +459,7 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
}
let mut action = Action::Continue;
// let mut implicit_return = false;
let mut implicit_return = false;
match op_code {
UNREACHABLE => {
@ -517,7 +517,7 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
if self.blocks.len() == self.outermost_block as usize {
// implicit RETURN at end of function
action = self.do_return();
// implicit_return = true;
implicit_return = true;
} else {
self.blocks.pop().unwrap();
}
@ -1518,17 +1518,17 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
}
}
// if let Some(debug_string) = &self.debug_string {
// let base = self.call_stack.value_stack_base();
// let slice = self.value_stack.get_slice(base as usize);
// eprintln!("{:06x} {:17} {:?}", file_offset, debug_string, slice);
// if op_code == RETURN || (op_code == END && implicit_return) {
// let fn_index = pc_to_fn_index(self.program_counter, module);
// eprintln!("returning to function {}\n", fn_index);
// } else if op_code == CALL || op_code == CALLINDIRECT {
// eprintln!();
// }
// }
if let Some(debug_string) = &self.debug_string {
let base = self.call_stack.value_stack_base();
let slice = self.value_stack.get_slice(base as usize);
eprintln!("{:06x} {:17} {:?}", file_offset, debug_string, slice);
if op_code == RETURN || (op_code == END && implicit_return) {
let fn_index = pc_to_fn_index(self.program_counter, module);
eprintln!("returning to function {}\n", fn_index);
} else if op_code == CALL || op_code == CALLINDIRECT {
eprintln!();
}
}
Ok(action)
}