Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f4d9282
Refactor WASM module instantiation; enable WASM instance pooling
koute Dec 14, 2021
6b9b777
Disable the `uffd` feature on `wasmtime`
koute Dec 15, 2021
d982eeb
Merge branch 'master' into master_wasmtime_pooling
koute Dec 15, 2021
92cbf66
Restore the original behavior regarding the initial WASM memory size
koute Dec 15, 2021
719aadd
Adjust error message
koute Dec 15, 2021
d9e055b
Remove unnecessary import in the benchmarks
koute Dec 16, 2021
2f53ad6
Preinstantiate the WASM runtime for a slight speedup
koute Dec 16, 2021
19daf56
Delete the asserts in `convert_memory_import_into_export`
koute Dec 16, 2021
ae988e2
`return` -> `break`
koute Dec 16, 2021
44c5086
Revert WASM instance pooling for now
koute Dec 16, 2021
afd355b
Have `convert_memory_import_into_export` return an error instead of p…
koute Dec 17, 2021
3e8932f
Update the warning when an import is missing
koute Jan 20, 2022
0a61182
Merge branch 'master' into master_wasmtime_pooling
koute Jan 20, 2022
7370f41
Rustfmt and clippy fix
koute Jan 24, 2022
539347e
Fix executor benchmarks' compilation without `wasmtime` being enabled
koute Jan 24, 2022
7f0d17a
rustfmt again
koute Jan 28, 2022
780b0ec
Align to review comments
koute Feb 10, 2022
72aa655
Extend tests so that both imported and exported memories are tested
koute Feb 10, 2022
3a15f68
Increase the number of heap pages for exported memories too
koute Feb 10, 2022
3cb916e
Merge branch 'master' into master_wasmtime_pooling
koute Feb 10, 2022
3b4ca22
Fix `decommit_works` test
koute Feb 10, 2022
e3be4e7
Merge branch 'master' into master_wasmtime_pooling
koute Feb 18, 2022
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
Prev Previous commit
Next Next commit
Align to review comments
  • Loading branch information
koute committed Feb 10, 2022
commit 780b0ece357b5d5323496c11e9328aef6a1423e4
4 changes: 2 additions & 2 deletions client/executor/common/src/runtime_blob/runtime_blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ impl RuntimeBlob {
// just in case to cover all of our bases.
self.raw_module
.insert_section(Section::Export(Default::default()))
.expect("an export section can be always inserted if it doesn't exist");
.expect("an export section can be always inserted if it doesn't exist; qed");
}
self.raw_module
.export_section_mut()
.expect("export section always exists")
.expect("export section already existed or we just added it above, so it always exists; qed")
.entries_mut()
.push(ExportEntry::new(memory_name, Internal::Memory(0)));

Expand Down
22 changes: 7 additions & 15 deletions client/executor/wasmtime/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,12 @@ where
if allow_missing_func_imports {
for (name, (import_ty, func_ty)) in registry.pending_func_imports {
let error = format!("call to a missing function {}:{}", import_ty.module(), name);
if func_ty.params().len() == 0 && func_ty.results().len() == 0 {
linker
.func_wrap("env", &name, move || -> Result<(), Trap> {
Err(Trap::new(error.clone()))
})
.expect("adding a missing import stub doesn't fail");
} else {
log::warn!("Missing import: '{}' {:?}", name, func_ty);
linker
.func_new("env", &name, func_ty.clone(), move |_, _, _| {
Err(Trap::new(error.clone()))
})
.expect("adding a missing import stub doesn't fail");
}
log::debug!("Missing import: '{}' {:?}", name, func_ty);
linker
.func_new("env", &name, func_ty.clone(), move |_, _, _| {
Err(Trap::new(error.clone()))
})
.expect("adding a missing import stub can only fail when the item already exists, and it is missing here; qed");
}
} else {
let mut names = Vec::new();
Expand Down Expand Up @@ -117,7 +109,7 @@ impl<'a, 'b> sp_wasm_interface::HostFunctionRegistry for Registry<'a, 'b> {
fn_name: &str,
func: impl wasmtime::IntoFunc<Self::State, Params, Results>,
) -> Result<(), Self::Error> {
if let Some((_, _)) = self.pending_func_imports.remove(fn_name) {
if self.pending_func_imports.remove(fn_name).is_some() {
self.linker.func_wrap("env", fn_name, func).map_err(|error| {
WasmError::Other(format!(
"failed to register host function '{}' with the WASM linker: {}",
Expand Down
4 changes: 2 additions & 2 deletions client/executor/wasmtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,15 @@ where
let mut blob = instrument(blob, &config.semantics)?;

// We don't actually need the memory to be imported so we can just convert any memory
// import into an export with imputiny. This simplifies our code since `wasmtime` will
// import into an export with impunity. This simplifies our code since `wasmtime` will
// now automatically take care of creating the memory for us, and it also allows us
// to potentially enable `wasmtime`'s instance pooling at a later date. (Imported
// memories are ineligible for pooling.)
blob.convert_memory_import_into_export(
config
.heap_pages
.try_into()
.expect("a reasonable 'heap_pages' will never exceed 2^32"),
.map_err(|e| WasmError::Other(format!("invalid `heap_pages`: {}", e)))?,
)?;

let serialized_blob = blob.clone().serialize();
Expand Down