Skip to content

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

Closed

Description

@SoniEx2

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.

Activity

  1. changed the title [-]Undefine for big-endian hosts[/-] [+]Get rid of wasm_memory_data, use a copying wasm_get_memory_data instead[/+] on Oct 11, 2020
  2. 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[/+] on Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions