Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions iconst_4_spec_compliance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## Spec compliance report

| Compiler | Status | Issues |
|----------|--------|--------|
| l1a | ✅ PASS | None |
| l1b | ✅ PASS | None |
| l2 | ✅ PASS | None |

---

## Details

### l1a Implementation
- **Status:** ✅ PASS
- **Files:** `core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java:2161`, `core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.java:61`, `core/src/core/org/jnode/vm/x86/compiler/l1a/IntItem.java:60`, `core/src/core/org/jnode/vm/x86/compiler/l1a/Item.java:250`
- **Issues:** None

**Analysis:**
- BytecodeParser (line 174) correctly decodes opcode 0x07 → `handler.visit_iconst(4)`
- X86BytecodeVisitor.visit_iconst() pushes an IntItem with JvmType.INT via ItemFactory.createIConst()
- IntItem.getType() returns JvmType.INT (category 1)
- Item.getCategory() returns 1 (correct for int)
- VirtualStack correctly tracks the single-slot push

### l1b Implementation
- **Status:** ✅ PASS
- **Files:** `core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java:2604`, `core/src/core/org/jnode/vm/x86/compiler/l1b/ItemFactory.java:56`, `core/src/core/org/jnode/vm/x86/compiler/l1b/IntItem.java:61`, `core/src/core/org/jnode/vm/x86/compiler/l1b/Item.java:235`
- **Issues:** None

**Analysis:**
- Identical implementation pattern to l1a
- Adds bytecode counter for profiling
- IntItem extends WordItem with JvmType.INT, category 1
- VirtualStack correctly handles the push

### l2 Implementation
- **Status:** ✅ PASS
- **Files:** `core/src/core/org/jnode/vm/compiler/ir/IRGenerator.java:275`, `core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java:241`, `core/src/core/org/jnode/vm/compiler/ir/IntConstant.java:26`
- **Issues:** None

**Analysis:**
- IRGenerator.visit_iconst() creates ConstantRefAssignQuad with IntConstant(value)
- Stack offset incremented by 1 (category 1)
- GenericX86CodeGenerator.generateCodeFor(ConstantRefAssignQuad) emits MOV_Const to register or stack
- L2ByteCodeSupportChecker does not override visit_iconst (inherits empty impl from BytecodeVisitorSupport) — this is correct as the checker only validates L2 eligibility, actual compilation uses IRGenerator

---

## JVM Spec References
- **Spec Base:** https://docs.oracle.com/javase/specs/jvms/se6/html/Instructions.doc.html
- **Spec Page:** https://docs.oracle.com/javase/specs/jvms/se6/html/Instructions2.doc6.html#iconst
- **Operation:** Push `int` constant
- **Format:** `iconst_<i>`
- **Forms:** `iconst_4` = 7 (0x7)
- **Operand Stack:** `...` → `..., <i>`
- **Description:** Push the `int` constant `<i>` (-1, 0, 1, 2, 3, 4 or 5) onto the operand stack
- **Notes:** Equivalent to `bipush <i>` except operand is implicit
- **Category:** 1 (int is a category-1 computational type per JVM Spec §2.11.1)
Loading