Skip to content

Skip generating JS glue shims for wasm exports when unnecessary #1666

Open
@fitzgen

Description

@fitzgen

When an exported function only uses things that can be expressed with normal conversions (i32, f64, etc...) then we should skip generating JS glue shim functions for the exports.

Motivation

Reduce amount JS glue. Don't have excess JS frames on the stack in between wasm and the imported function (can matter for performance for wasm importing wasm, where engines can optimize calls).

Proposed Solution

Because instantiation is async, we can't just export wasm.my_export_function since wasm doesn't exist yet and that will throw. Instead, we need to do export let my_exported_function = undefined; and then dynamically rebind my_exported function after instantiation. This means that we are reducing our JS glue foot print, but unfortunately we can't wholesale remove JS glue for exports like we can for imports.

The exact details will vary for each target, but is essentially the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenIssues related to emitting code at the end of the wasm-bindgen pipelinefile-sizeIssues related to compiled wasm file sizesjavascriptspeedIssues related to runtime performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions