WebAssembly / custom-page-sizes

Other
3 stars 1 forks source link

WAT syntax for custom page sizes? #6

Closed fitzgen closed 6 months ago

fitzgen commented 6 months ago

The overview is using the following strawperson syntax for specifying a 512-byte page size, where the power-of-two page size is directly written:

(memory (page_size 512))

This means that text parsers would need to check for and reject non-power-of-two values like (page_size 7).

But if we use log-encoding in the binary format, maybe we should also use logs in the text format? Relevant prior art is alignment of memory accesses, which is log-encoded in the binary but the power-of-two alignment is written directly in the text format. And therefore text parsers do need to check for and reject non-power-of-two alignments. I suppose we should do the same thing with page sizes here, unless anyone wants to argue otherwise.

Also feel free to bikeshed the (page_size N) syntax, I guess.

rossberg commented 6 months ago

Consistency with prior art in the text format suggests the following:

All together, along with the Wasm 64 proposal, that would give us the following consistent scheme:

(memory i64 1 10 (page 4096))
(table i64 1 10 (ref $t))