GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Align bytecode CFG cleanup with CPython by youknowone · Pull Request #7781 · RustPython/RustPython

Align bytecode CFG cleanup with CPython #7781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
youknowone merged 76 commits into RustPython:main from youknowone:bytecode-parity
May 12, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Align bytecode CFG cleanup with CPython #7781

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
c09c475
Align CFG cleanup bytecode with CPython
youknowone Apr 28, 2026
fe64200
remove test
youknowone Apr 30, 2026
94e2ae3
Align bytecode CFG cleanup with CPython
youknowone May 5, 2026
a743ffc
fix
youknowone May 5, 2026
c998628
Align named-except borrow deopts with CPython
youknowone May 5, 2026
68610b9
Remove duplicated Lib test codegen cases
youknowone May 5, 2026
c82c43f
Cache CFG layout predecessors during NOP cleanup
youknowone May 6, 2026
cd9a711
Address bytecode parity review feedback
youknowone May 7, 2026
15a88df
Align nested with cleanup bytecode
youknowone May 7, 2026
4bd27be
Align conditional raise loop backedge ordering
youknowone May 7, 2026
9b257b1
Align percent format optimization with CPython preprocess
youknowone May 7, 2026
8fbe367
Preserve shared finally reraises in CFG cleanup
youknowone May 7, 2026
3ccda96
Align CFG cleanup with CPython finally layout
youknowone May 7, 2026
2aa954f
Align loop CFG anchors with CPython
youknowone May 7, 2026
742ff9b
Preserve loop false-path CFG bodies
youknowone May 7, 2026
6cfa6f2
Align protected store-subscript CFG bytecode
youknowone May 7, 2026
cc59c46
Align borrow deopts with CPython CFG
youknowone May 7, 2026
891e972
Align delete-loop CFG with CPython
youknowone May 7, 2026
19b7427
Align CFG inlining with CPython jumps
youknowone May 7, 2026
d734c06
Align protected CFG jump threading
youknowone May 7, 2026
0e2b226
Narrow handler resume borrow deopt
youknowone May 7, 2026
3bb0430
Preserve branch-local implicit continue targets
youknowone May 7, 2026
55ec30d
Avoid duplicating boolop continue backedges
youknowone May 7, 2026
95c4492
Preserve same-line assert message borrows
youknowone May 7, 2026
8ce6677
Handle nested handler update tail borrows
youknowone May 7, 2026
d37b510
Align terminal handler borrow deopts with CPython CFG
youknowone May 7, 2026
ac086bf
Refine borrow deopts for reraise handler continuations
youknowone May 7, 2026
644d3e3
Refine try-else terminal handler borrow deopts
youknowone May 7, 2026
7adc9f4
Refine protected tail borrow parity
youknowone May 7, 2026
33ec4a6
Refine exception borrow deopt parity
youknowone May 7, 2026
de00801
Align while loop CFG layout with CPython
youknowone May 7, 2026
309b936
Align loop backedge CFG with CPython
youknowone May 7, 2026
f3b8ba1
Handle multi-block scope-exit CFG segments
youknowone May 7, 2026
aa2ca06
Preserve CPython-normalized call-body CFG
youknowone May 7, 2026
cea61f2
Preserve CPython empty if-end return anchor
youknowone May 7, 2026
8be2a54
Match CPython borrow CFG boundaries
youknowone May 7, 2026
f155436
Match CPython tuple unpack constant folding
youknowone May 7, 2026
85c3367
Match CPython implicit continue CFG layout
youknowone May 7, 2026
bb7be66
Keep implicit continue CFG targets in layout
youknowone May 7, 2026
058bc6d
Align try-except end label location with CPython
youknowone May 7, 2026
e4eb97c
Remove folded operand NOPs before line propagation
youknowone May 8, 2026
b022111
Align no-location return exit handling
youknowone May 8, 2026
5e4c096
Align nested protected import bytecode
youknowone May 8, 2026
f7d8240
Align conditional loop backedge layout
youknowone May 8, 2026
5001df7
Align protected loop exit duplication
youknowone May 8, 2026
6b604df
Preserve protected jump-back duplicates
youknowone May 8, 2026
83f109e
Align loop call-body backedge layout
youknowone May 8, 2026
3e11e1f
Align future annotation setup ordering
youknowone May 8, 2026
88ec625
Align named-except cleanup and borrow parity
youknowone May 8, 2026
e24a9b7
Align redundant jump removal with CPython
youknowone May 8, 2026
7f1376b
Preserve finally cleanup jump NOPs
youknowone May 8, 2026
6f95452
Align finally cleanup CFG with CPython
youknowone May 8, 2026
1d078e3
Fix finally cleanup CFG regression
youknowone May 8, 2026
85c70ca
Align async cleanup CFG marker handling
youknowone May 8, 2026
606e816
Preserve CPython continue CFG layout before conditional bodies
youknowone May 8, 2026
b340ca8
Refine protected CFG bytecode parity
youknowone May 8, 2026
330c44c
Align protected CFG cleanup layout
youknowone May 8, 2026
9c737eb
Align CFG cleanup and peephole parity
youknowone May 8, 2026
d35c13d
Align nested loop conditional CFG layout
youknowone May 8, 2026
bba340b
Align named expression comprehension scope
youknowone May 8, 2026
ea757cf
Align CFG cleanup with CPython line markers
youknowone May 8, 2026
555e8fc
Align CFG line marker cleanup with CPython
youknowone May 8, 2026
8abe32a
Align loop CFG fallthrough with CPython
youknowone May 8, 2026
05d96e4
Align conditional CFG fallthrough cases with CPython
youknowone May 8, 2026
a891818
Align protected CFG layout with CPython
youknowone May 8, 2026
24dde16
Align CFG cleanup and type-param calls with CPython
youknowone May 8, 2026
93e8bc4
Align annotation and super call bytecode parity
youknowone May 8, 2026
1b414fe
Align finally reraise tail inlining
youknowone May 8, 2026
7268983
Align protected loop CFG cleanup
youknowone May 8, 2026
a24a791
Align loop CFG bytecode layout with CPython
youknowone May 9, 2026
0941b7a
Align nested loop jump-back layout
youknowone May 9, 2026
448e1f2
Align conditional jump threading with CPython
youknowone May 9, 2026
a448fb6
fix
youknowone May 9, 2026
b3b8329
Skip test_stack_overflow under -u cpu
youknowone May 11, 2026
7790e54
Fix CI lint and clippy errors
youknowone May 12, 2026
19bf583
Speed up CFG cleanup for large compile inputs
youknowone May 12, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
Align bytecode CFG cleanup with CPython
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone committed May 11, 2026
commit 94e2ae3abdafd596ecb07527dbae66a3db2fa09c

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

