Skip to content

Wire system call stubs to real runtime implementations#223

Merged
fglock merged 10 commits intomasterfrom
fix-slowopcode-stubs
Feb 23, 2026
Merged

Wire system call stubs to real runtime implementations#223
fglock merged 10 commits intomasterfrom
fix-slowopcode-stubs

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Feb 23, 2026

Summary

Several system call operators in the bytecode interpreter were wired to dead SlowOpcodeHandler stubs that either threw UnsupportedOperationException or returned stub values. The real implementations already existed in the runtime.

Operators fixed

  • chownChownOperator.chown()
  • waitpidWaitpidOperator.waitpid()
  • setsockoptIOOperator.setsockopt()
  • getsockoptIOOperator.getsockopt()
  • getpgrpOperator.getpgrp()
  • setpgrpOperator.setpgrp()
  • getpriorityOperator.getpriority()
  • setpriority → stub (no native impl yet, returns 0)

Changes

  • MiscOpcodeHandler.java: Added cases for all 8 operators
  • BytecodeInterpreter.java: executeSystemOps now delegates to MiscOpcodeHandler instead of dead stubs
  • CompileOperator.java: Removed old custom emit code for getpgrp/setpgrp/getpriority (used wrong format); they now use the standard rd argsReg ctx format via the generic handler

…ority, setpriority to real runtime implementations via MiscOpcodeHandler
…etsockopt, getpgrp, setpgrp, getpriority, setpriority
…ler dispatch, CompileOperator, BytecodeInterpreter
…x SELECT robustness, add EvalStringHandler package sync

- Revert BytecodeCompiler.compile() package sync (from fcac2c3) which broke
  signatures.t by corrupting register allocation in subroutine compilation
- Restore CompileOperator print path to original single-register PRINT emit
  (a12f6bc select fix is preserved)
- Fix BytecodeInterpreter SELECT handler to accept RuntimeScalar (LOAD_UNDEF)
  as well as RuntimeList — empty ListNode compiles to LOAD_UNDEF
- Add targeted package sync in EvalStringHandler after BytecodeCompiler
  construction so *named resolves to correct package in eval STRING
- RuntimeCode.DISASSEMBLE: new static flag set by JPERL_DISASSEMBLE env var or
  --disassemble CLI flag; prints interpreter bytecode for each eval STRING
- BytecodeCompiler.setCompilePackage(): new public method to sync compile-time
  package from eval call site
- RuntimeCode.evalStringWithInterpreter: call setCompilePackage() so bare names
  like *named compile to FOO3::named instead of main::named; fixes
  eval q[*named{CODE}] returning undef in JPERL_EVAL_USE_INTERPRETER=1 mode
- EvalStringHandler: add DISASSEMBLE output; document why setCompilePackage
  must NOT be called here (corrupts die/warn location baking)
- ArgumentParser: set RuntimeCode.DISASSEMBLE when --disassemble is passed

stash.t: 34/56 passing with JPERL_EVAL_USE_INTERPRETER=1 (was 16)
signatures.t: 597/908 passing (unchanged from HEAD)
…erpretedCode

Store the compile-time package in InterpretedCode.compilePackage (set by
BytecodeCompiler from symbolTable.getCurrentPackage() when building the code).

EvalStringHandler now uses currentCode.compilePackage instead of
InterpreterState.currentPackage (runtime package). This matches exactly what
evalStringHelper (JVM path) does via capturedSymbolTable.snapShot():
- compile-time package = package at the eval call site in source
- runtime package = package last set by a 'package Foo;' statement at runtime

Using the runtime package was wrong: it caused bare names like *named to
resolve to the wrong package when multiple package declarations had run.

stash.t: 34/56 passing with and without JPERL_EVAL_USE_INTERPRETER=1 (was 16)
signatures.t: 597/908 passing (no regression)
@fglock fglock force-pushed the fix-slowopcode-stubs branch from 9f249fd to f11df9a Compare February 23, 2026 18:52
@fglock fglock merged commit 180a29b into master Feb 23, 2026
2 checks passed
@fglock fglock deleted the fix-slowopcode-stubs branch February 23, 2026 19: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