Move wasm data sections out of wasmtime_environ::Module (#3231)
* Reduce indentation in `to_paged` Use a few early-returns from `match` to avoid lots of extra indentation. * Move wasm data sections out of `wasmtime_environ::Module` This is the first step down the road of #3230. The long-term goal is that `Module` is always `bincode`-decoded, but wasm data segments are a possibly very-large portion of this residing in modules which we don't want to shove through bincode. This refactors the internals of wasmtime to be ok with this data living separately from the `Module` itself, providing access at necessary locations. Wasm data segments are now extracted from a wasm module and concatenated directly. Data sections then describe ranges within this concatenated list of data, and passive data works the same way. This implementation does not lend itself to eventually optimizing the case where passive data is dropped and no longer needed. That's left for a future PR.
This commit is contained in:
@@ -269,7 +269,9 @@ unsafe fn initialize_wasm_page(
|
||||
if let MemoryInitialization::Paged { map, .. } = &instance.module.memory_initialization {
|
||||
let pages = &map[memory_index];
|
||||
|
||||
if let Some(Some(data)) = pages.get(page_index) {
|
||||
let pos = pages.binary_search_by_key(&(page_index as u64), |k| k.0);
|
||||
if let Ok(i) = pos {
|
||||
let data = instance.wasm_data(pages[i].1.clone());
|
||||
debug_assert_eq!(data.len(), WASM_PAGE_SIZE);
|
||||
|
||||
log::trace!(
|
||||
@@ -530,6 +532,7 @@ mod test {
|
||||
shared_signatures: VMSharedSignatureIndex::default().into(),
|
||||
host_state: Box::new(()),
|
||||
store: None,
|
||||
wasm_data: &[],
|
||||
},
|
||||
)
|
||||
.expect("instance should allocate"),
|
||||
|
||||
Reference in New Issue
Block a user