Remove dependency on wasmi

This is a pretty heavyweight dependency which accounts for a surprising amount
of runtime for larger modules in `wasm-bindgen`. We don't need 90% of the crate
and so this commit bundles a small interpreter for instructions we know are only
going to appear in describe-related functions.
This commit is contained in:
Alex Crichton
2018-08-19 17:07:30 -07:00
parent 7486fa5104
commit 6343f2659a
8 changed files with 503 additions and 134 deletions

View File

@ -10,6 +10,7 @@ use wasm_gc;
use super::Bindgen;
use descriptor::{Descriptor, VectorKind};
use wasm_interpreter::Interpreter;
mod js2rust;
use self::js2rust::Js2Rust;
@ -41,7 +42,7 @@ pub struct Context<'a> {
pub exported_classes: HashMap<String, ExportedClass>,
pub function_table_needed: bool,
pub run_descriptor: &'a Fn(&str) -> Option<Vec<u32>>,
pub interpreter: &'a mut Interpreter,
}
#[derive(Default)]
@ -1668,9 +1669,9 @@ impl<'a> Context<'a> {
Ok(())
}
fn describe(&self, name: &str) -> Option<Descriptor> {
fn describe(&mut self, name: &str) -> Option<Descriptor> {
let name = format!("__wbindgen_describe_{}", name);
(self.run_descriptor)(&name).map(|d| Descriptor::decode(&d))
Some(Descriptor::decode(self.interpreter.interpret(&name, self.module)?))
}
fn global(&mut self, s: &str) {