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

#1496 in WebAssembly

Download history 65514/week @ 2024-01-23 82537/week @ 2024-01-30 85839/week @ 2024-02-06 100044/week @ 2024-02-13 87789/week @ 2024-02-20 88006/week @ 2024-02-27 57349/week @ 2024-03-05 46474/week @ 2024-03-12 49257/week @ 2024-03-19 43833/week @ 2024-03-26 44700/week @ 2024-04-02 42579/week @ 2024-04-09 43216/week @ 2024-04-16 39809/week @ 2024-04-23 38868/week @ 2024-04-30 32332/week @ 2024-05-07

161,971 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
~123K SLoC