mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 13:01:22 +00:00
Upgrade to walrus 0.4
Also be sure to have an explicit GC pass!
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user