0xMiden / 0xMiden/compiler

Wasm memory.size/memory.grow use Miden heap state instead of the module memory declaration

未關閉
#1,184 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
115
分支
84
平均合併
1 天 8 小時
30 天內合併 PR
15

描述

## Summary

The Wasm translator maps `memory.size` and `memory.grow` to Miden heap intrinsics. This can make a Wasm module observe heap page state rather than the module's declared linear memory size and max.

Affected commit checked: `17eb665e52f3c2a519f8aa58c7dff1335ba63887` on `next`.

## Steps to reproduce

Public repro:

https://github.com/Kuhai9801/miden-int32-to-uint-ci/actions/runs/27597467547

The repro models a Wasm memory declared with one page and compares that with the current zero-initialized heap-backed size.

## Expected behavior

For a module with one declared memory page, `memory.size` should report `1`. `memory.grow` should respect the Wasm memory maximum.

## Actual behavior

The heap-backed path reports `0` for the same initial state in the repro, and growth is checked against heap capacity rather than the Wasm memory declaration.

## Notes

`frontend/wasm/src/code_translator/mod.rs` maps `Operator::MemorySize` and `Operator::MemoryGrow` to `builder.mem_size` / `builder.mem_grow`. The parsed Wasm memory declaration appears not to be the source of truth for these operations.

貢獻指南

開啟貢獻指南

研究方向

該問題位於 `frontend/wasm/src/code_translator/mod.rs` 中,其中 `Operator::MemorySize` 和 `Operator::MemoryGrow` 被映射到 `builder.mem_size` 和 `builder.mem_grow`。首先,檢查 Wasm 記憶體宣告的解析過程,以了解其預期的大小和最大值。然後,修改翻譯程式碼,使其使用這些宣告的值,而不是 Miden 堆積的狀態。連結的再現測試展示了預期行為。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
rust, wasm
領域
compilers
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。