Repository navigation
series: keep guest loads whose value is unused - #8
Merged
Merged
Conversation
HotSpot C1 null checks are cmp rax,[reg] with dead flags; the dead-flag pass removed the load with the compare and Necesse aborted on the next field load. Patch 0007 declares the guest load IR ops as side-effecting. Series version 5.
4 of 8 tasks
utkarshdalal
added a commit
to utkarshdalal/GameNative
that referenced
this pull request
Oct 29, 2026
Series 5 keeps guest loads whose value is unused (GameNative/FEX#8): the dead-flag pass deleted HotSpot's cmp rax,[rdx] null probe, which aborted the JVM in Necesse 13 s after start on every earlier FEX build. Replaces the gn-4 entry as #2211 did for gn3; overlays with a 2610-gn floor resolve to it. Co-authored-by: Utkarsh Dalal <utkarsh.dalal@toptal.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.
Adds series patch 0007 and bumps SERIES_VERSION to 5.
What
The dead-flag pass (
RedundantFlagCalculationElimination::EliminateDeadCode) removes any IR node with no uses and no declared side effects.LoadMemandLoadMemTSOdeclare none, so a guest load whose only consumer was a flag write that a later instruction overwrites is removed together with the compare. A load that faults on x86 then does not fault under FEX.0007 sets
HasSideEffectson the guest load ops inIR.json:LoadMem,LoadMemTSO,VLoadVectorMasked,VLoadVectorGatherMasked,VLoadVectorGatherMaskedQPS,VLoadVectorElement,VLoadNonTemporal.LoadMemPairalready had it. The flag is read only by that dead-code check, so the only behaviour change is that unused loads stay in the block.Why
HotSpot's C1 emits its explicit null check as
cmp rax,[reg]with the flags dead (MacroAssembler::null_check), and turns the access violation at that PC into a NullPointerException. Under FEX the compare and its load were gone, so a null receiver reached the next field load, whose PC is not in the nmethod's null-check table, and the VM aborted.Necesse (Temurin 17.0.19 x86-64 JRE) died this way 13 s after start on the Odin 3 on every FEX build and preset:
EXCEPTION_ACCESS_VIOLATIONreading0xcatmov esi,[rdx+0xc]innecesse.engine.save.LoadData.getInt/getBoolean(8 bytes, tier 3), right after a passedcmp rax,[rdx]. The code between the two is the profile counter update:All five distinct hs_err dumps show the normal path (rsi holds the live counter, no stub taken) and the event log has
Implicit null exception at <pc> to 0x0000000000000000: the JVM looked up a continuation for the faulting PC and found none.-XX:TieredStopAtLevel=1and-XX:-TieredCompilationsurvive because that code folds the null check into a used load.Evidence
Odin 3, Proton 11.0-2-arm64ec-9, Necesse container, stock
Necesse.json.Stand-alone repro (
C1NullProbe: a static method calling a virtual on its argument, null every 5000th call, 5 M iterations,-XX:CompileCommand=dontinline):-XX:TieredStopAtLevel=3-XX:TieredStopAtLevel=1J 159 c1 C1NullProbe.getBool (8 bytes) @ +0x4e, AV reading 0xc, rdx=0,Implicit null exception ... to 0x0DONE n=4999000 npe=1000Necesse on stock settings:
-XX:-ImplicitNullChecks)Not covered: upstream InstructionCountCI expectations will change where a test compares against memory with dead flags; the series CI only builds the DLLs. Upstream
main(fb48e2d) has the same code; this is not sent upstream here.