Wire system call stubs to real runtime implementations#223
Merged
Conversation
…ority, setpriority to real runtime implementations via MiscOpcodeHandler
…etsockopt, getpgrp, setpgrp, getpriority, setpriority
…ler dispatch, CompileOperator, BytecodeInterpreter
…kage, fix B::svref_2object for CODE scalars
…ix SELECT with empty ListNode
… print default filehandle
…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)
9f249fd to
f11df9a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several system call operators in the bytecode interpreter were wired to dead
SlowOpcodeHandlerstubs that either threwUnsupportedOperationExceptionor returned stub values. The real implementations already existed in the runtime.Operators fixed
chown→ChownOperator.chown()waitpid→WaitpidOperator.waitpid()setsockopt→IOOperator.setsockopt()getsockopt→IOOperator.getsockopt()getpgrp→Operator.getpgrp()setpgrp→Operator.setpgrp()getpriority→Operator.getpriority()setpriority→ stub (no native impl yet, returns 0)Changes
MiscOpcodeHandler.java: Added cases for all 8 operatorsBytecodeInterpreter.java:executeSystemOpsnow delegates toMiscOpcodeHandlerinstead of dead stubsCompileOperator.java: Removed old custom emit code forgetpgrp/setpgrp/getpriority(used wrong format); they now use the standardrd argsReg ctxformat via the generic handler