All three JNode compilers (L1A, L1B, L2) ✅ PASS lload spec compliance.#564
Open
opencode-agent[bot] wants to merge 1 commit into
Open
All three JNode compilers (L1A, L1B, L2) ✅ PASS lload spec compliance.#564opencode-agent[bot] wants to merge 1 commit into
lload spec compliance.#564opencode-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:3232core/src/core/org/jnode/vm/x86/compiler/l1a/X86StackFrame.java:351core/src/core/org/jnode/vm/x86/compiler/l1a/DoubleWordItem.java:150,161,189,235core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.java:150l1b Implementation
core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java:4035core/src/core/org/jnode/vm/x86/compiler/l1b/X86StackFrame.java:343core/src/core/org/jnode/vm/x86/compiler/l1b/DoubleWordItem.java:143,153,179,223core/src/core/org/jnode/vm/x86/compiler/l1b/ItemFactory.java:133l2 Implementation
core/src/core/org/jnode/vm/compiler/ir/IRGenerator.java:323core/src/core/org/jnode/vm/x86/compiler/l2/X86StackFrame.java:351core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java:278core/src/core/org/jnode/vm/x86/compiler/l2/L2ByteCodeSupportChecker.java(inherits support)Verification Against JVM Spec (JVMS SE6 §lload)
Spec Requirements:
lload= 22 (0x16), followed by unsigned byte index.lload_<n>(0x1e-0x21) for implicit indices 0-3.... → ..., value(pushes long, category 2)indexandindex+1must be valid local variable indices; the long value occupies two consecutive slots.wide lloaduses 16-bit unsigned index.Bytecode Parser Compliance (BytecodeParser.java):
case 0x16: handler.visit_lload(getu1());— correctly reads 8-bit index viagetu1().case 0x1e-0x21: handler.visit_lload(0-3);— correctly handles implicit indices.case 0xc4:reads opcode 0x16 and callshandler.visit_lload(getu2())at line 841 — correctly reads 16-bit index viagetu2().Category-2 Local Slot Handling:
All three tiers use
getWideEbpOffset(typeSizeInfo, index)which is implemented as:This correctly maps the JVM's category-2 local (occupying
indexandindex+1) to the MSB slot offset, whilegetLsbOffsetToFPreturns the base offset andgetMsbOffsetToFPreturns base+4 (32-bit) or the same 64-bit offset.Stack Item Type & Category:
visit_lloadcreates aLongItemviaifac.createLocal(JvmType.LONG, ...).LongItemextendsDoubleWordItemwhich returnsgetCategory() == 2(DoubleWordItem.java:150). The virtual stack tracks this as a category-2 item.IRGenerator.visit_lload(line 323-330) marksvariables[index]andvariables[index+1]asOperand.LONG, pushes two stack slots (stackOffset += 2), and emits aVariableRefAssignQuadfor the load.L2 Code Generation:
GenericX86CodeGenerator.generateCodeFor(VariableRefAssignQuad)(line 278) handlesREGISTER←LOCAL,STACK←LOCAL, andLOCAL←REGISTER/STACK/CONSTANTmodes.X86StackFrame.emitHeader(line 233-240) allocates one slot per local variable index, matching the verifier's frame model where category-2 locals consume two indices.BytecodeVisitorSupport (L2 Support Checker):
L2ByteCodeSupportCheckerdoes not overridevisit_lload, inheriting the empty implementation fromBytecodeVisitorSupport:931, meaninglloadis supported in L2 compilation.Conclusion
All three JNode compiler tiers (L1A, L1B, L2) correctly implement the
lloadinstruction per the JVM SE6 specification. The parser correctly decodes 8-bit and 16-bit (wide) indices, the category-2 local variable slot layout is properly handled viagetWideEbpOffset(index) → getEbpOffset(index+1), and the operand stack effect (pushing a category-2 long value) is faithfully represented in each tier's intermediate representation.Closes #342
opencode session | github run