-
Notifications
You must be signed in to change notification settings - Fork 30
Fix least valid pointer value #2240
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
So how come this issue wasn't reproducible in browsers, but only in Wasmer and Wasmtime? |
WebAssembly doesn't reserve low addresses But without "extra inhabitants" of the pointer representation, runtime performance and memory footprint are worse. So assume that compiler driver uses wasm-ld and --global-base=1024 to reserve low 1KB.
6a94890
to
78e3cee
Compare
I confirmed that JavaScriptKit allocates some memories before main func. After JavaScriptKit initial allocation, heap objects are allocated at more than 4KB address, so this issue doesn't happen. |
Can you explain: "extra inhabitants" of the pointer representation? What is this low 1kb used for? |
To distinguish enum cases without adding extra but width. Think that |
Thank you very much for your answer. However, I don't understand it without more context, as I have little experience in this domain. Im trying to do this for my SwiftWasm REPL experiment: I though I could use --global-base flag to achieve this but found it blocked. |
I'm sorry, my first explanation was wrong. I updated my comment. If you are thinking about dynamic linking, it's much more challenging than you think. The most difficult part is making a relative pointer across data and code to be position independent. See this thread for more details. But let me answer your questions respectively just in case:
The memory layout explained by the figure is correct only when passing
No read/write should happen against the lower 1KB. This convention let the compiler assume that
What do you mean "relocated"? "Relocation" is a term that represents a process during the linking, right? I'm not sure what you are asking, sorry. |
Thank you for your helpful answer and the link to the Wasm Support forum thread. |
WebAssembly doesn't reserve low addresses But without "extra inhabitants" of
the pointer representation, runtime performance and memory footprint are
worse. So assume that compiler driver uses wasm-ld and --global-base=1024 to
reserve low 1KB.
Fix #2223