Repository navigation
Runtime: reuse a cached import binding only for the (library, nid) it was resolved for - #45
Open
kalpakprod wants to merge 1 commit into
Open
kalpakprod wants to merge 1 commit into
kalpakprod wants to merge 1 commit into
Conversation
… was resolved for Import slots are per-corpus ordinals, so two corpora reuse the same slot numbers for different imports. Store the (library, nid) in each cached binding and re-resolve on mismatch.
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.
What changed
Runtime::invoke_import_cachedcaches the resolved HLE function per import slot inimport_bindings_. A slot is a per-corpus ordinal, so two corpora (a main executable plus a PRX module, both with their own import tables) use the same slot numbers for different imports. The cache did not check which import it had been filled for, so the first corpus to touch slot N decided what every later corpus got for slot N.Each cached binding now stores the
(library, nid)it was resolved for and is reused only for that pair; otherwise the import is resolved again and the slot is overwritten.Why
Found while bringing up a game with a main executable and 31 PRX modules loaded at run time. A module's
sceKernelCreateThreadimport (slot 60) hit the main executable's cached slot 60, a different ThreadMan function. The module's main thread was never created, the game stopped at a black screen, and other cross-corpus slots misdispatched into blocking calls (frames of 400 to 600 ms with the guest idle). With the change the same game gets past module start, shows its menu and plays its intro movie.How it was verified
g++ -std=c++20 -fsyntax-only src/runtime.cppis clean.[hle-stub]lines.Not verified
ctestand the CI platforms (macOS, Windows) were not run on this branch.