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

WASM instantiation doesn't work properly #2544

Closed
ry opened this issue Jun 19, 2019 · 3 comments · Fixed by #2548
Closed

WASM instantiation doesn't work properly #2544

ry opened this issue Jun 19, 2019 · 3 comments · Fixed by #2548
Labels
bug Something isn't working correctly

Comments

@ry
Copy link
Member

ry commented Jun 19, 2019

Here's an example program:

const global = new WebAssembly.Global({value:'i32', mutable:true}, 0);
const mem = new WebAssembly.Memory({initial:10, maximum:100});

let wasmImports = {
  js: { global, mem },
};

async function main() {
  console.log(" ok 1");
  let bytes = Deno.readFileSync('./global.wasm');
  console.log(" ok 2");
  window.wasm = await WebAssembly.instantiate(bytes, wasmImports)
  console.log(" ok 3");
}

main();

It will never reach "ok 3"

The file global.wasm is produced from the following file global.wat:

(module
  (global $g (import "js" "global") (mut i32))
  (import "js" "mem" (memory 1))
  (func (export "getGlobal") (result i32)
        (global.get $g))
  (func (export "incGlobal")
        (global.set $g
                    (i32.add (global.get $g) (i32.const 15))))
  (func (export "retSize") (result i32)
        (memory.size)
  )
)

by running wat2wasm global.wat

@ry ry added the bug Something isn't working correctly label Jun 19, 2019
@kevinkassimo
Copy link
Contributor

#1325 is also related to this: seems we currently do not wait for any async wasm operations.

@ry
Copy link
Member Author

ry commented Jun 19, 2019

Debugging further reveals that setting the V8 flag --no-wasm-async-compilation will make this work properly. I think that v8::platform::PumpMessageLoop() needs to be called in order to support async compilation.

@ry
Copy link
Member Author

ry commented Jun 19, 2019

@ry ry closed this as completed in #2548 Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants