Skip to content

Commit

Permalink
keep storing table for sc executor
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx committed Oct 29, 2024
1 parent 06891d8 commit f37ae44
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions substrate/client/executor/wasmtime/src/instance_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ impl InstanceWrapper {
})?;

let memory = get_linear_memory(&instance, &mut store)?;
let table = get_table(&instance, &mut store);

store.data_mut().memory = Some(memory);
store.data_mut().table = table;

Ok(InstanceWrapper { instance, store, _release_instance_handle })
}
Expand Down Expand Up @@ -181,6 +183,17 @@ fn get_linear_memory(instance: &Instance, ctx: impl AsContextMut) -> Result<Memo
Ok(memory)
}


/// Extract the table from the given instance if any.
fn get_table(instance: &Instance, ctx: &mut Store) -> Option<Table> {
instance
.get_export(ctx, "__indirect_function_table")
.as_ref()
.cloned()
.and_then(Extern::into_table)
}


/// Functions related to memory.
impl InstanceWrapper {
pub(crate) fn store(&self) -> &Store {
Expand Down

0 comments on commit f37ae44

Please sign in to comment.