Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP by youknowone · Pull Request #6810 · RustPython/RustPython · GitHub
Skip to content

Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP#6810

Merged
youknowone merged 4 commits intoRustPython:mainfrom
youknowone:opcode
Jan 20, 2026
Merged

Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP#6810
youknowone merged 4 commits intoRustPython:mainfrom
youknowone:opcode

Conversation

@youknowone
Copy link
Copy Markdown
Member

@youknowone youknowone commented Jan 20, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Optimized compiler instruction handling and bytecode generation for improved efficiency and reduced code complexity.
    • Enhanced virtual machine stack management and iterator cleanup behavior, particularly during loop execution.
    • Streamlined the instruction set by removing obsolete instruction types.
    • Consolidated conditional jump and subscript operation handling logic for better maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 20, 2026

@youknowone youknowone marked this pull request as ready for review January 20, 2026 06:28
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/codegen/src/compile.rs (1)

4928-4935: Add PopTop after EndAsyncFor to clean up the async iterator.

The EndAsyncFor instruction only pops exception handling items (awaitable, exc), not the iterator itself. The iterator remains on the stack after the instruction completes. A PopTop must follow to clean it up, matching the pattern used in comprehension loops at lines 7363-7368 and 7564-7568.

if is_async {
    emit!(self, Instruction::EndAsyncFor);
    emit!(self, Instruction::PopTop);
} else {
    // Pop the iterator after loop ends
    emit!(self, Instruction::PopTop);
}

@youknowone youknowone merged commit f0c3e7d into RustPython:main Jan 20, 2026
13 checks passed
@youknowone youknowone deleted the opcode branch January 20, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant