83 releases

new 0.2.99 Dec 7, 2024
0.2.97 Nov 30, 2024
0.2.92 Mar 4, 2024
0.2.89 Nov 27, 2023
0.2.28 Nov 12, 2018

#1610 in WebAssembly

Download history 36162/week @ 2024-08-17 33725/week @ 2024-08-24 32709/week @ 2024-08-31 32847/week @ 2024-09-07 32956/week @ 2024-09-14 31180/week @ 2024-09-21 36365/week @ 2024-09-28 32796/week @ 2024-10-05 35735/week @ 2024-10-12 36765/week @ 2024-10-19 33937/week @ 2024-10-26 31986/week @ 2024-11-02 35982/week @ 2024-11-09 39568/week @ 2024-11-16 29909/week @ 2024-11-23 40432/week @ 2024-11-30

150,953 downloads per month
Used in 38 crates (via wasm-bindgen-cli-support)

MIT/Apache

32KB
457 lines

A tiny and incomplete Wasm interpreter

This module contains a tiny and incomplete Wasm interpreter built on top of walrus's module structure. Each Interpreter contains some state about the execution of a Wasm instance. The "incomplete" part here is related to the fact that this is only used to execute the various descriptor functions for wasm-bindgen.

As a recap, the wasm-bindgen macro generate "descriptor functions" which basically as a mapping of rustc's trait resolution in executable code. This allows us to detect, after the macro is invoke, what trait selection did and what types of functions look like. By executing descriptor functions they'll each invoke a known import (with only one argument) some number of times, which gives us a list of u32 values to then decode.

The interpreter here is only geared towards this one exact use case, so it's quite small and likely not extra-efficient.

Dependencies

~5.5MB
~113K SLoC