Fix glob slot access (*X{HASH}) in interpreter eval#212
Merged
Conversation
When accessing glob slots like *X{HASH} inside eval STRING, the interpreter
was incorrectly dereferencing the glob as a hash (returning %-) and then
trying to access the "HASH" key, which caused "No group with name <HASH>"
errors when the glob was aliased to special variables like *-.
The baseline compiler works correctly because RuntimeGlob overrides
hashDerefGetNonStrict() to directly access glob slots via getGlobSlot(),
bypassing hash dereference. The interpreter was using DEREF_HASH + HASH_GET
which doesn't invoke this override.
Solution: Added GLOB_SLOT_GET opcode (230, before LASTOP to avoid generated
section) that detects glob slot access patterns (*X{key}) in
BytecodeCompiler.handleGeneralHashAccess() and emits a single operation
calling glob.hashDerefGetNonStrict(key, package) to match the baseline behavior.
Added documentation comment explaining where to add manual opcodes to prevent
them from being overwritten by the opcode generation tool.
Fixes re/reg_namedcapture.t test 1 (0/2 -> 1/2 passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes glob slot access like
*X{HASH}inside eval STRING when usingJPERL_EVAL_USE_INTERPRETER=1.Problem
When accessing glob slots like
*X{HASH}inside eval STRING, the interpreter was incorrectly dereferencing the glob as a hash (returning%-) and then trying to access the "HASH" key, which caused "No group with name " errors when the glob was aliased to special variables like*-.Example failure:
Root Cause
The baseline compiler works correctly because
RuntimeGloboverrideshashDerefGetNonStrict()to directly access glob slots viagetGlobSlot(), bypassing hash dereference. The interpreter was usingDEREF_HASH + HASH_GETwhich doesn't invoke this override.Solution
Added
GLOB_SLOT_GETopcode (230, before LASTOP to avoid generated section) that:*X{key}) inBytecodeCompiler.handleGeneralHashAccess()glob.hashDerefGetNonStrict(key, package)Changes
GLOB_SLOT_GETopcode in manual section (beforeGENERATED_OPCODES_START)LASTOPfrom 229 to 230BytecodeCompiler.handleGeneralHashAccess()to detect glob slot patternsSlowOpcodeHandler.executeGlobSlotGet()BytecodeInterpreterInterpretedCodeTest Results
re/reg_namedcapture.t: 0/2 → 1/2 passing ✓Notes
The opcode is placed in the manual section before
LASTOPwith clear documentation to prevent it from being overwritten by the opcode generation tool.🤖 Generated with Claude Code