mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 15:31:25 +00:00
Fix an assert while deleting table elements
LLVM's mergefunc pass may mean that the same descriptor function is used for different closure invocation sites even when the closure itself is different. This typically only happens with LTO but in theory could happen at any time! The assert was tripping when we tried to delete the same function table entry twice, so instead of a `Vec<usize>` of entries to delete this commit switches to a `HashSet<usize>` which should do the deduplication for us and enusre that we delete each descriptor only once. Closes #1264
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use walrus::ir::ExprId;
|
||||
use walrus::{FunctionId, LocalFunction, LocalId, Module, TableId};
|
||||
|
||||
@ -168,7 +168,7 @@ impl Interpreter {
|
||||
&mut self,
|
||||
id: FunctionId,
|
||||
module: &Module,
|
||||
entry_removal_list: &mut Vec<usize>,
|
||||
entry_removal_list: &mut HashSet<usize>,
|
||||
) -> Option<&[u32]> {
|
||||
// Call the `id` function. This is an internal `#[inline(never)]`
|
||||
// whose code is completely controlled by the `wasm-bindgen` crate, so
|
||||
@ -213,7 +213,7 @@ impl Interpreter {
|
||||
|
||||
// This is used later to actually remove the entry from the table, but
|
||||
// we don't do the removal just yet
|
||||
entry_removal_list.push(descriptor_table_idx);
|
||||
entry_removal_list.insert(descriptor_table_idx);
|
||||
|
||||
// And now execute the descriptor!
|
||||
self.interpret_descriptor_id(descriptor_id, module)
|
||||
|
Reference in New Issue
Block a user