Skip to content

Add comprehensive interpreter mode documentation#192

Merged
fglock merged 9 commits intomasterfrom
feature/interpreter-documentation-updates
Feb 13, 2026
Merged

Add comprehensive interpreter mode documentation#192
fglock merged 9 commits intomasterfrom
feature/interpreter-documentation-updates

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 13, 2026

Summary

Comprehensive documentation updates for the interpreter mode feature, including architecture documentation, CLI options, changelog updates, and developer guides.

Changes

Documentation Files

Architecture & Design:

  • Updated docs/reference/architecture.md with interpreter module section
  • Added dual execution mode overview (Compiler vs Interpreter)
  • Documented interpreter components: BytecodeInterpreter, BytecodeCompiler, Opcodes, etc.
  • Updated project structure diagram to include interpreter package

CLI Options:

  • Added docs/reference/cli-options.md section for --interpreter flag
  • Documented performance characteristics (~47M ops/sec vs ~82M ops/sec)
  • Explained use cases and execution modes
  • Updated --disassemble option to show both modes

Changelog:

  • Reformatted docs/about/changelog.md version headers to use proper markdown (##)
  • Improved document structure and navigation

Developer Resources:

  • Updated dev/README.md with interpreter/ directory documentation
  • Simplified docs/about/roadmap.md by removing duplicated content

Interpreter Documentation:

  • Updated dev/interpreter/SKILL.md with variable sharing implementation
  • Documented SET_SCALAR opcode, context detection, error handling
  • Removed obsolete Java test harness references

Code Changes

Cleanup:

  • Removed duplicate Java test harnesses from src/test/java/org/perlonjava/interpreter/
    • ClosureTest.java, EvalStringTest.java, ForLoopBenchmark.java, ForLoopTest.java, InterpreterTest.java
    • Testing now done via Perl test files in dev/interpreter/tests/

Simplification:

  • Simplified BytecodeInterpreter.java RETURN opcode handling
  • Uses polymorphic getList() instead of multiple instanceof checks

Testing

  • All unit tests pass (make test-unit)
  • Build successful (make build)
  • Interpreter tests run correctly via ./jperl dev/interpreter/tests/*.t

Documentation Coverage

✅ Architecture documentation (docs/reference/architecture.md)
✅ CLI options reference (docs/reference/cli-options.md)
✅ Changelog formatting (docs/about/changelog.md)
✅ Developer guide (dev/README.md, dev/interpreter/SKILL.md)
✅ Removed duplicate test code

Performance

  • Interpreter mode: ~47M ops/sec (1.75x slower than compiler, within 2-5x target ✓)
  • Compiler mode: ~82M ops/sec (after JIT warmup)
  • Both modes share 100% of runtime APIs

Key Features Documented

  • Register-based bytecode interpreter with tableswitch optimization
  • Variable sharing between interpreted and compiled code
  • Closures and bidirectional calling support
  • Context detection (VOID/SCALAR/LIST) for wantarray semantics
  • SET_SCALAR opcode for reference preservation
  • Error reporting with accurate line numbers

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

fglock and others added 9 commits February 13, 2026 09:22
Relocated test files from src/main/java to src/test/java to separate
test code from production code:
- ClosureTest.java
- EvalStringTest.java
- ForLoopBenchmark.java
- ForLoopTest.java
- InterpreterTest.java

These are standalone test harnesses with main() methods (not JUnit tests),
but belong in the test source tree rather than main source tree.

Updated SKILL.md documentation to reflect new file locations and
recommended Gradle execution method (which handles classpath automatically).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace multiple instanceof checks with single getList() call.
RuntimeBase.getList() already handles all cases:
- RuntimeList returns itself
- RuntimeScalar wraps in RuntimeList
- RuntimeArray converts to RuntimeList
- Other types use their getList() implementation

This eliminates redundant type checking and relies on the existing
polymorphic behavior in the runtime type hierarchy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Updated architecture documentation to reflect the dual execution modes:
- Added Compiler Mode vs Interpreter Mode comparison with performance metrics
- Added interpreter/ package to project structure diagram
- Added dev/interpreter/ documentation directory to structure
- Added src/test/java/org/perlonjava/interpreter/ test harnesses
- New "Interpreter" section describing core components:
  - BytecodeInterpreter (register-based VM with tableswitch optimization)
  - BytecodeCompiler (AST to bytecode with register allocation)
  - InterpretedCode (bytecode container with disassembler)
  - Opcodes (instruction set organized into categories)
  - SlowOpcodeHandler (rare operations via SLOW_OP gateway)
  - VariableCaptureAnalyzer (variable sharing analysis)
- Key features: register-based architecture, runtime API sharing,
  closures, bidirectional calling, variable sharing via persistent storage
- Performance: 47M ops/sec (1.75x slower than compiler)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Corrected:
- PerlLanguageProviderTest.java → PerlScriptExecutionTest.java (actual filename)
- Alphabetized interpreter test files to match directory listing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removed src/test/java/org/perlonjava/interpreter/ containing:
- ClosureTest.java
- EvalStringTest.java
- ForLoopBenchmark.java
- ForLoopTest.java
- InterpreterTest.java

These Java test harnesses were duplicates/redundant. The interpreter
is tested using Perl test files in dev/interpreter/tests/ which are
more appropriate for testing Perl semantics.

Updated documentation:
- SKILL.md: Removed references to Java test harnesses, updated benchmark
  instructions to use Perl benchmark script (for_loop_benchmark.pl)
- architecture.md: Removed src/test/java/org/perlonjava/interpreter/
  from project structure diagram

Testing is now done exclusively through:
- Perl test files (*.t) in dev/interpreter/tests/
- Perl benchmark scripts (*.pl) in dev/interpreter/tests/
- Standard unit tests via make test-unit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added new "Execution Mode Options" section documenting the --interpreter flag:
- Explains interpreter mode vs compiler mode (default)
- Performance characteristics: ~47M ops/sec vs ~82M ops/sec
- Use cases: faster startup, lower memory, ideal for short-lived scripts
- Notes that both modes share 100% of runtime APIs

Updated --disassemble option:
- Shows how to use with both compiler and interpreter modes
- Explains that bytecode format differs between modes

Added examples in "Combining Options" section:
- Quick script execution with interpreter mode
- Debugging interpreter bytecode with --interpreter --disassemble

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changed format from:
- **vX.X.X**: Title

To:
## vX.X.X: Title

This uses proper markdown header syntax (##) instead of bold list items,
making the document structure more consistent and easier to navigate.
No text content was changed, only formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added new section documenting the interpreter/ subdirectory:
- Comprehensive documentation files (SKILL.md, STATUS.md, TESTING.md, BYTECODE_DOCUMENTATION.md)
- Architecture design documents in architecture/ subdirectory
- Test files for interpreter-specific features in tests/ subdirectory
- Key features: register-based bytecode interpreter with tableswitch optimization
- Performance: ~47M ops/sec (1.75x slower than compiler, within 2-5x target)
- Variable sharing, closures, bidirectional calling, and context detection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Simplified documentation for better readability:

dev/README.md:
- Condensed interpreter section to essential information
- Removed detailed feature list (available in dedicated docs)

docs/about/roadmap.md:
- Removed v5.42.3 upcoming milestone (now in changelog)
- Removed Work in Progress section (now in changelog)

docs/reference/cli-options.md:
- Reordered compiler mode before interpreter mode for clarity
- Simplified interpreter mode description
- Removed redundant "Both modes share..." statement
- Kept essential performance and use case information

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fglock fglock merged commit 430a17b into master Feb 13, 2026
2 checks passed
@fglock fglock deleted the feature/interpreter-documentation-updates branch February 13, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant