Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR adds WebAssembly code generation support for Inference loop and break statements, including structured control-flow depth tracking, and introduces a comprehensive test suite plus fixtures to validate both generated bytes and runtime behavior.
Changes:
- Implement
loop/breaklowering incore/wasm-codegenusing the standard WASMblock+looppattern and a newLoopContextdepth tracker. - Refactor
Compilerto store per-function compilation state onself(function body, locals map, frame layout, loop context). - Add loop-focused docs and a full set of codegen + execution tests with expected
.wasm/.watfixtures.
Reviewed changes
Copilot reviewed 31 out of 44 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_data/codegen/wasm/loops/void_loop/void_loop.wat | New WAT fixture for void-returning loop |
| tests/test_data/codegen/wasm/loops/void_loop/void_loop.wasm | New WASM fixture for void-returning loop |
| tests/test_data/codegen/wasm/loops/void_loop/void_loop.inf | New source fixture for void-returning loop |
| tests/test_data/codegen/wasm/loops/simple_loop/simple_loop.wat | New WAT fixture for basic conditional loops |
| tests/test_data/codegen/wasm/loops/simple_loop/simple_loop.wasm | New WASM fixture for basic conditional loops |
| tests/test_data/codegen/wasm/loops/simple_loop/simple_loop.inf | New source fixture for basic conditional loops |
| tests/test_data/codegen/wasm/loops/nondet_then_break/nondet_then_break.wasm | New WASM fixture for non-det block inside loop + break |
| tests/test_data/codegen/wasm/loops/nondet_then_break/nondet_then_break.inf | New source fixture for non-det block inside loop + break |
| tests/test_data/codegen/wasm/loops/nested_loop/nested_loop.wat | New WAT fixture for nested loops |
| tests/test_data/codegen/wasm/loops/nested_loop/nested_loop.wasm | New WASM fixture for nested loops |
| tests/test_data/codegen/wasm/loops/nested_loop/nested_loop.inf | New source fixture for nested loops |
| tests/test_data/codegen/wasm/loops/loop_zero_iters/loop_zero_iters.wat | New WAT fixture for zero-iteration loop |
| tests/test_data/codegen/wasm/loops/loop_zero_iters/loop_zero_iters.wasm | New WASM fixture for zero-iteration loop |
| tests/test_data/codegen/wasm/loops/loop_zero_iters/loop_zero_iters.inf | New source fixture for zero-iteration loop |
| tests/test_data/codegen/wasm/loops/loop_with_if/loop_with_if.wat | New WAT fixture for loops containing if/else |
| tests/test_data/codegen/wasm/loops/loop_with_if/loop_with_if.wasm | New WASM fixture for loops containing if/else |
| tests/test_data/codegen/wasm/loops/loop_with_if/loop_with_if.inf | New source fixture for loops containing if/else |
| tests/test_data/codegen/wasm/loops/loop_with_array/loop_with_array.wat | New WAT fixture for loops interacting with arrays/frame layout |
| tests/test_data/codegen/wasm/loops/loop_with_array/loop_with_array.wasm | New WASM fixture for loops interacting with arrays/frame layout |
| tests/test_data/codegen/wasm/loops/loop_with_array/loop_with_array.inf | New source fixture for loops interacting with arrays/frame layout |
| tests/test_data/codegen/wasm/loops/loop_return_array/loop_return_array.wat | New WAT fixture for early return from loop with arrays |
| tests/test_data/codegen/wasm/loops/loop_return_array/loop_return_array.wasm | New WASM fixture for early return from loop with arrays |
| tests/test_data/codegen/wasm/loops/loop_return_array/loop_return_array.inf | New source fixture for early return from loop with arrays |
| tests/test_data/codegen/wasm/loops/loop_in_nondet/loop_in_nondet.wasm | New WASM fixture for loops inside non-det blocks |
| tests/test_data/codegen/wasm/loops/loop_in_nondet/loop_in_nondet.inf | New source fixture for loops inside non-det blocks |
| tests/test_data/codegen/wasm/loops/loop_break_early/loop_break_early.wat | New WAT fixture for early break from loop |
| tests/test_data/codegen/wasm/loops/loop_break_early/loop_break_early.wasm | New WASM fixture for early break from loop |
| tests/test_data/codegen/wasm/loops/loop_break_early/loop_break_early.inf | New source fixture for early break from loop |
| tests/test_data/codegen/wasm/loops/loop_accumulator/loop_accumulator.wat | New WAT fixture for accumulator-style loops |
| tests/test_data/codegen/wasm/loops/loop_accumulator/loop_accumulator.wasm | New WASM fixture for accumulator-style loops |
| tests/test_data/codegen/wasm/loops/loop_accumulator/loop_accumulator.inf | New source fixture for accumulator-style loops |
| tests/test_data/codegen/wasm/loops/infinite_loop_break/infinite_loop_break.wat | New WAT fixture for infinite loops with break |
| tests/test_data/codegen/wasm/loops/infinite_loop_break/infinite_loop_break.wasm | New WASM fixture for infinite loops with break |
| tests/test_data/codegen/wasm/loops/infinite_loop_break/infinite_loop_break.inf | New source fixture for infinite loops with break |
| tests/test_data/codegen/wasm/loops/break_nested_if/break_nested_if.wat | New WAT fixture for break under nested ifs |
| tests/test_data/codegen/wasm/loops/break_nested_if/break_nested_if.wasm | New WASM fixture for break under nested ifs |
| tests/test_data/codegen/wasm/loops/break_nested_if/break_nested_if.inf | New source fixture for break under nested ifs |
| tests/src/codegen/wasm/mod.rs | Registers the new loops wasm-codegen test module |
| tests/src/codegen/wasm/loops.rs | Adds loop codegen byte/WAT validation and Wasmtime execution tests (+ regen helpers) |
| core/wasm-codegen/src/memory.rs | Updates frame-layout documentation + adjusts stack-related tests |
| core/wasm-codegen/src/compiler.rs | Implements loop/break lowering and refactors per-function compiler state |
| core/wasm-codegen/docs/loops-lowering.md | New design doc describing loop/break lowering and depth tracking |
| core/wasm-codegen/README.md | Updates README to reflect loop/break support + links new doc |
| CHANGELOG.md | Records loop/break implementation and new fixtures/tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Georgii Plotnikov <accembler@gmail.com>
Signed-off-by: Georgii Plotnikov <accembler@gmail.com>
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.
No description provided.