mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-19 19:15:43 +00:00
Fix max_stacksize DEBUG to use const
This commit is contained in:
parent
6760d21399
commit
c3b1400240
1 changed files with 10 additions and 4 deletions
14
src/ir.rs
14
src/ir.rs
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue