Repository navigation
bugc: give a called function's entry its source range - #400
Merged
Merged
Conversation
gnidan
force-pushed
the
bugc-entry-range
branch
from
October 16, 2026 00:10
0932550 to
703bf32
Compare
A called function's entry JUMPDEST has the function's declaration, the one its invoke names. The end of a body that has no return (the frame teardown and exit JUMP, or the STOP of code) has the function's range, and a block's JUMPDEST has the range of the instruction after it. Code generation is unchanged.
gnidan
force-pushed
the
bugc-entry-range
branch
from
October 16, 2026 00:10
703bf32 to
6f9fd64
Compare
Contributor
|
Check that a block's JUMPDEST has the range of the instruction after it, and that the exit of a body with no return has the function's. Exempt only a JUMPDEST before an inlined call. In the locals check, exempt only the function's range after the body, not the entry and the prologue.
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.
A real (not inlined) internal call's entry JUMPDEST carried the
invokebut nocode, so a debugger stopped there highlighted nothing. It now has the function's declaration, the same range theinvoke'sdeclarationnames.A survey of the examples (and the arcade game) found other instructions bugc adds with no range. This PR gives them one too:
return. The frame teardown and exit JUMP of a function, or theSTOPofcode, has the function's range, as the prologue and the guardSTOPalready do. So a return the source does not write highlights the whole function: the IR has no range for the body's closing brace. Recording that range in the IR and using it here could be a follow-up. The instructions that return a value fromcodenow have thereturnstatement's range; before, they had none.STOPthatcodeleaves out) has the function's range.Two kinds still have no range:
createblock's range is the likely choice, orcode's when there is nocreate.A runtime with no
codeblock has no source to point at, so its compiler-made instructions keep their remark.The new
code-ranges.test.tschecks every instruction of every example at every level, with those exceptions named. It also checks the rules: an entry's range is theinvoke's declaration, a block's JUMPDEST has the range of the instruction after it, and the exit of a body with noreturnhas the function's range. The bytecode digests inactivation-pairing.test.tsare unchanged, so code generation is unchanged. One check inlocal-variables.soundness.test.tsmakes sure no instruction with a range beforelet xlistsx. The function's range also starts there, so the check now exempts that range after the body only. It still checks the entry and the prologue.