Skip to content

wasm import: remove double compilation #3348

Closed
@kevinkassimo

Description

Follow-up for #3328

wasm import currently does double compilation: the first compilation happens here:

const compiled = await WebAssembly.compile(buffer);

and the second time happens here:

const compiled = await WebAssembly.compile(buffer);

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions