Uh oh!
There was an error while loading. Please reload this page.
[wasm] Make back branches faster in the jiterpreter and clean up some code - #99772
Merged
Conversation
…back branches even if they aren't taken
kg
marked this pull request as ready for review
March 14, 2024 18:36
kg
requested review from
BrzVlad, kotlarmilos, lewing, pavelsavara and vargaz
as code ownersMarch 14, 2024 18:36
vargaz
approved these changes
Mar 14, 2024
3 tasks
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Right now the jiterpreter maintains a local variable tracking whether a backward branch has ever been taken, and flushes it to memory upon abnormal exit to notify the monitoring code whether the trace took any backward branches.
I realized this variable isn't actually necessary, because the design of the jiterpreter's dispatch code ensures that the existing
dispvariable will only have the value 0 on first execution, and will always have a nonzero value after any backwards branch is taken. So we can just flushdispto memory on abnormal exit instead. This means we don't have to waste valuable cycles setting the flag every time we take a backwards branch, since we're already settingdisp.I also took the opportunity to change things so we pass a
NULLcinfoto traces when they're not being monitored. In most scenarios this shouldn't matter, but for hot traces that abnormally exit this will reduce the number of pointless memory writes they do a little bit, and it will also fix the minor problem that in multithreaded scenarios, all traces compete to write to the same dummy staticcinfovariable (now they won't perform the write at all).While adding this optimization I also noticed that conditional back-branches were modifying
dispeven when the branch wasn't taken, which would raise the cost of each of those branches for no good reason, so I cleaned that up as well.This makes abnormal exits ~5 bytes longer, but it makes back-branches 1 byte shorter, so it should be a trace size reduction on average.
There were a couple hard-coded offsets in the typescript and I took the opportunity to change them into JiterpMembers as well.