-
Notifications
You must be signed in to change notification settings - Fork 693
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
How is linear memory allocated #227
Comments
The two engines which implement asm.js support this. And I just added ArrayBuffer.transfer, which Chrome/FF already have, so if Safari joins the mix (@pizlonator) it seems like this should be fine (and it was pretty easy to add, so I don't see much motivation against it). In any case, I was envisioning that a wasm module requests a CommitHeapSize and a ReserveHeapSize, which would be a contiguous address space (i.e. |
What's currently in the design [1] is that a heap is private state of a module, created when the module is first loaded. Not explicitly documented yet is it that the "memory initialization section" [2] would be the place to declare the initial size (and initial state, analogous to what native binaries do with The two problems I see with I don't really understand the proposal to let the module allocate its own memory since it would mean starting execution w/o a heap (so no |
It looks like the current docs mention Also not clear to me in the docs is where |
Yes, I think it would be good to clarify after reaching agreement here. I'd lean towards a limited developer-side Fixed size at load time seems limiting, and so does Developers don't choose where the heap is, they just choose its size (since wasm implies a hidden base). |
What functionality are you proposing it would have that is more powerful than For anything non-trivial, perhaps it makes sense to stick to |
I'm not sure I'd initially give it that much more capabilities:
We should probably offer It would however be nice if the low-address page could be mapped as That allows us to:
|
As far as I can tell, the additional power you are proposing over I didn't follow the part about removing magic. Are you saying you see a problem with a wasm application accessing |
As soon as we start sharing heaps between modules or doing similar things, we'll want the ability to use Creating deadzones with |
@kripken: "magic" refers to the |
That seems to add magic - I still don't follow what you mean by "remove some magic" earlier? What is the current magic that this removes? |
The current suggestion automagically sets some |
I see, thanks, that's the part at paragraph 3 here, I now see. Do we agree that |
I think |
Ok, it looks like most of us agree that mmap is the better option, so perhaps there just isn't a reason to do
How does that sound? |
@kripken sgtm :-) |
Opened #285. |
Sorry to be late to the party.
I object to WebKit doing this. We don’t currently have a plan to “support” asm.js in the sense of recognizing “use asm”, and there is no good way to reconcile our plain-JS singleton-based constant inference and reassigning the HEAP variables.
|
All the talk of memory reminds me that we haven't discussed how WebAssembly modules get their memory.
Current implementations:
WebAssembly, at least initially, shares its virtual memory space with other parts of the browser, which means that over-allocation will lead to fragmentation and potentially virtual memory exhaustion. This is a problem e.g. on 32-bit Windows XP systems which are still pretty big usecases.
Allocating physical memory lazily also means that an application can fault at runtime for any read/write that touches memory that was never used and now needs to be allocated. I think it's a desirable feature, but without signal handling it's kind of hard to handle!
Also, what kind of alignment and power-of-two size guarantees do we make, if any?
I think it would be great to support
mmap
, and on_start
just allocate the heap with some restricted flags. We can decide to restrict what can be done initially (don't be lazy, allocate all physical memory, don't allow reallocation), and loosen these restrictions later. This is similar to passing in memory from the embedder, but can be made more powerful later while still being polyfillable (the polyfill can behave the same as asm.js does).The text was updated successfully, but these errors were encountered: