binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

[Custom Page Sizes] Feature/support custom pages size

Open BilelGho opened this issue 7 months ago • 3 comments

This implements the feature across the toolchain by adding the page size as an attribute of the memory instead of a constant.

I added the tests from the proposal repo to spec/test (not sure if it was the right move)

Fixes: #6873

BilelGho avatar Jul 01 '25 09:07 BilelGho

Sorry, when I pushed this I wasn't aware of the trsting structure and didn't pay attention how to run it. I am currently working on making all the tests run and will push changes once done.

BilelGho avatar Jul 02 '25 21:07 BilelGho

Tests working now. Most of the edits are straightforward and are about extending the core Memory interface to include a memory page size, stored as a log2 and updating the parser, validator, binary reader/writer, interpreter, the wasm2js glue, and related passes.

Most of the changes in the passes involved supporting a variable page size, whose size is provided and stored as a log2. The pass that involved some change in the logic is the multi-memory lowering. The combined memory would have the minimum page size of the memories to be unified. memory.grow and memory.size implementations are adapted accordingly. The secondary memory created in instrumenter.cpp still uses the default page size.

Tests from the proposal are added. However, due to lacking linking verification at instantiation in the interpreter, some tests with invalid modules that were expected to failed did not and therefore are skipped in the configuration.

BilelGho avatar Jul 08 '25 14:07 BilelGho

@BilelGho, do you have time to continue this work?

We have had a request that emscripten supports custom page sizes which in turn requires this PR to land: https://github.com/emscripten-core/emscripten/discussions/25885

sbc100 avatar Dec 01 '25 16:12 sbc100