Skip to content

Using shared WebAssembly.Memory (SharedArrayBuffer) with non-multithreaded builds? #16596

Answered by kripken
donalffons asked this question in Q&A
Discussion options

You must be logged in to vote

Linking with -sSHARED_MEMORY should support this use case, and it works when I try it on hello world, by adding this right before the check of Module['wasmMemory']:

    Module['wasmMemory'] = new WebAssembly.Memory({
      'initial': INITIAL_MEMORY / 65536,
      'maximum': INITIAL_MEMORY / 65536,
      'shared': true
    });

Perhaps check the wasm file, and see that it declares the memory properly as shared? (Is there a chance you are seeing an old wasm file in the cache?) You should see this:

$ wasm-dis b.out.wasm | grep memory
 (import "env" "memory" (memory $mimport$0 (shared 256 256)))

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@kripken
Comment options

@sbc100
Comment options

@kripken
Comment options

@donalffons
Comment options

@sbc100
Comment options

Answer selected by donalffons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants