irjit: Add ini option to precompile functions #10514
Merged
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.
This uses an xxhash of the original code to validate before actually linking emuhacks. We'd need to do the same for any jit cache, because games don't call icache invalidation before executing blocks the first time consistently.
This also allows testing IR passes on all blocks at once.
With the hashing, this seems to work just as well in all games as without. Spikes in jitc while loading are mostly gone though, replaced by small bumps from the hash validation.
Some things we could do:
Add a "safe mode" (possibly a game id hack, as much as I hate those) for some games that confuse the jit. It could revalidate the hash each time. This would be a lot slower, but maybe needed for Tony Hawk and Jit emuhacks detected by games (Metal Gear Solid: Peace Walker demo) #3365? Have not validated assumption that this would beat interp in speed, though - might be worse.... could be a dev option to validate if emuhacks vs jit bugs are the problem.
Cache the instructions to a file / reload. Would need to version and think about lifecycle though (e.g. new build with irjit fix, new ops, etc.)
Reuse previously invalidated blocks if the hash matches. Currently, they never get used again.
More aggressively use optimization passes, since they wouldn't cause ingame hitching at least.
Either hook this up to jit backends with IR, or port (in theory the same should be doable there - just have to watch the codepool cap and the branch prediction order.)
The preload time, on desktop, is usually 200ms to at most ~750ms (after 64-bit IR.) On mobile it's surely slower, but I didn't really measure yet.
This is still off by default.
-[Unknown]