diff --git a/fconst_0_compliance_report.md b/fconst_0_compliance_report.md new file mode 100644 index 000000000..1fb17615d --- /dev/null +++ b/fconst_0_compliance_report.md @@ -0,0 +1,48 @@ +## 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:1792`, `core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.java:74`, `core/src/core/org/jnode/vm/x86/compiler/l1a/FloatItem.java:88-110` +- **Issues:** None + +**Analysis:** +The L1A implementation correctly handles `fconst_0` (opcode 0xb) by creating a `FloatItem` with `Kind.CONSTANT` and the value `0.0f`. The `FloatItem` class stores the float value and when loaded to a register or pushed to the stack, it uses `Float.floatToIntBits(value)` (line 89, 109 in FloatItem.java) which correctly preserves the IEEE 754 bit pattern including signed zero (+0.0). The virtual stack mechanism delays emission until needed, maintaining the correct category-1 (single-slot) stack effect as required by the spec. + +### l1b Implementation +- **Status:** ✅ PASS +- **Files:** `core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java:2153`, `core/src/core/org/jnode/vm/x86/compiler/l1b/ItemFactory.java:67`, `core/src/core/org/jnode/vm/x86/compiler/l1b/FloatItem.java:88-110` +- **Issues:** None + +**Analysis:** +The L1B implementation is functionally identical to L1A for `fconst_0`, with the addition of a bytecode counter increment. It creates a `FloatItem` with `Kind.CONSTANT` and value `0.0f`, using the same `Float.floatToIntBits()` conversion for register loads and stack pushes. The virtual stack and item management are equivalent to L1A, correctly preserving the float bit pattern and category-1 stack effect. + +### l2 Implementation +- **Status:** ✅ PASS +- **Files:** `core/src/core/org/jnode/vm/compiler/ir/IRGenerator.java:291`, `core/src/core/org/jnode/vm/compiler/ir/FloatConstant.java:38`, `core/src/core/org/jnode/vm/x86/compiler/l2/FPX86CodeGenerator.java:191` +- **Issues:** None + +**Analysis:** +The L2 compiler's `IRGenerator.visit_fconst()` creates a `FloatConstant` IR node with the value `0.0f`. The `FloatConstant.getIntBits()` method uses `Float.floatToRawIntBits(value)` (line 39) which preserves the exact IEEE 754 bit representation including signed zero. During code generation, `FPX86CodeGenerator.loadToFPUStack32()` (line 191) handles the CONSTANT addressing mode by pushing the raw int bits to the stack and executing `FLD32`, correctly loading +0.0 onto the FPU stack. The IR assigns it to a single stack slot (`stackOffset += 1`), matching the category-1 requirement. + +--- + +## JVM Spec References +- **Instruction:** `fconst_0` (opcode 0xb / 11) +- **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.doc4.html +- **Operand Stack Effect:** `... → ..., 0.0` +- **Type:** `float` (category 1, single slot) +- **Description:** "Push the float constant 0.0 onto the operand stack." +- **Exceptions:** None + +All three JNode compiler tiers correctly implement the `fconst_0` instruction per the JVM SE 6 specification. \ No newline at end of file