mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 10:41:09 +00:00
Update wasmtime to 0.27 (#8913)
* Update wasmtime to 0.27 A couple of notes: - Now we are fair about unsafeness of runtime creation via an compiled artifact. This change was prompted by the change in wasmtime which made `deserialize` rightfully unsafe. Now `CodeSupplyMode` was hidden and the `create_runtime` now takes the blob again and there is now a new fn for creating a runtime with a compiled artifact. - This is a big change for wasmtime. They switched to the modern backend for code generation. While this can bring performance improvements, it can also introduce some problems. In fact, 0.27 fixed a serious issue that could lead to sandbox escape. Hence we need a proper burn in. This would require a change to PVF validation host as well. * Filter regalloc logging
This commit is contained in:
Generated
+83
-59
@@ -16,7 +16,16 @@ version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
"gimli 0.23.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a"
|
||||
dependencies = [
|
||||
"gimli 0.24.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -428,11 +437,11 @@ version = "0.3.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"addr2line 0.14.1",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"object 0.23.0",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
@@ -963,38 +972,36 @@ checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-bforest"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcee7a5107071484772b89fdf37f0f460b7db75f476e43ea7a684fd942470bcf"
|
||||
checksum = "c8ca3560686e7c9c7ed7e0fe77469f2410ba5d7781b1acaa9adc8d8deea28e3e"
|
||||
dependencies = [
|
||||
"cranelift-entity",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "654ab96f0f1cab71c0d323618a58360a492da2c341eb2c1f977fc195c664001b"
|
||||
checksum = "baf9bf1ffffb6ce3d2e5ebc83549bd2436426c99b31cc550d521364cbe35d276"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cranelift-bforest",
|
||||
"cranelift-codegen-meta",
|
||||
"cranelift-codegen-shared",
|
||||
"cranelift-entity",
|
||||
"gimli",
|
||||
"gimli 0.24.0",
|
||||
"log",
|
||||
"regalloc",
|
||||
"serde",
|
||||
"smallvec 1.6.1",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-meta"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65994cfc5be9d5fd10c5fc30bcdddfa50c04bb79c91329287bff846434ff8f14"
|
||||
checksum = "4cc21936a5a6d07e23849ffe83e5c1f6f50305c074f4b2970ca50c13bf55b821"
|
||||
dependencies = [
|
||||
"cranelift-codegen-shared",
|
||||
"cranelift-entity",
|
||||
@@ -1002,27 +1009,27 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-shared"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "889d720b688b8b7df5e4903f9b788c3c59396050f5548e516e58ccb7312463ab"
|
||||
checksum = "ca5b6ffaa87560bebe69a5446449da18090b126037920b0c1c6d5945f72faf6b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-entity"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a2e6884a363e42a9ba980193ea8603a4272f8a92bd8bbaf9f57a94dbea0ff96"
|
||||
checksum = "7d6b4a8bef04f82e4296782646f733c641d09497df2fabf791323fefaa44c64c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-frontend"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6f41e2f9b57d2c030e249d0958f1cdc2c3cd46accf8c0438b3d1944e9153444"
|
||||
checksum = "c31b783b351f966fce33e3c03498cb116d16d97a8f9978164a60920bd0d3a99c"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"log",
|
||||
@@ -1032,9 +1039,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-native"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aab70ba7575665375d31cbdea2462916ce58be887834e1b83c860b43b51af637"
|
||||
checksum = "a77c88d3dd48021ff1e37e978a00098524abd3513444ae252c08d37b310b3d2a"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"target-lexicon",
|
||||
@@ -1042,9 +1049,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-wasm"
|
||||
version = "0.71.0"
|
||||
version = "0.74.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2fc3d2e70da6439adf97648dcdf81834363154f2907405345b6fbe7ca38918c"
|
||||
checksum = "edb6d408e2da77cdbbd65466298d44c86ae71c1785d2ab0d8657753cdb4d9d89"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"cranelift-entity",
|
||||
@@ -2248,6 +2255,12 @@ name = "gimli"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189"
|
||||
dependencies = [
|
||||
"fallible-iterator",
|
||||
"indexmap",
|
||||
@@ -4595,6 +4608,12 @@ name = "object"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"indexmap",
|
||||
@@ -9758,9 +9777,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.11.2"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95"
|
||||
checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834"
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
@@ -10899,15 +10918,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.76.0"
|
||||
version = "0.78.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "755a9a4afe3f6cccbbe6d7e965eef44cf260b001f93e547eba84255c1d0187d8"
|
||||
checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65"
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "718cb52a9fdb7ab12471e9b9d051c9adfa6b5c504e0a1fea045e5eabc81eedd9"
|
||||
checksum = "b310b9d20fcf59385761d1ade7a3ef06aecc380e3d3172035b919eaf7465d9f7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"backtrace",
|
||||
@@ -10915,9 +10934,11 @@ dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cpp_demangle",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"paste 1.0.4",
|
||||
"psm",
|
||||
"region",
|
||||
"rustc-demangle",
|
||||
"serde",
|
||||
@@ -10936,9 +10957,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-cache"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f984df56c4adeba91540f9052db9f7a8b3b00cfaac1a023bee50a972f588b0c"
|
||||
checksum = "d14d500d5c3dc5f5c097158feee123d64b3097f0d836a2a27dff9c761c73c843"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.0",
|
||||
@@ -10957,28 +10978,29 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-cranelift"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a05abbf94e03c2c8ee02254b1949320c4d45093de5d9d6ed4d9351d536075c9"
|
||||
checksum = "c525b39f062eada7db3c1298287b96dcb6e472b9f6b22501300b28d9fa7582f6"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"cranelift-entity",
|
||||
"cranelift-frontend",
|
||||
"cranelift-wasm",
|
||||
"target-lexicon",
|
||||
"wasmparser",
|
||||
"wasmtime-environ",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-debug"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "382eecd6281c6c1d1f3c904c3c143e671fc1a9573820cbfa777fba45ce2eda9c"
|
||||
checksum = "c5d2a763e7a6fc734218e0e463196762a4f409c483063d81e0e85f96343b2e0a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"gimli",
|
||||
"gimli 0.24.0",
|
||||
"more-asserts",
|
||||
"object",
|
||||
"object 0.24.0",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
"wasmparser",
|
||||
@@ -10987,16 +11009,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-environ"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81011b2b833663d7e0ce34639459a0e301e000fc7331e0298b3a27c78d0cec60"
|
||||
checksum = "f64d0c2d881c31b0d65c1f2695e022d71eb60b9fbdd336aacca28208b58eac90"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if 1.0.0",
|
||||
"cranelift-codegen",
|
||||
"cranelift-entity",
|
||||
"cranelift-wasm",
|
||||
"gimli",
|
||||
"gimli 0.24.0",
|
||||
"indexmap",
|
||||
"log",
|
||||
"more-asserts",
|
||||
@@ -11007,9 +11028,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-fiber"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d92da32e31af2e3d828f485f5f24651ed4d3b7f03a46ea6555eae6940d1402cd"
|
||||
checksum = "a089d44cd7e2465d41a53b840a5b4fca1bf6d1ecfebc970eac9592b34ea5f0b3"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -11018,11 +11039,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-jit"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b5f649623859a12d361fe4cc4793de44f7c3ff34c322c5714289787e89650bb"
|
||||
checksum = "4d4539ea734422b7c868107e2187d7746d8affbcaa71916d72639f53757ad707"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"addr2line 0.15.1",
|
||||
"anyhow",
|
||||
"cfg-if 1.0.0",
|
||||
"cranelift-codegen",
|
||||
@@ -11030,10 +11051,10 @@ dependencies = [
|
||||
"cranelift-frontend",
|
||||
"cranelift-native",
|
||||
"cranelift-wasm",
|
||||
"gimli",
|
||||
"gimli 0.24.0",
|
||||
"log",
|
||||
"more-asserts",
|
||||
"object",
|
||||
"object 0.24.0",
|
||||
"rayon",
|
||||
"region",
|
||||
"serde",
|
||||
@@ -11051,13 +11072,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-obj"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef2e99cd9858f57fd062e9351e07881cedfc8597928385e02a48d9333b9e15a1"
|
||||
checksum = "8e1a8ff85246d091828e2225af521a6208ed28c997bb5c39eb697366dc2e2f2b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"more-asserts",
|
||||
"object",
|
||||
"object 0.24.0",
|
||||
"target-lexicon",
|
||||
"wasmtime-debug",
|
||||
"wasmtime-environ",
|
||||
@@ -11065,16 +11086,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-profiling"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e46c0a590e49278ba7f79ef217af9db4ecc671b50042c185093e22d73524abb2"
|
||||
checksum = "e24364d522dcd67c897c8fffc42e5bdfc57207bbb6d7eeade0da9d4a7d70105b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if 1.0.0",
|
||||
"gimli",
|
||||
"gimli 0.24.0",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"object",
|
||||
"object 0.24.0",
|
||||
"scroll",
|
||||
"serde",
|
||||
"target-lexicon",
|
||||
@@ -11084,10 +11105,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-runtime"
|
||||
version = "0.24.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1438a09185fc7ca067caf1a80d7e5b398eefd4fb7630d94841448ade60feb3d0"
|
||||
checksum = "c51e57976e8a19a18a18e002c6eb12e5769554204238e47ff155fda1809ef0f7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"backtrace",
|
||||
"cc",
|
||||
"cfg-if 1.0.0",
|
||||
@@ -11095,12 +11117,14 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"mach",
|
||||
"memoffset 0.6.1",
|
||||
"more-asserts",
|
||||
"psm",
|
||||
"rand 0.8.3",
|
||||
"region",
|
||||
"thiserror",
|
||||
"wasmtime-environ",
|
||||
"wasmtime-fiber",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
@@ -11115,9 +11139,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wat"
|
||||
version = "1.0.36"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc"
|
||||
checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02"
|
||||
dependencies = [
|
||||
"wast",
|
||||
]
|
||||
|
||||
@@ -321,7 +321,7 @@ pub fn create_wasm_runtime_with_code(
|
||||
#[cfg(feature = "wasmtime")]
|
||||
WasmExecutionMethod::Compiled => {
|
||||
sc_executor_wasmtime::create_runtime(
|
||||
sc_executor_wasmtime::CodeSupplyMode::Verbatim { blob },
|
||||
blob,
|
||||
sc_executor_wasmtime::Config {
|
||||
heap_pages: heap_pages as u32,
|
||||
allow_missing_func_imports,
|
||||
|
||||
@@ -22,7 +22,7 @@ sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interf
|
||||
sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime-interface" }
|
||||
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
|
||||
sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" }
|
||||
wasmtime = "0.24.0"
|
||||
wasmtime = "0.27.0"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.3.0"
|
||||
|
||||
@@ -118,7 +118,12 @@ fn resolve_memory_import(
|
||||
}
|
||||
|
||||
let memory_ty = MemoryType::new(Limits::new(initial, requested_memory_ty.limits().max()));
|
||||
let memory = Memory::new(store, memory_ty);
|
||||
let memory = Memory::new(store, memory_ty).map_err(|e| {
|
||||
WasmError::Other(format!(
|
||||
"failed to create a memory during resolving of memory import: {}",
|
||||
e,
|
||||
))
|
||||
})?;
|
||||
Ok(Extern::Memory(memory))
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,6 @@ mod runtime;
|
||||
mod state_holder;
|
||||
mod util;
|
||||
|
||||
pub use runtime::{create_runtime, prepare_runtime_artifact, CodeSupplyMode, Config, Semantics};
|
||||
pub use runtime::{
|
||||
create_runtime, create_runtime_from_artifact, prepare_runtime_artifact, Config, Semantics,
|
||||
};
|
||||
|
||||
@@ -272,7 +272,7 @@ pub struct Config {
|
||||
pub semantics: Semantics,
|
||||
}
|
||||
|
||||
pub enum CodeSupplyMode<'a> {
|
||||
enum CodeSupplyMode<'a> {
|
||||
/// The runtime is instantiated using the given runtime blob.
|
||||
Verbatim {
|
||||
// Rationale to take the `RuntimeBlob` here is so that the client will be able to reuse
|
||||
@@ -295,9 +295,42 @@ pub enum CodeSupplyMode<'a> {
|
||||
|
||||
/// Create a new `WasmtimeRuntime` given the code. This function performs translation from Wasm to
|
||||
/// machine code, which can be computationally heavy.
|
||||
///
|
||||
/// The `cache_path` designates where this executor implementation can put compiled artifacts.
|
||||
pub fn create_runtime(
|
||||
blob: RuntimeBlob,
|
||||
config: Config,
|
||||
host_functions: Vec<&'static dyn Function>,
|
||||
) -> std::result::Result<WasmtimeRuntime, WasmError> {
|
||||
// SAFETY: this is safe because it doesn't use `CodeSupplyMode::Artifact`.
|
||||
unsafe { do_create_runtime(CodeSupplyMode::Verbatim { blob }, config, host_functions) }
|
||||
}
|
||||
|
||||
/// The same as [`create_runtime`] but takes a precompiled artifact, which makes this function
|
||||
/// considerably faster than [`create_runtime`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that the compiled artifact passed here was produced by [`prepare_runtime_artifact`].
|
||||
/// Otherwise, there is a risk of arbitrary code execution with all implications.
|
||||
///
|
||||
/// It is ok though if the `compiled_artifact` was created by code of another version or with different
|
||||
/// configuration flags. In such case the caller will receive an `Err` deterministically.
|
||||
pub unsafe fn create_runtime_from_artifact(
|
||||
compiled_artifact: &[u8],
|
||||
config: Config,
|
||||
host_functions: Vec<&'static dyn Function>,
|
||||
) -> std::result::Result<WasmtimeRuntime, WasmError> {
|
||||
do_create_runtime(
|
||||
CodeSupplyMode::Artifact { compiled_artifact },
|
||||
config,
|
||||
host_functions,
|
||||
)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
///
|
||||
/// This is only unsafe if called with [`CodeSupplyMode::Artifact`]. See [`create_runtime_from_artifact`]
|
||||
/// to get more details.
|
||||
unsafe fn do_create_runtime(
|
||||
code_supply_mode: CodeSupplyMode<'_>,
|
||||
config: Config,
|
||||
host_functions: Vec<&'static dyn Function>,
|
||||
@@ -313,7 +346,8 @@ pub fn create_runtime(
|
||||
}
|
||||
}
|
||||
|
||||
let engine = Engine::new(&wasmtime_config);
|
||||
let engine = Engine::new(&wasmtime_config)
|
||||
.map_err(|e| WasmError::Other(format!("cannot create the engine for runtime: {}", e)))?;
|
||||
|
||||
let (module, snapshot_data) = match code_supply_mode {
|
||||
CodeSupplyMode::Verbatim { mut blob } => {
|
||||
@@ -341,6 +375,8 @@ pub fn create_runtime(
|
||||
}
|
||||
}
|
||||
CodeSupplyMode::Artifact { compiled_artifact } => {
|
||||
// SAFETY: The unsafity of `deserialize` is covered by this function. The
|
||||
// responsibilities to maintain the invariants are passed to the caller.
|
||||
let module = wasmtime::Module::deserialize(&engine, compiled_artifact)
|
||||
.map_err(|e| WasmError::Other(format!("cannot deserialize module: {}", e)))?;
|
||||
|
||||
@@ -375,12 +411,12 @@ pub fn prepare_runtime_artifact(
|
||||
) -> std::result::Result<Vec<u8>, WasmError> {
|
||||
instrument(&mut blob, semantics);
|
||||
|
||||
let engine = Engine::new(&common_config());
|
||||
let module = wasmtime::Module::new(&engine, &blob.serialize())
|
||||
.map_err(|e| WasmError::Other(format!("cannot compile module: {}", e)))?;
|
||||
module
|
||||
.serialize()
|
||||
.map_err(|e| WasmError::Other(format!("cannot serialize module: {}", e)))
|
||||
let engine = Engine::new(&common_config())
|
||||
.map_err(|e| WasmError::Other(format!("cannot create the engine: {}", e)))?;
|
||||
|
||||
engine
|
||||
.precompile_module(&blob.serialize())
|
||||
.map_err(|e| WasmError::Other(format!("cannot precompile module: {}", e)))
|
||||
}
|
||||
|
||||
fn perform_call(
|
||||
|
||||
@@ -121,6 +121,9 @@ where
|
||||
// Disable info logging by default for some modules.
|
||||
.add_directive(parse_default_directive("ws=off").expect("provided directive is valid"))
|
||||
.add_directive(parse_default_directive("yamux=off").expect("provided directive is valid"))
|
||||
.add_directive(
|
||||
parse_default_directive("regalloc=off").expect("provided directive is valid"),
|
||||
)
|
||||
.add_directive(
|
||||
parse_default_directive("cranelift_codegen=off").expect("provided directive is valid"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user