mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
Update the walrus
dependency (#2125)
This commit updates the `walrus` crate used in `wasm-bindgen`. The major change here is how `walrus` handles element segments, exposing segments rather than trying to keep a contiugous array of all the elements and doing the splitting itself. That means that we need to do mroe logic here in `wasm-bindgen` to juggle indices, segments, etc.
This commit is contained in:
@ -14,7 +14,8 @@ edition = '2018'
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
log = "0.4"
|
||||
walrus = "0.14.0"
|
||||
walrus = "0.16.0"
|
||||
wasm-bindgen-wasm-conventions = { path = "../wasm-conventions", version = "0.2.62" }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use walrus::ir::Instr;
|
||||
use walrus::{FunctionId, LocalId, Module, TableId};
|
||||
use walrus::{ElementId, FunctionId, LocalId, Module, TableId};
|
||||
|
||||
/// A ready-to-go interpreter of a wasm module.
|
||||
///
|
||||
@ -159,7 +159,7 @@ impl Interpreter {
|
||||
&mut self,
|
||||
id: FunctionId,
|
||||
module: &Module,
|
||||
entry_removal_list: &mut HashSet<usize>,
|
||||
entry_removal_list: &mut HashSet<(ElementId, usize)>,
|
||||
) -> Option<&[u32]> {
|
||||
// Call the `id` function. This is an internal `#[inline(never)]`
|
||||
// whose code is completely controlled by the `wasm-bindgen` crate, so
|
||||
@ -184,28 +184,19 @@ impl Interpreter {
|
||||
|
||||
let args = vec![0; num_params];
|
||||
self.call(id, module, &args);
|
||||
let descriptor_table_idx =
|
||||
self.descriptor_table_idx
|
||||
.take()
|
||||
.expect("descriptor function should return index") as usize;
|
||||
let descriptor_table_idx = self
|
||||
.descriptor_table_idx
|
||||
.take()
|
||||
.expect("descriptor function should return index");
|
||||
|
||||
// After we've got the table index of the descriptor function we're
|
||||
// interested go take a look in the function table to find what the
|
||||
// actual index of the function is.
|
||||
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
|
||||
.get(descriptor_table_idx)
|
||||
.expect("out of bounds read of function table")
|
||||
.expect("attempting to execute null function");
|
||||
|
||||
// This is used later to actually remove the entry from the table, but
|
||||
// we don't do the removal just yet
|
||||
entry_removal_list.insert(descriptor_table_idx);
|
||||
let entry =
|
||||
wasm_bindgen_wasm_conventions::get_function_table_entry(module, descriptor_table_idx)
|
||||
.expect("failed to find entry in function table");
|
||||
let descriptor_id = entry.func.expect("element segment slot wasn't set");
|
||||
entry_removal_list.insert((entry.element, entry.idx));
|
||||
|
||||
// And now execute the descriptor!
|
||||
self.interpret_descriptor(descriptor_id, module)
|
||||
|
Reference in New Issue
Block a user