Skip to content

Commit

Permalink
Refactor runtime Table to support static storage.
Browse files Browse the repository at this point in the history
This commit refactors `Table` in the runtime such that it can be created from a
pointer to existing table data.

The current `Vec` backing of the `Table` is considered to be "dynamic" storage.

This will be used for the upcoming pooling allocator where table memory is
managed externally to the instance.

The `table.copy` implementation was improved to use slice primitives for doing
the copying.

Fixes bytecodealliance#983.
  • Loading branch information
peterhuene committed Jan 25, 2021
1 parent bf2036c commit e4d85ac
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 99 deletions.
2 changes: 1 addition & 1 deletion crates/runtime/src/instance/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl OnDemandInstanceAllocator {
let mut tables: PrimaryMap<DefinedTableIndex, _> =
PrimaryMap::with_capacity(module.table_plans.len() - num_imports);
for table in &module.table_plans.values().as_slice()[num_imports..] {
tables.push(Table::new(table));
tables.push(Table::new_dynamic(table));
}
tables.into_boxed_slice()
}
Expand Down
Loading

0 comments on commit e4d85ac

Please sign in to comment.