79 releases

0.2.95 Oct 10, 2024
0.2.93 Aug 12, 2024
0.2.92 Mar 4, 2024
0.2.89 Nov 27, 2023
0.2.28 Nov 12, 2018

#1541 in WebAssembly

Download history 44631/week @ 2024-07-21 47601/week @ 2024-07-28 42410/week @ 2024-08-04 39045/week @ 2024-08-11 35889/week @ 2024-08-18 33499/week @ 2024-08-25 32803/week @ 2024-09-01 33125/week @ 2024-09-08 32463/week @ 2024-09-15 31413/week @ 2024-09-22 36677/week @ 2024-09-29 32555/week @ 2024-10-06 36000/week @ 2024-10-13 36887/week @ 2024-10-20 33506/week @ 2024-10-27 29418/week @ 2024-11-03

138,508 downloads per month
Used in 37 crates (via wasm-bindgen-cli-support)

MIT/Apache

31KB
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
~114K SLoC