42 changes: 1 addition & 41 deletions 42 crates/codegen/src/compile.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3384,8 +3384,6 @@ impl Compiler {
)?;
}

let else_block = self.new_block();

// if handlers is empty, compile body directly
// without wrapping in TryExcept (only FinallyTry is needed)
if handlers.is_empty() {
Expand Down Expand Up @@ -3487,19 +3485,11 @@ impl Compiler {
self.compile_statements(body)?;
emit!(self, PseudoInstruction::PopBlock);
self.set_no_location();
self.remove_last_no_location_nop();
self.pop_fblock(FBlockType::TryExcept);
emit!(
self,
PseudoInstruction::JumpNoInterrupt { delta: else_block }
);
self.set_no_location();
self.remove_last_no_location_nop();

let cleanup_block = self.new_block();
// We successfully ran the try block:
// else:
self.switch_to_block(else_block);
self.compile_statements(orelse)?;

emit!(
Expand Down Expand Up @@ -5839,17 +5829,10 @@ impl Compiler {
if is_async {
self.set_source_range(with_range);
}
let preserve_pop_block_nop = !is_async && self.current_block_follows_end_async_for();
if preserve_pop_block_nop {
emit!(self, Instruction::Nop);
self.preserve_last_redundant_nop();
}
emit!(self, PseudoInstruction::PopBlock);
if !is_async {
self.set_no_location();
if !preserve_pop_block_nop {
self.remove_last_no_location_nop();
}
self.remove_last_no_location_nop();
self.set_source_range(with_range);
}
self.pop_fblock(if is_async {
Expand Down Expand Up @@ -10877,29 +10860,6 @@ impl Compiler {
&mut info.blocks[info.current_block]
}

fn current_block_follows_end_async_for(&mut self) -> bool {
let info = self.current_code_info();
let current = info.current_block;
if info.blocks[current]
.instructions
.iter()
.rev()
.find_map(|info| info.instr.real())
.is_some_and(|instr| matches!(instr, Instruction::EndAsyncFor))
{
return true;
}
info.blocks.iter().any(|block| {
block.next == current
&& block
.instructions
.iter()
.rev()
.find_map(|info| info.instr.real())
.is_some_and(|instr| matches!(instr, Instruction::EndAsyncFor))
})
}

fn new_block(&mut self) -> BlockIdx {
let code = self.current_code_info();
let idx = BlockIdx::new(code.blocks.len().to_u32());
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.