76 releases

0.2.92 Mar 4, 2024
0.2.90 Jan 12, 2024
0.2.89 Nov 27, 2023
0.2.87 Jun 12, 2023
0.2.28 Nov 12, 2018

#1525 in WebAssembly

Download history 80948/week @ 2024-02-07 100400/week @ 2024-02-14 88536/week @ 2024-02-21 88778/week @ 2024-02-28 49418/week @ 2024-03-06 47382/week @ 2024-03-13 48318/week @ 2024-03-20 45590/week @ 2024-03-27 41747/week @ 2024-04-03 42719/week @ 2024-04-10 43491/week @ 2024-04-17 39631/week @ 2024-04-24 38224/week @ 2024-05-01 38855/week @ 2024-05-08 36920/week @ 2024-05-15 26384/week @ 2024-05-22

147,754 downloads per month
Used in 32 crates (via wasm-bindgen-cli-support)

MIT/Apache

24KB
321 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

~6MB
~126K SLoC