Refactor tuples into typed opcode subclasses#473
Merged
bertysentry merged 3 commits intoMay 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Jawk’s intermediate “tuple” instruction stream from a monolithic, positional-operand Tuple representation into typed opcode-specific tuple subclasses, and updates the execution/optimization code paths to use named accessors. This reduces reliance on fragile operand indexing and supports a smaller, more JIT-friendly dispatch loop in the AVM.
Changes:
- Introduces
Tupleas a typed instruction hierarchy (e.g.,PushLongTuple,AddressTuple,VariableTuple, etc.) and updates tuple construction accordingly. - Updates
PositionTrackerandAVMto consume typed tuples viaPositionTracker.current()and new accessors, extracting larger opcode bodies into helper methods. - Updates tuple optimization tests and peephole optimization logic to work with typed tuples and new index access (
currentIndex()).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/io/jawk/AwkTupleOptimizationTest.java | Updates tuple optimization assertions to use typed tuples and a typed literal extractor. |
| src/main/java/io/jawk/intermediate/Tuple.java | Replaces the monolithic tuple storage with a typed tuple class hierarchy and named accessors. |
| src/main/java/io/jawk/intermediate/PositionTracker.java | Removes positional operand accessors and exposes the current typed tuple plus currentIndex(). |
| src/main/java/io/jawk/intermediate/AwkTuples.java | Updates tuple emission and peephole folding to construct/inspect typed tuples. |
| src/main/java/io/jawk/backend/AVM.java | Switches execution to typed tuple casts/accessors and extracts several opcode implementations into helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Tuplestorage model with typed tuple subclasses tailored to each opcode or opcode group.AwkTuples,PositionTracker, andAVMto construct and consume the new tuple types with named accessors.executeTuples()to keep the dispatch loop smaller and friendlier to JIT optimization.AwkTupleOptimizationTest.Testing
mvn testpassed.mvn verifypassed; the existing compatibility-suite failures remain expected and unchanged.