refactor(vm): tidy chunk boundary for optimizer prep 🧹#161
Merged
Conversation
Chunk now exposes only the low-level `set_jump_offset` primitive; the policy of "what offset to compute from current write position" lives in the compiler where it belongs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wraps the `isize` operand of jump-family opcodes in a `JumpOffset` newtype so the contract has a single definition site and future representations (label IDs, basic-block targets) can be slotted in without touching every call site. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ea59212 to
2a823ed
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
Two small, mechanical refactors that pre-stage the seams a future bytecode optimizer will need, without introducing any optimizer infrastructure or behaviour change.
patch_jumpandwrite_jump_backout ofChunkintoCompiler.Chunknow exposes only the low-levelset_jump_offset(idx, JumpOffset)primitive. The policy of "what offset to compute from the current write position" lives in the compiler, where it belongs.Chunkbecomes closer to "pure data: instructions + constants + spans" with no compile-time emission protocol baked in.JumpOffsetfor jump operands. Replaces rawisizeoperands onJump,JumpIfTrue,JumpIfFalse, andIterNextwith aJumpOffsetnewtype. Gives the contract a single definition site so a future representation change (label IDs, basic-block targets) is a localized edit.(A third item discussed — dropping an unused
Stage/PhantomDatafromChunk— was uncommitted local WIP and didn't produce a commit; the branch matchesmaster'sChunkshape.)Test plan
cargo buildcleancargo test— 389 passed, 0 failedcargo clippy -p ndc_vm --all-targets— no new warnings introduced (baseline 4, after change 4)cargo fmt🤖 Generated with Claude Code