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

Get rid of wasm_memory_data, use a copying wasm_(read/write)_memory_data instead #156

Closed
SoniEx2 opened this issue Oct 10, 2020 · 0 comments

Comments

@SoniEx2
Copy link

SoniEx2 commented Oct 10, 2020

There are 2 ways to do little-endian VMs on big-endian hosts:

  1. Byteswap every load/store instruction.
    • This is very slow.
  2. Adjust load/store addresses such that the VM sees the memory as little-endian, but no byteswaps are required.
    • This is faster, but requires byteswapping at the C API layer.

The former is faster for IO-bound tasks, whereas the latter is faster for CPU-bound tasks. In practice, nobody uses wasm for IO-bound tasks, because wasm was designed for CPU-bound tasks, as a replacement for asm.js. This means approach 2 is better for wasm.

However, approach 2 is a bit mind-bending, and so maybe not everyone wants to deal with it. Thus, leaving the C API undefined for big-endian hosts might be the best approach to take here.

See also WebAssembly/wabt#1557

So it'd be nice if wasm_memory_data wasn't, and instead the caller had to pass in a buffer for the runtime to copy things into.

@SoniEx2 SoniEx2 changed the title Undefine for big-endian hosts Get rid of wasm_memory_data, use a copying wasm_get_memory_data instead Oct 11, 2020
@SoniEx2 SoniEx2 changed the title Get rid of wasm_memory_data, use a copying wasm_get_memory_data instead Get rid of wasm_memory_data, use a copying wasm_(read/write)_memory_data instead Oct 12, 2020
@SoniEx2 SoniEx2 closed this as completed Feb 3, 2021
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