Bytecode parity CFG normalization and jump cleanup by youknowone · Pull Request #7721 · RustPython/RustPython
Reorder try/except/else/finally to emit else+finally before except handlers matching CPython layout. Add set_no_location for cleanup blocks. Extend CFG reorder pass to handle true-path jump-back for generators, break/continue, and assert in loops. Add stop-iteration error handler awareness to block protection.
remove_nops and remove_redundant_nops_in_blocks repeated has_jump_predecessor / has_plain_jump_predecessor / target lookups per block, scanning all blocks each time. With ~200,000 if blocks this became O(B^2 * I) and timed out test_compile.test_stack_overflow. Fold the three flags into one O(B * I) pass via compute_target_predecessor_flags.
- try_fold_constant_slice now delegates to try_fold_constant_expr so slice bounds accept the same constants other folding paths do (unary-folded values, __debug__, etc.). - remove_nops resolves fallthrough predecessors through empty blocks via next_nonempty_block before checking ends_with_for_cleanup. - should_deopt_borrowed_attr_chain ReturnIter matcher now accepts Instruction::CallKw alongside Instruction::Call, matching the Call/CallKw treatment in the surrounding deopt trigger check.
youknowone
changed the title
Bytecode parity cfg
Bytecode parity CFG normalization and jump cleanup
This was referenced
This was referenced
This was referenced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters