mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
Be sure to GC our imports as well as the module
After a module goes through its primary GC pass we need to look over the set of remaining imports and use that to prune the set of imports that we're binding. Closes #1613
This commit is contained in:
@ -204,8 +204,18 @@ impl<'a> Context<'a> {
|
||||
// After all we've done, especially
|
||||
// `unexport_unused_internal_exports()`, we probably have a bunch of
|
||||
// garbage in the module that's no longer necessary, so delete
|
||||
// everything that we don't actually need.
|
||||
// everything that we don't actually need. Afterwards make sure we don't
|
||||
// try to emit bindings for now-nonexistent imports by pruning our
|
||||
// `wasm_import_definitions` set.
|
||||
walrus::passes::gc::run(self.module);
|
||||
let remaining_imports = self
|
||||
.module
|
||||
.imports
|
||||
.iter()
|
||||
.map(|i| i.id())
|
||||
.collect::<HashSet<_>>();
|
||||
self.wasm_import_definitions
|
||||
.retain(|id, _| remaining_imports.contains(id));
|
||||
|
||||
// Cause any future calls to `should_write_global` to panic, making sure
|
||||
// we don't ask for items which we can no longer emit.
|
||||
|
Reference in New Issue
Block a user