Open
Description
0 is valid as a pointer value in wasm. top-mem would make it invalid.
top-mem simply makes the memory grow downwards from UINT_MAX down to 0. so a 64kB memory goes from UINT_MAX-65535 to UINT_MAX (inclusive), and so on for increasingly bigger memories.
(it is a shame that C and C++ decided 0 was the best way to represent NULL, instead of using -1 which would fault on all major architectures for bigger-than-byte reads. at least we can workaround the issue in wasm.)
Interaction with JS
JS's view of a wasm memory should respect top-mem. that way pointers don't need to be converted/adjusted by JS before indexing the memory.