YJIT: Reduce paddings if --yjit-exec-mem-size <= 128 on arm64 #7671
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.
Despite our past effort #6790, YJIT's arm64 code still seems to be bloated a lot by
nop
instructions. For invalidation, we still waste a lot of spaces for non-side-exit jumps.b
instruction could make a jump to +/-128MiB relative from the PC. Using that property, if the virtual code region size is <= 128MiB, we should always be able to encode an unconditional jump to JIT code withb
.We've already learned that the default 64MiB is more than enough for SFR, and we're even running Shopify Core with 64MiB. This PR minimizes the number of
nop
instructions when--yjit-exec-mem-size
is <= 128MiB, assuming most people would use the default 64MiB and almost never need more than 128MiB.Example
Before
After
Unconditional jumps will always fit in a single
b
instruction, so nonop
instructions are generated. For unconditional jumps,b.cond
+b
(2 instructions) will be the worst case, so up to 1nop
instruction can be generated.Code size
On railsbench,
Before
After
inline_code_size
is reduced by 16%.Benchmark