Add tracing.
This commit is contained in:
parent
20ea31c9dd
commit
055193e926
|
@ -14,7 +14,6 @@ pub struct InterpContext {
|
|||
memories: PerEntity<Memory, InterpMemory>,
|
||||
tables: PerEntity<Table, InterpTable>,
|
||||
globals: PerEntity<Global, ConstVal>,
|
||||
trace_log: Vec<(usize, Vec<ConstVal>)>,
|
||||
}
|
||||
|
||||
type MultiVal = SmallVec<[ConstVal; 2]>;
|
||||
|
@ -73,7 +72,6 @@ impl InterpContext {
|
|||
memories,
|
||||
tables,
|
||||
globals,
|
||||
trace_log: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +189,7 @@ impl InterpContext {
|
|||
multivalue[0]
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
self.trace_log.push((id, args));
|
||||
eprintln!("TRACE: {}: {:?}", id, &args[..]);
|
||||
smallvec![]
|
||||
}
|
||||
&ValueDef::None | &ValueDef::Placeholder(..) | &ValueDef::BlockParam(..) => {
|
||||
|
|
|
@ -5,3 +5,4 @@ pub mod dom_pass;
|
|||
pub mod empty_blocks;
|
||||
pub mod maxssa;
|
||||
pub mod resolve_aliases;
|
||||
pub mod trace;
|
||||
|
|
18
src/passes/trace.rs
Normal file
18
src/passes/trace.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
//! Trace-insertion pass.
|
||||
|
||||
use crate::entity::EntityRef;
|
||||
use crate::ir::*;
|
||||
|
||||
pub fn run(body: &mut FunctionBody) {
|
||||
for (block, data) in body.blocks.entries_mut() {
|
||||
let value = ValueDef::Trace(
|
||||
block.index(),
|
||||
data.params
|
||||
.iter()
|
||||
.map(|&(_, param)| param)
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
let value = body.values.push(value);
|
||||
data.insts.insert(0, value);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue