Skip to content

L1A compiler: investigate 'unbalanced item handling' warnings during boot #618

Description

@LSantha

Observation

During boot, the L1A (X86 bytecode visitor) emits multiple warnings of the form:

HH:MM:SS,mmm WARN  Unbalanced item handling in org.jnode.core.BootInfos-scanManifestResource(Ljava/io/InputStream;)V
HH:MM:SS,mmm WARN  Unbalanced item handling in org.jnode.core.BundleLauncherService-launch(Lorg/jnode/core/BundleLauncherService;)V

The ItemFactory maintains an active-list stack tracking operand items during L1A bytecode translation. The logWarning() method fires when activeCount != expected, indicating an imbalance between pushes and pops tracked by the visitor.

What we know

  • Log site: X86BytecodeVisitor.java — now routed through BootLog (previously raw System.out)
  • Detection: ItemFactory.isBalanced(int expected) compares activeCount (tracking depth relative to maxStack) against an expected delta
  • Files involved:
    • core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java — the L1A visitor that translates each bytecode
    • core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.java — manages the active list of operand items
    • core/src/core/org/jnode/vm/x86/compiler/l1a/X86StackFrame.java — stack frame setup
  • Affected methods seen in boot: BootInfos.scanManifestResource, BundleLauncherService.launch

Questions to investigate

  1. Root cause: Is the imbalance a real correctness issue (compiled code has wrong stack handling), or a bookkeeping quirk of the active-list tracking (e.g., dead items, exception handler boundaries, or phi merges)?
  2. Scope: Does it affect only these two methods, or does it fire more widely at DEBUG level? Boot with log4j.logger.org.jnode.vm.x86.compiler.l1a=DEBUG to see full output.
  3. Downstream effect: Can the affected methods be compiled and run successfully despite the warning? (They appear to work in practice.)
  4. Correctness: Verify the active-list delta accounting against the bytecode verifier's maxStack — if the warning indicates a real mismatch, the compiled native code may have a subtle stack layout error in the JIT.
  5. Reproduction: Can we write a focused unit test that reproduces the imbalance with a minimal bytecode snippet?

Environment

  • Seen during standard cd-x86-combined-lite boot (VirtualBox + serial console)
  • L1A compiler on both x86 and x86_64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/corecore/ — VM, kernel, scheduler, classmgr, drivers.area/vmJVM internals: JIT compilers, GC, VM magic, type system.kind/bugConfirmed bug report with a repro or stack trace.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions