Skip to content

+Loops#154

Open
0xGeorgii wants to merge 6 commits intomainfrom
152-loops
Open

+Loops#154
0xGeorgii wants to merge 6 commits intomainfrom
152-loops

Conversation

@0xGeorgii
Copy link
Contributor

No description provided.

@0xGeorgii 0xGeorgii self-assigned this Mar 3, 2026
@0xGeorgii 0xGeorgii added inf2wasm Inference to WASM converting codegen Bytecode emitting labels Mar 3, 2026
@0xGeorgii 0xGeorgii requested a review from Copilot March 3, 2026 07:17
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 90.86538% with 38 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
core/wasm-codegen/src/compiler.rs 90.77% 38 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / break lowering in core/wasm-codegen using the standard WASM block+loop pattern and a new LoopContext depth tracker.
  • Refactor Compiler to store per-function compilation state on self (function body, locals map, frame layout, loop context).
  • Add loop-focused docs and a full set of codegen + execution tests with expected .wasm/.wat fixtures.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Bytecode emitting inf2wasm Inference to WASM converting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants