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:
Alex Crichton
2019-02-19 08:17:14 -08:00
parent e498d99b2d
commit 9bab9d4af1
3 changed files with 7 additions and 11 deletions

View File

@ -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)