Implement data.drop and memory.init and get the rest of the bulk memory spec tests passing (#1264)

* Enable the already-passing `bulk-memoryoperations/imports.wast` test

* Implement support for the `memory.init` instruction and passive data

This adds support for passive data segments and the `memory.init` instruction
from the bulk memory operations proposal. Passive data segments are stored on
the Wasm module and then `memory.init` instructions copy their contents into
memory.

* Implement the `data.drop` instruction

This allows wasm modules to deallocate passive data segments that it doesn't
need anymore. We keep track of which segments have not been dropped on an
`Instance` and when dropping them, remove the entry from the instance's hash
map. The module always needs all of the segments for new instantiations.

* Enable final bulk memory operations spec test

This requires special casing an expected error message for an `assert_trap`,
since the expected error message contains the index of an uninitialized table
element, but our trap implementation doesn't save that diagnostic information
and shepherd it out.
This commit is contained in:
Nick Fitzgerald
2020-03-10 07:30:11 -07:00
committed by GitHub
parent 11510ec426
commit 674a6208d8
10 changed files with 237 additions and 42 deletions

View File

@@ -565,6 +565,10 @@ impl VMBuiltinFunctionsArray {
wasmtime_memory_fill as usize;
ptrs[BuiltinFunctionIndex::get_imported_memory_fill_index().index() as usize] =
wasmtime_imported_memory_fill as usize;
ptrs[BuiltinFunctionIndex::get_memory_init_index().index() as usize] =
wasmtime_memory_init as usize;
ptrs[BuiltinFunctionIndex::get_data_drop_index().index() as usize] =
wasmtime_data_drop as usize;
debug_assert!(ptrs.iter().cloned().all(|p| p != 0));