Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sc-executor): store table for wasm executor #7

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading