-
Notifications
You must be signed in to change notification settings - Fork 746
wasm2c: big endian support moves memory on growth which will cause overheads #2599
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
Comments
I am amazed and impressed that anybody is even using our s390x/big-endian support, much less Firefox! That's pretty cool. |
I'm just playing with it for the moment :) |
Still curious how the host interaction works with this. E.g., when passing a string pointer to the host, isn't it all backwards (and pointing to the wrong end) from the host's perspective? |
@rossberg RLBox (the glue layer between Wasm sandboxed libraries and host applications) tends to marshal data from the Wasm memory to host memory both for safety reasons (avoiding time-of-check time-of-use scenarios) as well as to perform ABI fixups. For example, one of the current ABI fixups is that I should caution that this is still early in my testing process. The use of wasm2c in big endian config in Firefox is contingent on whether I am actually able to modify RLBox to hide these differences from the host reasonably well. The upside here is this this gives me an excuse to cleanup the big endian support in wasm2c. |
(Edit: correction, the tests pass. There was a bug in my setup) |
Uh oh!
There was an error while loading. Please reload this page.
@sbc100 @keithw @SoniEx2
The big endian support in wasm2c with
mmap
ed linear memory still moves data when growing memory. This is inefficient. Where possible, it is probably simpler to rely on growing memory in place (similar to the little endian implementation)The context here is Firefox's potential usage of RLBox + wasm2c on the s390x. Beyond the performance concern, an additional issue is that RLBox does not support using wasm2c when memory can be moved.
I believe a fix should be possible.
Approach:
The rough difference behind wasm's little vs. big endian implementation is the accesses to linear memory. In the little endian impl, accessing an offset
i
means we are accessing locationlinear_memory[i]
. On big endian systems we are accessinglinear_memory[linear_memory_size - i - 1]
Thus, we can avoid moving memories, by reserving the max memory with no page permissions, and growing the usable memory from the end of the allocation to the beginning.
I'll try to look into this soon (Any help or thoughts welcome)
The text was updated successfully, but these errors were encountered: