Skip to content

Investigate adding a "fast init" function for initializing the VMContext #13502

@alexcrichton

Description

@alexcrichton

In #13487 support was added to initialize a wasm instance's "complicated" globals, tables, memories, etc. This, in theory, can go even further, however, and we could JIT initialization of an instance's VMContext itself. Right now vm::Instance::initialize_vmctx is a very branch-y and complicated function. This low-level initialization additionally doesn't need anything like fuel checks, epochs, a wasm stack, etc. Ideally we could split module initialization in two:

  • A "fast" function which has a custom native ABI generated by Cranelift which initializes the VMContext. The signature of this function need not be related to wasm (could take native pointers) and need not be connected to things like VMFuncRef for example. This could largely just be a function pointer emitted by Cranelift which is virtually dispatched to during instantiation
  • A "slow" function which is implemented in Move most module initialization to compiled code  #13487 for full wasm initialization which needs fuel, epochs, a custom stack, etc. This function could trap (unlike the "fast" function), and is that the "module startup" is after Move most module initialization to compiled code  #13487.

This in theory might make module instantiation even faster after #13487 since initialize_vmctx would be a JIT'd function rather than a generic one-size-fits-all function with lots of branches. Benchmarking TBD!

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancewasmtimeIssues about wasmtime that don't fall into another label

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions