Skip to content

Fix --interpreter flag propagation, add times opcode, fix print/printf LIST context#276

Merged
fglock merged 1 commit into
masterfrom
fix-interpreter-global-flag
Mar 6, 2026
Merged

Fix --interpreter flag propagation, add times opcode, fix print/printf LIST context#276
fglock merged 1 commit into
masterfrom
fix-interpreter-global-flag

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 6, 2026

Summary

  • Global interpreter flag: Added FORCE_INTERPRETER (static final) in RuntimeCode.java, checked in both PerlLanguageProvider.compileToExecutable() and EmitterMethodCreator.createRuntimeCode(). Previously, --interpreter / JPERL_INTERPRETER=1 was not propagated to subroutine compilation via createRuntimeCode(), causing 21 JVM-compiled anonymous classes even in interpreter mode.
  • times opcode: Added TIMES = 373 with compiler emission, runtime handler (Time.times(ctx)), interpreter dispatch, and disassembly support. Fixes Unsupported operator: times in Benchmark.pm.
  • Print/say LIST context fix: CompileBinaryOperator was compiling print HANDLE LIST content in the callers context (often SCALAR). In scalar context, ListNode evaluates all but the last element for side effects only - so print timestr(...), newline called timestr but only printed newline. Fixed by forcing LIST context.
  • printf/binmode/seek/eof/close/fileno/getc context fix: Same LIST context issue in compileBinaryAsListOp.

Test plan

  • mvn test - all JVM backend tests pass
  • JPERL_INTERPRETER=1 ./jperl dev/bench/benchmark_lexical.pl - produces correct timing output
  • JPERL_INTERPRETER=1 ./jperl --disassemble - shows only interpreter bytecode, no JVM assembly
  • JPERL_SHOW_FALLBACK=1 ./jperl --interpreter - no JVM compilation succeeded messages
  • JPERL_INTERPRETER=1 ./jperl -e 'printf "%s %d\n", "hello", 42' - correct output

Generated with Devin

- Add FORCE_INTERPRETER static final flag checked in compileToExecutable()
  and createRuntimeCode() so JPERL_INTERPRETER=1 is truly global
- Add TIMES opcode (373) for Perl's times() builtin
- Fix print/say LIST context: CompileBinaryOperator was compiling print
  content in caller's context (often SCALAR), causing ListNode to drop
  all but the last element. Now forces LIST context.
- Fix printf/binmode/seek/eof/close/fileno/getc args context in
  compileBinaryAsListOp for the same reason.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit 694c9bd into master Mar 6, 2026
2 checks passed
@fglock fglock deleted the fix-interpreter-global-flag branch March 6, 2026 14:00
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