Fix max_stacksize DEBUG to use const

This commit is contained in:
Jeong YunWon 2022-08-11 06:14:42 +09:00
parent 6760d21399
commit c3b1400240

View file

@ -167,19 +167,22 @@ impl CodeInfo {
let mut startdepths = vec![u32::MAX; self.blocks.len()]; let mut startdepths = vec![u32::MAX; self.blocks.len()];
startdepths[0] = 0; startdepths[0] = 0;
stack.push(Label(0)); stack.push(Label(0));
let debug = false; const DEBUG: bool = false;
'process_blocks: while let Some(block) = stack.pop() { 'process_blocks: while let Some(block) = stack.pop() {
let mut depth = startdepths[block.0 as usize]; let mut depth = startdepths[block.0 as usize];
if debug { if DEBUG {
eprintln!("===BLOCK {}===", block.0); eprintln!("===BLOCK {}===", block.0);
} }
let block = &self.blocks[block.0 as usize]; let block = &self.blocks[block.0 as usize];
for i in &block.instructions { for i in &block.instructions {
let instr = &i.instr; let instr = &i.instr;
let effect = instr.stack_effect(false); let effect = instr.stack_effect(false);
if DEBUG {
eprint!("{instr:?}: {depth} {effect:+} => ");
}
let new_depth = add_ui(depth, effect); let new_depth = add_ui(depth, effect);
if debug { if DEBUG {
eprintln!("{:?}: {:+}, {:+} = {}", instr, effect, depth, new_depth); eprintln!("{new_depth}");
} }
if new_depth > maxdepth { if new_depth > maxdepth {
maxdepth = new_depth maxdepth = new_depth
@ -205,6 +208,9 @@ impl CodeInfo {
} }
stackdepth_push(&mut stack, &mut startdepths, block.next, depth); stackdepth_push(&mut stack, &mut startdepths, block.next, depth);
} }
if DEBUG {
eprintln!("DONE: {maxdepth}");
}
maxdepth maxdepth
} }
} }