Skip to content

Match CPython borrow and fast-local superinstruction selection #27

@youknowone

Description

@youknowone

Summary

Many remaining diffs are no longer about control-flow or constants, but about the exact local-variable opcode
forms RustPython chooses.

Evidence

Recurring mismatches include:

  • LOAD_FAST vs LOAD_FAST_BORROW
  • LOAD_FAST_LOAD_FAST vs LOAD_FAST_BORROW_LOAD_FAST_BORROW
  • STORE_FAST vs STORE_FAST_STORE_FAST
  • STORE_FAST_LOAD_FAST where CPython keeps separate instructions

This pattern appears across:

  • Lib/test/test_buffer.py
  • Lib/test/test_math.py
  • Lib/test/test_tarfile.py
  • Lib/dataclasses.py
  • Lib/test/test_dis.py

Expected direction

Borrow opcode and fused local opcode selection should follow CPython’s optimizer decisions, not a RustPython-
specific heuristic. This should be driven by the same structural conditions CPython uses.

Likely implementation areas

  • crates/codegen/src/ir.rs
  • local-op fusion and borrow/deopt logic after CFG shaping

Done when

Representative functions in the files above stop drifting on borrow/fused local opcodes and match CPython’s
chosen opcode forms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions