You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first compilation is to enable us to get imports/exports info such that we are able to build a dynamic script with static imports and named exports. The second one is for the later actual instantiation.
Ideally we should be able to just compile once, and in the module evaluation script we can somehow get a handle to the old compiled object. However currently these 2 compilations happens in 2 different isolates (first in some compiler isolate, second in the main isolate), thus making storing and transferring the compiled object difficult.
I'm not so sure if SyntheticModule APIs could be useful, since handling imports in its evaluation steps would be painful while doing exports is easy. Also we still need to create some js/.d.ts code for the module to placate TS compiler for named exports (especially under de-structuring)
The text was updated successfully, but these errors were encountered:
For clarification, this is a generated JS wrapper script for wasm imports (with cli/tests/051_wasm_import/simple.wasm):
constimportObject=Object.create(null);/* BEGIN static import inject */import*asm0from"./wasm-dep.js";importObject["./wasm-dep.js"]=m0;import*asm1from"http://127.0.0.1:4545/cli/tests/051_wasm_import/remote.ts";importObject["http://127.0.0.1:4545/cli/tests/051_wasm_import/remote.ts"]=m1;/* END static import inject */functionbase64ToUint8Array(data){constbinString=window.atob(data);constsize=binString.length;constbytes=newUint8Array(size);for(leti=0;i<size;i++){bytes[i]=binString.charCodeAt(i);}returnbytes;}constbuffer=base64ToUint8Array("AGFzbQEAAAABEwRgAAF/YAAAYAJ/fwF/YAF/AX8CdgMNLi93YXNtLWRlcC5qcwRqc0ZuAAANLi93YXNtLWRlcC5qcwhqc0luaXRGbgABOWh0dHA6Ly8xMjcuMC4wLjE6NDU0NS9jbGkvdGVzdHMvMDUxX3dhc21faW1wb3J0L3JlbW90ZS50cwpqc1JlbW90ZUZuAAADBQQBAgMDByEDA2FkZAAEC2FkZEltcG9ydGVkAAUJYWRkUmVtb3RlAAYIAQMKHgQEABABCwcAIAAgAWoLBwAgABAAagsHACAAEAJqCw==");constcompiled=awaitWebAssembly.compile(buffer);constinstance=newWebAssembly.Instance(compiled,importObject);/* BEGIN named exports inject */exportconstadd=instance.exports.add;exportconstaddImported=instance.exports.addImported;exportconstaddRemote=instance.exports.addRemote;/* END named exports inject */
Uh oh!
There was an error while loading. Please reload this page.
Follow-up for #3328
wasm import currently does double compilation: the first compilation happens here:
deno/cli/js/compiler.ts
Line 753 in 4902a1c
and the second time happens here:
deno/cli/compilers/wasm_wrap.js
Line 15 in 4902a1c
The first compilation is to enable us to get imports/exports info such that we are able to build a dynamic script with static imports and named exports. The second one is for the later actual instantiation.
Ideally we should be able to just compile once, and in the module evaluation script we can somehow get a handle to the old compiled object. However currently these 2 compilations happens in 2 different isolates (first in some compiler isolate, second in the main isolate), thus making storing and transferring the compiled object difficult.
I'm not so sure if SyntheticModule APIs could be useful, since handling imports in its evaluation steps would be painful while doing exports is easy. Also we still need to create some js/.d.ts code for the module to placate TS compiler for named exports (especially under de-structuring)
The text was updated successfully, but these errors were encountered: