Repository navigation
feat(bytecode): coverage guard + drop dead :set_global opcode - #362
Merged
Merged
Conversation
…code Adds `Bytecode.fully_compiled?/1`, which walks the prototype tree and returns true iff every prototype carries a bytecode encoding — a guard against a prototype silently falling back to the interpreter. A new coverage corpus pins that every covered opcode family compiles end-to-end, with `:goto` / `:label` documented as the one remaining exception. Removes the `:set_global` opcode (builder + executor handler). Modern codegen emits `:set_field` on `_ENV` for free-name assignment (Plan A16) and never produces `:set_global`; it was dead code. `State.set_global/3`, the runtime globals API, is unaffected.
This was referenced Jun 14, 2026
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.
Context
First of three PRs driving the bytecode Dispatcher to 100% opcode coverage so no prototype silently falls back to the interpreter. This PR establishes the invariant the rest of the work defends, and clears one dead-code gap.
The two remaining coverage gaps were
:goto/:label(real, ported in the next PR) and:set_global(dead). This PR handles the guard + the dead one.What changed
Bytecode.fully_compiled?/1— walks the prototype tree, returnstrueiff every prototype carries abytecodeencoding. The guard against a prototype quietly reverting to the interpreter.fully_compiled?/1. One test pinsgoto/labelas the only documented exception — this flips in PR 3.:set_globalopcode — builder (Instruction.set_global/2) + executor handler. Modern codegen emits:set_fieldon_ENVfor free-name assignment (Plan A16) and never produces:set_global. Confirmed zero emitters repo-wide.State.set_global/3(the runtime globals API) is unrelated and untouched.Verification
mix test test/lua/compiler/bytecode_test.exs— 39 passmix test test/lua/vm test/lua/compiler— 1295 pass, 4 skippedmix format --check-formattedcleanFollow-ups
:goto/:labelvia the label-map strategy (encoder label-resolution + dispatcherunwind_blocks).