llrt icon indicating copy to clipboard operation
llrt copied to clipboard

llrt crashes when trying to load wasm

Open teidesu opened this issue 11 months ago • 4 comments

/*
https://webassembly.github.io/wabt/demo/wat2wasm/

(module
    ;; add(a, b) returns a+b
    (func $add (export "add") (param $a i32) (param $b i32) (result i32)
        (i32.add (local.get $a) (local.get $b))
    )
)
*/
const bytes = Buffer.from(
    'AGFzbQEAAAABBwFgAn9/AX8DAgEABwcBA2FkZAAACgkBBwAgACABagsAGARuYW1lAQYBAANhZGQCCQEAAgABYQEBYg==',
    'base64'
)
const wasm = new WebAssembly.Module(bytes)
console.log(wasm)
console.log('wasm loaded!')

llrt outputs nothing (exiting with code 0 right before the console.logs), while on node this code works fine

$ ./llrt llrt-test.js
$ node llrt-test.js  
Module [WebAssembly.Module] {}
wasm loaded!

LLRT (darwin arm64) 0.1.10-beta

teidesu avatar Mar 05 '24 14:03 teidesu

Hi @teidesu. Thanks for the report. Unfortunately, WASM is not supported at the moment. WASM requires a warm runtime that will significantly add to the complexity of this project and contribute to startup time. There are lightweight alternatives, but they also need to also interop with our engine QuickJS and Rust that makes it a less prioritized feature right now

richarddavison avatar Mar 05 '24 21:03 richarddavison

at least i think it would be nice for the runtime to tell what's wrong and not just crash

teidesu avatar Mar 05 '24 21:03 teidesu

at least i think it would be nice for the runtime to tell what's wrong and not just crash

It should not just crash. Where are you running this? Runnin on my local machine gives:

ReferenceError: 'WebAssembly' is not defined
    at <anonymous> (index.mjs:15:18)

richarddavison avatar Mar 05 '24 22:03 richarddavison

Where are you running this?

sorry, should have mentioned in the op

macOS 14.2.1 (23C71), Darwin 23.2.0 MacBook M1 Pro (2021)

just checked on linux arm, works fine indeed

teidesu avatar Mar 06 '24 10:03 teidesu