Skip to content

Preserve interrupt ownership across AOT tail fallbacks - #194

Merged
mstan merged 1 commit into
RetroPortingToolKit:mainfrom
sergiomanzur:codex/interrupt-tail-ownership
Oct 21, 2026
Merged

mstan merged 1 commit into
RetroPortingToolKit:mainfrom
sergiomanzur:codex/interrupt-tail-ownership

Conversation

@sergiomanzur

Copy link
Copy Markdown
Contributor

An unresolved tail from an AOT subroutine running inside NMI/IRQ currently enters a fresh interrupt interpreter before checking whether an existing interpreter owns the continuation. That nested run consumes the caller's continuation and RTI, then returns to compiled code with a guest stack that has already unwound.

Check the interpreter bounce owner first, and only select interrupt-root execution when there is no paired RTS/RTL return frame (hrv == 0). Near and far subroutines retain the existing balanced fallback, including indirect-dispatch handling.

Validation:

  • Added a ROM-free fixture linked against the production interpreter and bridge. On unchanged main it reports 10 failed checks: incorrect S, double-executed continuations, and missing owner unwind for both JSR and JSL.
  • python -m pytest tests/test_interrupt_tail.py -q: 2 passed, covering the new fixture and the existing bridge contract harness.
  • New fixture also verifies interrupt-root RTI and enclosing interrupt-scope preservation.
  • Independent code review found no actionable issues.

This was extracted from ISSD Native bring-up and adapted to current main (0788387). No commercial ROM, generated game source, frame scheduling changes, or game-specific addresses are required. Cross-title gameplay qualification is left to the maintainers; this PR establishes the synthetic ownership contract.

@mstan mstan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed ownership ordering: interpreter bounce ownership must win, and only an unpaired interrupt root may run to RTI. Near/far subroutines retain balanced fallback. The production bridge regression and existing bridge harness pass.

Validation: five-head integration passed 826 Python tests (2 skipped) and 109 Rust tests. After excluding #198 for its separate title-save compatibility blocker, the four-head combination passed all 69 focused tests. Linux, Windows, macOS and Lua CI are green for this reviewed head. No new cross-title gameplay playtest is claimed.

@mstan
mstan merged commit 03b9037 into RetroPortingToolKit:main Oct 21, 2026
8 checks passed
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.

2 participants