F2I/F2L fix: NaN→0, +Inf→MAX_VALUE#462
Open
opencode-agent[bot] wants to merge 1 commit into
Open
Conversation
Co-authored-by: LSantha <LSantha@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.
The fix is complete and builds successfully. Here's a summary of all changes:
Changes Made
6 files modified (5 source + 1 test):
1.
core/src/core/org/jnode/vm/x86/compiler/l1a/IntItem.java—popFromFPU()for F2I/D2I in L1A compiler. Emits assembly guards beforeFISTP32:[reg+disp-4]before conversionInteger.MIN_VALUE(indefinite integer)MAX_VALUE, -Inf → keepsMIN_VALUEMAX_VALUE2.
core/src/core/org/jnode/vm/x86/compiler/l1a/LongItem.java— Same pattern for F2L/D2L withFISTP64, checking both 32-bit halves of the 64-bit result againstLong.MIN_VALUE.3.
core/src/core/org/jnode/vm/x86/compiler/l1b/IntItem.java— Same fix for L1B IntItem.4.
core/src/core/org/jnode/vm/x86/compiler/l1b/LongItem.java— Same fix for L1B LongItem.5.
core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java— Fix for all 4F2Icases (reg→reg, reg→mem, mem→reg, mem→mem) in the L2 (IR-based) compiler.6.
core/src/test/org/jnode/test/bugs/ConversionTest.java— Test with 18 assertions covering NaN, ±Inf, normal values, zero, overflow, and boundary conditions.Fix Strategy
Each FISTP instruction is preceded by saving a copy of the FPU value (using
FSTP+FLD), followed by a post-instruction fixup that checks the result against the "indefinite integer" pattern and corrects it per JLS §5.1.3.Closes #456
opencode session | github run