wasm: improve debug logging

This commit is contained in:
Brian Carroll 2022-04-07 11:53:10 +01:00
parent 6de8892e88
commit 5cce24bc8f
3 changed files with 16 additions and 7 deletions

View file

@ -7,7 +7,7 @@ use roc_collections::all::MutMap;
use roc_module::ident::Ident; use roc_module::ident::Ident;
use roc_module::low_level::{LowLevel, LowLevelWrapperType}; use roc_module::low_level::{LowLevel, LowLevelWrapperType};
use roc_module::symbol::{Interns, Symbol}; 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::{ use roc_mono::ir::{
BranchInfo, CallType, Expr, JoinPointId, ListLiteralElement, Literal, ModifyRc, Param, Proc, BranchInfo, CallType, Expr, JoinPointId, ListLiteralElement, Literal, ModifyRc, Param, Proc,
ProcLayout, Stmt, ProcLayout, Stmt,
@ -270,6 +270,13 @@ impl<'a> WasmBackend<'a> {
self.storage.stack_frame_size, self.storage.stack_frame_size,
self.storage.stack_frame_pointer, 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) { fn append_proc_debug_name(&mut self, sym: Symbol) {

View file

@ -253,6 +253,7 @@ pub struct WasmDebugLogSettings {
helper_procs_ir: bool, helper_procs_ir: bool,
let_stmt_ir: bool, let_stmt_ir: bool,
instructions: bool, instructions: bool,
storage_map: bool,
pub keep_test_binary: bool, pub keep_test_binary: bool,
} }
@ -262,5 +263,6 @@ pub const DEBUG_LOG_SETTINGS: WasmDebugLogSettings = WasmDebugLogSettings {
helper_procs_ir: false && cfg!(debug_assertions), helper_procs_ir: false && cfg!(debug_assertions),
let_stmt_ir: false && cfg!(debug_assertions), let_stmt_ir: false && cfg!(debug_assertions),
instructions: false && cfg!(debug_assertions), instructions: false && cfg!(debug_assertions),
storage_map: false && cfg!(debug_assertions),
keep_test_binary: false && cfg!(debug_assertions), keep_test_binary: false && cfg!(debug_assertions),
}; };

View file

@ -62,7 +62,7 @@ struct VmBlock<'a> {
impl std::fmt::Debug for VmBlock<'_> { impl std::fmt::Debug for VmBlock<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 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!( log_instruction!(
"{:10}\t\t{:?}", "{:10}\t\t{:?}",
format!("{:?}", opcode), format!("{:?}", opcode),
self.current_stack() self.vm_block_stack
); );
} }
@ -635,7 +635,7 @@ impl<'a> CodeBuilder<'a> {
"{:10}\t{}\t{:?}", "{:10}\t{}\t{:?}",
format!("{:?}", opcode), format!("{:?}", opcode),
immediate, immediate,
self.current_stack() self.vm_block_stack
); );
} }
@ -648,7 +648,7 @@ impl<'a> CodeBuilder<'a> {
format!("{:?}", opcode), format!("{:?}", opcode),
align, align,
offset, offset,
self.current_stack() self.vm_block_stack
); );
} }
@ -752,7 +752,7 @@ impl<'a> CodeBuilder<'a> {
"{:10}\t{}\t{:?}", "{:10}\t{}\t{:?}",
format!("{:?}", CALL), format!("{:?}", CALL),
function_index, function_index,
self.current_stack() self.vm_block_stack
); );
} }
@ -823,7 +823,7 @@ impl<'a> CodeBuilder<'a> {
"{:10}\t{}\t{:?}", "{:10}\t{}\t{:?}",
format!("{:?}", opcode), format!("{:?}", opcode),
x, x,
self.current_stack() self.vm_block_stack
); );
} }
pub fn i32_const(&mut self, x: i32) { pub fn i32_const(&mut self, x: i32) {