WebAssembly / WebAssembly/custom-page-sizes

Size limit for memories with 1-byte-pages ?

Open
#45 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
13
Forks
6
PR merge metrics
No merged PRs in 30d

Description

It would be nice to be able to bounds-check accesses in a single operation. For example, an i32.load access at address 5 to a memory with length 7 must trap, and it would be nice to just be able to compare 5 to a limit instead of separately comparing 5 and 5+sizeof(u32) to a limit. I am assuming that with 1-byte pages, we get no OS support.

@eqrion suggested having an instance store memory limits for different-sized accesses, so in our example the limit for 32-bit accesses on a memory with length 7 would be 3; you just compare 5 against 3. This is a neat solution that works as long as the length is at least as long as the access size, or if the max size is set such that we can do signed comparisons. However I think as written the spec supports length=0, length=1, length=2^32-1, and also length=2^64-1 for memory64 configurations.

I have a terrible proposal :) Perhaps people have already considered it. Anyway, considering that the JS embedding specifies a max page count of 65536 (for memory32), I propose to keep the max page count to that size for 1-byte pages. It minimizes complexity for bounds checks, because we can do a simple signed comparison in all cases. If it is too constraining, we can raise it, but perhaps not to the whole address space.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or implementation entry points are named. Start by reading the issue's discussion and the WebAssembly custom page-size memory rules, then evaluate the proposed page-count limit against the listed memory lengths and access-size cases. Done means the specification question has a documented decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.