l1a/l1b: PARTIAL (no NPE check); l2: FAIL (unsupported)#559
Open
opencode-agent[bot] wants to merge 1 commit into
Open
l1a/l1b: PARTIAL (no NPE check); l2: FAIL (unsupported)#559opencode-agent[bot] wants to merge 1 commit into
opencode-agent[bot] wants to merge 1 commit into
Conversation
Co-authored-by: LSantha <[email protected]>
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.
Spec compliance report
Details
l1a Implementation
core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java:2153(visit_iastore)core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java:4143(wastore)core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java:330(checkBounds)checkBoundsmethod (line 330) only validates array index bounds viaCMP length, indexandJNAjump. It does not explicitly check ifarrayrefis null before dereferencing. Per JVM spec (§iastore),NullPointerExceptionmust be thrown ifarrayrefis null. Current implementation relies on hardware memory fault when accessingarrayLengthOffsetfrom a null reference, which may not reliably translate to a properNullPointerException.iastore(primitive int array). Per JVM spec, ArrayStoreException only applies to reference array stores (aastore). This TODO should be removed or clarified.val(value),idx(index),ref(arrayref) in that order (lines 4181-4183), matching spec..., arrayref, index, value → ....checkBounds(lines 330-360, 4199) — compares array length with index using unsigned comparison (JNA), callsthrowArrayOutOfBoundson failure. ✓BITS32, scale=4 for int arrays (lines 4161-4164).l1b Implementation
core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java:2593(visit_iastore)core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java:5127(wastore)core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java:322(checkBounds)checkBounds(line 322) only checks index bounds, no explicit null check onarrayref. Relies on hardware fault.checkBounds(lines 322-364, 5183). ✓BITS32, scale=4 (lines 5145-5148). ✓l2 Implementation
core/src/core/org/jnode/vm/x86/compiler/l2/L2ByteCodeSupportChecker.java:75(visit_iastore)core/src/core/org/jnode/vm/compiler/ir/IRGenerator.java:422(visit_iastore → visitArrayStore)core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java:4126(generateCodeFor ArrayStoreQuad)core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java:4276(checkBounds)L2ByteCodeSupportChecker.visit_iastore()(line 75) callsnotSupported(), which throwsUnsupportedOperationException. This means no method containingiastorewill ever be compiled by L2 — it will fall back to L1A/L1B. This is a major gap in the L2 compiler coverage.IRGenerator.visitArrayStore(lines 1382-1393) correctly handles operand stack order:val(top),ind(index),ref(arrayref) at offsets -disp, -disp-1, -disp-2. CreatesArrayStoreQuad. ✓GenericX86CodeGenerator.generateCodeFor(ArrayStoreQuad)(lines 4126-4273) implements store logic with proper addressing modes (REGISTER, CONSTANT, STACK for ref, index, value).checkBounds(lines 4276-4349) only validates index bounds, no explicit null check onref.int scale = 4;— correct for int arrays but not parameterized by element type (thoughArrayStoreQuadcarriesarrayType).JVM Spec Reference (Java SE 6)
iastore (Instructions2.doc6.html):
..., arrayref, index, value → ...arrayrefmust be reference toint[];indexandvaluemust beint. All three popped.valuestored atarray[index].NullPointerExceptionifarrayrefisnullArrayIndexOutOfBoundsExceptionifindexout of boundsiastore(only foraastoreper spec)Key Spec Quote: "If arrayref is null, iastore throws a NullPointerException. Otherwise, if index is not within the bounds of the array referenced by arrayref, the iastore instruction throws an ArrayIndexOutOfBoundsException."
Closes #300
opencode session | github run