Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what to set for max on imported 64-bit memories #33

Open
sbc100 opened this issue Feb 10, 2023 · 1 comment
Open

what to set for max on imported 64-bit memories #33

sbc100 opened this issue Feb 10, 2023 · 1 comment

Comments

@sbc100
Copy link
Member

sbc100 commented Feb 10, 2023

Imported, growable memories need to specify a max. In llvm, when we build a DLL, we generally don't care about the upper limit of the imported memory so we try to set the max max here:

https://github.com/llvm/llvm-project/blob/89197b59f597995ecb6b6dc2e262a1ecddeee901/lld/wasm/Writer.cpp#L351

For 32-bit memories the max is simple and obvious 2 ^ 32. For 64-bit memories it looks like 2 ^ 48 was chosen (most likely largely arbitrarily but IIRC that the size of the virtual address space on some 64-bit architectures?). However this currently run up against an implementation defined limit when trying to load such modules in v8:

[Error [CompileError]: WebAssembly.instantiate(): maximum memory size (4294967296 pages) is larger than implementation limit (262144 pages) @+85]
Thrown at:
    at /tmp/emtest_jt9nwb1e/emscripten_test_wasm64_mnmu7cfb/test_pthread_dylink.js:156:7
    at emit (node:events:510:28)
    at node:internal/process/execution:159:25

So for now I think we can modify llvm to emit 2 ^ 34 as the max, but we should probably come up with some better way to signal that we don't care about the maximum, or agree a sensible implementation limit and then embed that into the tools.

@sbc100
Copy link
Member Author

sbc100 commented Feb 10, 2023

Proposed llvm change: https://reviews.llvm.org/D143783

sbc100 added a commit to llvm/llvm-project that referenced this issue Feb 13, 2023
This is current limit in v8.  See
WebAssembly/memory64#33 how we might change
this in the future.

Differential Revision: https://reviews.llvm.org/D143783
CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Feb 14, 2023
This is current limit in v8.  See
WebAssembly/memory64#33 how we might change
this in the future.

Differential Revision: https://reviews.llvm.org/D143783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant