Wasm compilation exceeds internal limits in this context for arguments provided

So, I'm trying to create a WebAssembly module from an ArrayBuffer.

C code:

#include <stdio.h>

int main() {
      printf("hello, world!\n");
        return 0;
}

I will compile it like this:

$ emcc -O2 hello.c -s WASM=1 -o hello.html

I am running a local http server. And I'm trying to download it in my browser like this:

fetch('hello.wasm')
.then(res => res.arrayBuffer())
.then(buff => WebAssembly.Module(buff));

And I get the following error:

Unprepared (in promise) RangeError: WebAssembly.Module (): The Wasm compilation exceeds the internal limits in this context for the arguments provided with fetch.then.then.buff (: 1: 77) with

I have nothing to do with this error, and I can not find anything through a web search.

Any help was kindly appreciated.

Thank!

+4
source share
1 answer

WebAssembly.Module , , .

:

fetch('hello.wasm').then(response =>
    response.arrayBuffer()
).then(buffer =>
    WebAssembly.instantiate(buffer, importObj)
).then(({module, instance}) =>
    instance.exports.f()
);

WebAssembly.instantiate, importObject, (, WebAssembly.Memory).

, , main, f.

+2

Source: https://habr.com/ru/post/1679086/


All Articles