Skip to content

Commit e79df4a

Browse files
authored
Bytecode parity CFG normalization and jump cleanup (RustPython#7721)
* typealias reviews * Bytecode parity - try/except block order, CFG reorder 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. * Align CFG cleanup bytecode with CPython * Unmark test_dis.test_findlabels expected failure * Compute target predecessor flags in single pass 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. * Address review feedback on slice folding, fallthrough, attr-chain - 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. * remove test
1 parent 32e16fe commit e79df4a

4 files changed

Lines changed: 3199 additions & 606 deletions

File tree

‎Lib/test/test_dis.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,6 @@ def test__find_store_names(self):
24102410
res = tuple(dis._find_store_names(code))
24112411
self.assertEqual(res, expected)
24122412

2413-
@unittest.expectedFailure # TODO: RUSTPYTHON
24142413
def test_findlabels(self):
24152414
labels = dis.findlabels(jumpy.__code__.co_code)
24162415
jumps = [

0 commit comments

Comments
 (0)