0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing `memfill` op in IR

greenhat opened this issue · comments

I encountered the Wasm memory.fill instruction in the GlobalAlloc::alloc_zeroed function, which is used to zero out the memory allocated by GlobalAlloc::alloc.
Since the memory in Miden VM is guaranteed to be initialized to zeros, I ignored this instruction for now, but we're going to need it in the future.

See semantics at https://webassembly.github.io/spec/core/exec/instructions.html#exec-memory-fill

Tasks

The initial state of memory is guaranteed to be zero (for now at least), but alloc_zeroed is still needed because the allocator itself might free and reuse memory that was previously written to, which will no longer have that guarantee. So we'll definitely need this.

I'll make a note to add memset/memory.fill to the instruction set while I'm in there working on other things.

NOTE: We don't need this for the alpha, since we're leaning on WeeAlloc which doesn't reuse memory AFAIK, but we won't be able to make that assumption longer term.