Repository navigation
jit: accept x86 R15 as a valid register mapping target - #104
Merged
GloriousTacoo merged 2 commits intoOct 28, 2026
Merged
Conversation
allocate_x86_register() rejected a cached mapping to BAL_X86_R15 with cached_x86_register >= BAL_X86_R15. R15 is a valid scratch register (it is in SCRATCH_REGISTERS and the evict path documents [0, 15] as valid), so any ARM register backed by R15 tripped the corruption check and failed the whole block the next time that mapping was reused. Signed-off-by: GabrielGonHo <195778548+GabrielGonHo@users.noreply.github.com>
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.
Description
�llocate_x86_register() cached a mapping to BAL_X86_R15 and then rejected it:
c if (BAL_UNLIKELY(cached_x86_register < 0 || cached_x86_register >= (int8_t)BAL_X86_R15))BAL_X86_R15 is 15, and 15 is in SCRATCH_REGISTERS (the pool ends with BAL_X86_R15), so a cached mapping to r15 is legitimate. The >= turns it into "corrupted": �rm_to_x86 is reset, the entry returns BAL_X86_INVALID, and compiler->status becomes BAL_ERROR_REGISTER_ALLOCATOR_CORRUPTED, failing the whole block. The log message itself documents the intended range as "0-r15", contradicting the code.
The check now uses > so r15 is accepted. This only triggers when at least 9 ARM GPRs are simultaneously live (pool exhaustion backs one of them with r15), which is common in function prologues and STM/LDM-style sequences.
Type of Change
Testing