mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
wasm: improve debug logging
This commit is contained in:
parent
6de8892e88
commit
5cce24bc8f
3 changed files with 16 additions and 7 deletions
|
@ -7,7 +7,7 @@ use roc_collections::all::MutMap;
|
|||
use roc_module::ident::Ident;
|
||||
use roc_module::low_level::{LowLevel, LowLevelWrapperType};
|
||||
use roc_module::symbol::{Interns, Symbol};
|
||||
use roc_mono::code_gen_help::{CodeGenHelp, REFCOUNT_MAX};
|
||||
use roc_mono::code_gen_help::{CodeGenHelp, HelperOp, REFCOUNT_MAX};
|
||||
use roc_mono::ir::{
|
||||
BranchInfo, CallType, Expr, JoinPointId, ListLiteralElement, Literal, ModifyRc, Param, Proc,
|
||||
ProcLayout, Stmt,
|
||||
|
@ -270,6 +270,13 @@ impl<'a> WasmBackend<'a> {
|
|||
self.storage.stack_frame_size,
|
||||
self.storage.stack_frame_pointer,
|
||||
);
|
||||
|
||||
if DEBUG_LOG_SETTINGS.storage_map {
|
||||
println!("\nStorage:");
|
||||
for (sym, storage) in self.storage.symbol_storage_map.iter() {
|
||||
println!("{:?} => {:?}", sym, storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn append_proc_debug_name(&mut self, sym: Symbol) {
|
||||
|
|
|
@ -253,6 +253,7 @@ pub struct WasmDebugLogSettings {
|
|||
helper_procs_ir: bool,
|
||||
let_stmt_ir: bool,
|
||||
instructions: bool,
|
||||
storage_map: bool,
|
||||
pub keep_test_binary: bool,
|
||||
}
|
||||
|
||||
|
@ -262,5 +263,6 @@ pub const DEBUG_LOG_SETTINGS: WasmDebugLogSettings = WasmDebugLogSettings {
|
|||
helper_procs_ir: false && cfg!(debug_assertions),
|
||||
let_stmt_ir: false && cfg!(debug_assertions),
|
||||
instructions: false && cfg!(debug_assertions),
|
||||
storage_map: false && cfg!(debug_assertions),
|
||||
keep_test_binary: false && cfg!(debug_assertions),
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ struct VmBlock<'a> {
|
|||
|
||||
impl std::fmt::Debug for VmBlock<'_> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!("{:?}", self.opcode))
|
||||
f.write_fmt(format_args!("{:?} {:?}", self.opcode, self.value_stack))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ impl<'a> CodeBuilder<'a> {
|
|||
log_instruction!(
|
||||
"{:10}\t\t{:?}",
|
||||
format!("{:?}", opcode),
|
||||
self.current_stack()
|
||||
self.vm_block_stack
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -635,7 +635,7 @@ impl<'a> CodeBuilder<'a> {
|
|||
"{:10}\t{}\t{:?}",
|
||||
format!("{:?}", opcode),
|
||||
immediate,
|
||||
self.current_stack()
|
||||
self.vm_block_stack
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -648,7 +648,7 @@ impl<'a> CodeBuilder<'a> {
|
|||
format!("{:?}", opcode),
|
||||
align,
|
||||
offset,
|
||||
self.current_stack()
|
||||
self.vm_block_stack
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ impl<'a> CodeBuilder<'a> {
|
|||
"{:10}\t{}\t{:?}",
|
||||
format!("{:?}", CALL),
|
||||
function_index,
|
||||
self.current_stack()
|
||||
self.vm_block_stack
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,7 @@ impl<'a> CodeBuilder<'a> {
|
|||
"{:10}\t{}\t{:?}",
|
||||
format!("{:?}", opcode),
|
||||
x,
|
||||
self.current_stack()
|
||||
self.vm_block_stack
|
||||
);
|
||||
}
|
||||
pub fn i32_const(&mut self, x: i32) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue