mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
wasm_interp: bring back debug output
This commit is contained in:
parent
74bb8cc843
commit
06c675703a
2 changed files with 18 additions and 14 deletions
|
@ -10,7 +10,7 @@ use roc_wasm_module::{Value, ValueType};
|
||||||
|
|
||||||
use crate::call_stack::CallStack;
|
use crate::call_stack::CallStack;
|
||||||
use crate::value_stack::ValueStack;
|
use crate::value_stack::ValueStack;
|
||||||
use crate::{Error, ImportDispatcher};
|
use crate::{pc_to_fn_index, Error, ImportDispatcher};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
@ -459,7 +459,7 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut action = Action::Continue;
|
let mut action = Action::Continue;
|
||||||
// let mut implicit_return = false;
|
let mut implicit_return = false;
|
||||||
|
|
||||||
match op_code {
|
match op_code {
|
||||||
UNREACHABLE => {
|
UNREACHABLE => {
|
||||||
|
@ -517,7 +517,7 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
|
||||||
if self.blocks.len() == self.outermost_block as usize {
|
if self.blocks.len() == self.outermost_block as usize {
|
||||||
// implicit RETURN at end of function
|
// implicit RETURN at end of function
|
||||||
action = self.do_return();
|
action = self.do_return();
|
||||||
// implicit_return = true;
|
implicit_return = true;
|
||||||
} else {
|
} else {
|
||||||
self.blocks.pop().unwrap();
|
self.blocks.pop().unwrap();
|
||||||
}
|
}
|
||||||
|
@ -1518,17 +1518,17 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if let Some(debug_string) = &self.debug_string {
|
if let Some(debug_string) = &self.debug_string {
|
||||||
// let base = self.call_stack.value_stack_base();
|
let base = self.call_stack.value_stack_base();
|
||||||
// let slice = self.value_stack.get_slice(base as usize);
|
let slice = self.value_stack.get_slice(base as usize);
|
||||||
// eprintln!("{:06x} {:17} {:?}", file_offset, debug_string, slice);
|
eprintln!("{:06x} {:17} {:?}", file_offset, debug_string, slice);
|
||||||
// if op_code == RETURN || (op_code == END && implicit_return) {
|
if op_code == RETURN || (op_code == END && implicit_return) {
|
||||||
// let fn_index = pc_to_fn_index(self.program_counter, module);
|
let fn_index = pc_to_fn_index(self.program_counter, module);
|
||||||
// eprintln!("returning to function {}\n", fn_index);
|
eprintln!("returning to function {}\n", fn_index);
|
||||||
// } else if op_code == CALL || op_code == CALLINDIRECT {
|
} else if op_code == CALL || op_code == CALLINDIRECT {
|
||||||
// eprintln!();
|
eprintln!();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
Ok(action)
|
Ok(action)
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,10 @@ impl<'a> ValueStack<'a> {
|
||||||
pub(crate) fn truncate(&mut self, depth: usize) {
|
pub(crate) fn truncate(&mut self, depth: usize) {
|
||||||
self.values.truncate(depth)
|
self.values.truncate(depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_slice(&mut self, from: usize) -> &[Value] {
|
||||||
|
&self.values[from..]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for ValueStack<'_> {
|
impl Debug for ValueStack<'_> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue