mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Merge pull request #1277 from alexcrichton/upgrade-walrus
Upgrade to walrus 0.4
This commit is contained in:
commit
e66de7b866
@ -17,7 +17,7 @@ failure = "0.1.2"
|
||||
log = "0.4"
|
||||
rustc-demangle = "0.1.13"
|
||||
tempfile = "3.0"
|
||||
walrus = "0.2.1"
|
||||
walrus = "0.4.0"
|
||||
wasm-bindgen-shared = { path = "../shared", version = '=0.2.37' }
|
||||
wasm-bindgen-threads-xform = { path = '../threads-xform', version = '=0.2.37' }
|
||||
wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.37' }
|
||||
|
@ -142,6 +142,7 @@ impl ClosureDescriptors {
|
||||
let table = input.module.tables.get_mut(table_id);
|
||||
let table = match &mut table.kind {
|
||||
walrus::TableKind::Function(f) => f,
|
||||
walrus::TableKind::Anyref(_) => unreachable!(),
|
||||
};
|
||||
for idx in self.element_removal_list.iter().cloned() {
|
||||
log::trace!("delete element {}", idx);
|
||||
|
@ -536,6 +536,8 @@ impl<'a> Context<'a> {
|
||||
|
||||
self.export_table()?;
|
||||
|
||||
walrus::passes::gc::run(self.module);
|
||||
|
||||
// Note that it's important `throw` comes last *after* we gc. The
|
||||
// `__wbindgen_malloc` function may call this but we only want to
|
||||
// generate code for this if it's actually live (and __wbindgen_malloc
|
||||
@ -871,16 +873,10 @@ impl<'a> Context<'a> {
|
||||
if !self.function_table_needed {
|
||||
return Ok(());
|
||||
}
|
||||
let mut tables = self.module.tables.iter().filter_map(|t| match t.kind {
|
||||
walrus::TableKind::Function(_) => Some(t.id()),
|
||||
});
|
||||
let id = match tables.next() {
|
||||
let id = match self.module.tables.main_function_table()? {
|
||||
Some(id) => id,
|
||||
None => return Ok(()),
|
||||
None => bail!("no function table found in module"),
|
||||
};
|
||||
if tables.next().is_some() {
|
||||
bail!("couldn't find function table to export");
|
||||
}
|
||||
self.module.exports.add("__wbg_function_table", id);
|
||||
Ok(())
|
||||
}
|
||||
@ -976,7 +972,7 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
for id in to_remove {
|
||||
self.module.exports.remove_root(id);
|
||||
self.module.exports.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ impl Bindgen {
|
||||
// This means that whenever we encounter an import or export we'll
|
||||
// execute a shim function which informs us about its type so we can
|
||||
// then generate the appropriate bindings.
|
||||
let mut instance = wasm_bindgen_wasm_interpreter::Interpreter::new(&module);
|
||||
let mut instance = wasm_bindgen_wasm_interpreter::Interpreter::new(&module)?;
|
||||
|
||||
let mut memories = module.memories.iter().map(|m| m.id());
|
||||
let memory = memories.next();
|
||||
|
@ -24,7 +24,7 @@ rouille = { version = "3.0.0", default-features = false }
|
||||
serde = { version = "1.0", features = ['derive'] }
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
walrus = "0.2"
|
||||
walrus = "0.4"
|
||||
wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.37" }
|
||||
wasm-bindgen-shared = { path = "../shared", version = "=0.2.37" }
|
||||
|
||||
|
@ -12,5 +12,5 @@ Support for threading-related transformations in wasm-bindgen
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
walrus = "0.2"
|
||||
failure = "0.1"
|
||||
walrus = "0.4"
|
||||
|
@ -12,8 +12,9 @@ Micro-interpreter optimized for wasm-bindgen's use case
|
||||
edition = '2018'
|
||||
|
||||
[dependencies]
|
||||
walrus = "0.2"
|
||||
failure = "0.1"
|
||||
log = "0.4"
|
||||
walrus = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
@ -64,7 +64,7 @@ impl Interpreter {
|
||||
///
|
||||
/// Note that the `module` passed in to this function must be the same as
|
||||
/// the `module` passed to `interpret` below.
|
||||
pub fn new(module: &Module) -> Interpreter {
|
||||
pub fn new(module: &Module) -> Result<Interpreter, failure::Error> {
|
||||
let mut ret = Interpreter::default();
|
||||
|
||||
// The descriptor functions shouldn't really use all that much memory
|
||||
@ -102,14 +102,9 @@ impl Interpreter {
|
||||
ret.name_map.insert(export.name.to_string(), id);
|
||||
}
|
||||
|
||||
for table in module.tables.iter() {
|
||||
match table.kind {
|
||||
walrus::TableKind::Function(_) => {}
|
||||
}
|
||||
ret.functions = Some(table.id());
|
||||
}
|
||||
ret.functions = module.tables.main_function_table()?;
|
||||
|
||||
return ret;
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
/// Interprets the execution of the descriptor function `func`.
|
||||
@ -204,6 +199,7 @@ impl Interpreter {
|
||||
let functions = self.functions.expect("function table should be present");
|
||||
let functions = match &module.tables.get(functions).kind {
|
||||
walrus::TableKind::Function(f) => f,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let descriptor_id = functions
|
||||
.elements
|
||||
@ -348,8 +344,11 @@ impl Frame<'_> {
|
||||
|
||||
Expr::WithSideEffects(e) => {
|
||||
log::debug!("side effects");
|
||||
for x in e.before.iter() {
|
||||
self.eval(*x);
|
||||
}
|
||||
let ret = self.eval(e.value);
|
||||
for x in e.side_effects.iter() {
|
||||
for x in e.after.iter() {
|
||||
self.eval(*x);
|
||||
}
|
||||
return ret;
|
||||
|
@ -16,7 +16,7 @@ fn interpret(wat: &str, name: &str, result: Option<&[u32]>) {
|
||||
println!("status: {}", status);
|
||||
assert!(status.success());
|
||||
let module = walrus::Module::from_file(output.path()).unwrap();
|
||||
let mut i = Interpreter::new(&module);
|
||||
let mut i = Interpreter::new(&module).unwrap();
|
||||
assert_eq!(i.interpret_descriptor(name, &module), result);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user