codegen: emit lookupFunction dispatch for external jump-table targets#111
Closed
jlsandri wants to merge 1 commit intoran-j:mainfrom
Closed
codegen: emit lookupFunction dispatch for external jump-table targets#111jlsandri wants to merge 1 commit intoran-j:mainfrom
jlsandri wants to merge 1 commit intoran-j:mainfrom
Conversation
When a [[jump_tables.table]] entry has targets outside the function boundary, emit runtime lookupFunction dispatch calls instead of filtering them out. Internal targets still use goto labels. Added externalJumpTableTargets to AnalysisResult to distinguish internal gotos from external calls during codegen.
91708d4 to
bf97d21
Compare
Author
|
Closing as part of a batch cleanup after #107 landed. The runtime ecosystem refactor in #107 substantially reworked the files this PR touched, and I would like to re-audit the underlying fix against the new code structure before putting it back in front of you. If the fix is still needed after that re-audit, I will re-open as a focused PR rebased onto current main. Thanks for your patience. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When a
[[jump_tables.table]]entry in the TOML config has targets that live outside the enclosing function's boundary, the previous codegen silently filtered them out. Those external targets would then be unreachable from the recompiled jump, which at runtime manifests as a wrong branch destination (or a no-op, depending on the dispatch path).Fix
goto-to-label dispatch inside the function body) from external ones.lookupFunction(0x…)dispatch call for the external targets, matching the fallback path already used for unresolved staticJ/JALsites (per the README's "unresolved static J/JAL" behaviour).externalJumpTableTargetsfield toAnalysisResultso the two categories can be separated during codegen instead of being decided in the emitter.Scope
ps2xRecomp/include/ps2recomp/code_generator.h: +4 / -0ps2xRecomp/src/lib/code_generator.cpp: +46 / -9Rationale
The recompiler already has a principled fallback for unresolved static calls (
runtime->lookupFunction(...)), so routing external jump-table targets through the same mechanism fits the existing model and makes the previously-filtered targets actually reachable at runtime.