Repository navigation
Lower residual breaks to wasm br depths - #177
Open
dcharlot65-openie wants to merge 1 commit into
Open
dcharlot65-openie wants to merge 1 commit into
dcharlot65-openie wants to merge 1 commit into
Conversation
The carried count stays the source depth. An if does not decrement it, and break 0 is the local exit. The br index adds each intervening if and a loop's restart label, which the residual count does not include. Co-authored-by: David Charlot <dcharlot65-openie@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #173
rce emit wasmfor a graph term still returns from a kernel status(if ...). Thatifis not a break target. A structured control backend now lowers a residual break tobr N.The carried count is the source depth: ONE-15 writes
set e = d; break 0.break 0is the local exit and does not decremente. A block or a loop decrements once. Anifdoes not. That isone/eval.rs(BlockandLoopsubtract one;Ifreturns the inner control unchanged) and W2, which counts enclosing blocks and loops. The ledger row of 2026-11-09 andBreak.leanstepExitsay the same. ONE-15 says "construct" and does not say "not an if". The evaluator and W2 are the clause that decides, and they agree with that reading, so thee = d + 1initialisation is not used.WebAssembly counts every
block,loopandifas abrlabel, and a branch to alooprestarts it. A loop is therefore an exitblockaround aloop. The exit block is the one residual step. The restart label is wasm structure only, as anifis.ResidualandLabelDepthare separate types. Thebrimmediate is how many wasm labels lie between the break and its residual target, including that target.The integer carrier is wrapping i64, which is
int.wadd,int.wsubandint.wmulatint[-2^63, 2^63 - 1]. Comparisons are signed. The gate and the specification are unchanged.Tests: 10 core programs (nested blocks and loops, intervening
ifs, depths 0, 1 and 2,break 0as a local exit, and breaks that cross severalifs and loops). Each module is assembled withwat, checked withwasmparser, and instantiated withwasmi. The exportrunmatches the core evaluator. A further table checksbrdepths on label stacks directly.Base
86b8efcf6f9af6d46a04c0998d105037d0c1002b. Not merged. Not deployed.