Bump wasmtime from 0.19.0 to 0.22.0 (#7865)

* Bump wasmtime from 0.19.0 to 0.22.0

Bumps [wasmtime](https://github.com/bytecodealliance/wasmtime) from 0.19.0 to 0.22.0.
- [Release notes](https://github.com/bytecodealliance/wasmtime/releases)
- [Changelog](https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-some-possible-changes.md)
- [Commits](https://github.com/bytecodealliance/wasmtime/compare/v0.19.0...v0.22.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Account for ImportType::name() being an Optional

* Account for parameters being a impl Iterator now

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
dependabot[bot]
2021-02-08 13:03:05 +00:00
committed by GitHub
parent 0ed683ca13
commit 884d916559
4 changed files with 225 additions and 165 deletions
+173 -118
View File
@@ -16,7 +16,7 @@ version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7"
dependencies = [
"gimli 0.23.0",
"gimli",
]
[[package]]
@@ -889,6 +889,16 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]]
name = "cpp_demangle"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390"
dependencies = [
"cfg-if 1.0.0",
"glob",
]
[[package]]
name = "cpuid-bool"
version = "0.1.2"
@@ -903,25 +913,25 @@ checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba"
[[package]]
name = "cranelift-bforest"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dcc286b052ee24a1e5a222e7c1125e6010ad35b0f248709b9b3737a8fedcfdf"
checksum = "4066fd63b502d73eb8c5fa6bcab9c7962b05cd580f6b149ee83a8e730d8ce7fb"
dependencies = [
"cranelift-entity",
]
[[package]]
name = "cranelift-codegen"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d9badfe36176cb653506091693bc2bb1970c9bddfcd6ec7fac404f7eaec6f38"
checksum = "1a54e4beb833a3c873a18a8fe735d73d732044004c7539a072c8faa35ccb0c60"
dependencies = [
"byteorder",
"cranelift-bforest",
"cranelift-codegen-meta",
"cranelift-codegen-shared",
"cranelift-entity",
"gimli 0.21.0",
"gimli",
"log",
"regalloc",
"serde",
@@ -932,9 +942,9 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3f460031861e4f4ad510be62b2ae50bba6cc886b598a36f9c0a970feab9598"
checksum = "c54cac7cacb443658d8f0ff36a3545822613fa202c946c0891897843bc933810"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
@@ -942,24 +952,24 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76ad12409e922e7697cd0bdc7dc26992f64a77c31880dfe5e3c7722f4710206d"
checksum = "a109760aff76788b2cdaeefad6875a73c2b450be13906524f6c2a81e05b8d83c"
[[package]]
name = "cranelift-entity"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97cdc58972ea065d107872cfb9079f4c92ade78a8af85aaff519a65b5d13f71"
checksum = "3b044234aa32531f89a08b487630ddc6744696ec04c8123a1ad388de837f5de3"
dependencies = [
"serde",
]
[[package]]
name = "cranelift-frontend"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ef419efb4f94ecc02e5d9fbcc910d2bb7f0040e2de570e63a454f883bc891d6"
checksum = "5452b3e4e97538ee5ef2cc071301c69a86c7adf2770916b9d04e9727096abd93"
dependencies = [
"cranelift-codegen",
"log",
@@ -969,9 +979,9 @@ dependencies = [
[[package]]
name = "cranelift-native"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e69d44d59826eef6794066ac2c0f4ad3975f02d97030c60dbc04e3886adf36e"
checksum = "f68035c10b2e80f26cc29c32fa824380877f38483504c2a47b54e7da311caaf3"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
@@ -980,17 +990,19 @@ dependencies = [
[[package]]
name = "cranelift-wasm"
version = "0.66.0"
version = "0.69.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "979df666b1304624abe99738e9e0e7c7479ee5523ba4b8b237df9ff49996acbb"
checksum = "a530eb9d1c95b3309deb24c3d179d8b0ba5837ed98914a429787c395f614949d"
dependencies = [
"cranelift-codegen",
"cranelift-entity",
"cranelift-frontend",
"itertools 0.9.0",
"log",
"serde",
"smallvec 1.6.1",
"thiserror",
"wasmparser 0.59.0",
"wasmparser",
]
[[package]]
@@ -1297,16 +1309,6 @@ dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "directories"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c"
dependencies = [
"cfg-if 0.1.10",
"dirs-sys",
]
[[package]]
name = "directories"
version = "3.0.1"
@@ -1316,6 +1318,16 @@ dependencies = [
"dirs-sys",
]
[[package]]
name = "directories-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc"
dependencies = [
"cfg-if 1.0.0",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys"
version = "0.3.5"
@@ -1323,7 +1335,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
dependencies = [
"libc",
"redox_users",
"redox_users 0.3.5",
"winapi 0.3.9",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users 0.4.0",
"winapi 0.3.9",
]
@@ -2116,21 +2139,15 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.21.0"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c"
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
dependencies = [
"fallible-iterator",
"indexmap",
"stable_deref_trait",
]
[[package]]
name = "gimli"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
[[package]]
name = "glob"
version = "0.3.0"
@@ -4318,19 +4335,12 @@ dependencies = [
[[package]]
name = "object"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"
[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
dependencies = [
"crc32fast",
"indexmap",
"wasmparser 0.57.0",
]
[[package]]
@@ -5984,6 +5994,15 @@ dependencies = [
"prost",
]
[[package]]
name = "psm"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a"
dependencies = [
"cc",
]
[[package]]
name = "pwasm-utils"
version = "0.14.0"
@@ -6195,9 +6214,9 @@ dependencies = [
[[package]]
name = "raw-cpuid"
version = "7.0.4"
version = "8.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41"
checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73"
dependencies = [
"bitflags",
"cc",
@@ -6270,6 +6289,16 @@ dependencies = [
"rust-argon2",
]
[[package]]
name = "redox_users"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [
"getrandom 0.2.2",
"redox_syscall 0.2.4",
]
[[package]]
name = "ref-cast"
version = "1.0.6"
@@ -6292,9 +6321,9 @@ dependencies = [
[[package]]
name = "regalloc"
version = "0.0.27"
version = "0.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ba8aaf5fe7cf307c6dbdaeed85478961d29e25e3bee5169e11b92fa9f027a8"
checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5"
dependencies = [
"log",
"rustc-hash",
@@ -7478,7 +7507,7 @@ name = "sc-service"
version = "0.8.1"
dependencies = [
"async-std",
"directories 3.0.1",
"directories",
"exit-future",
"futures 0.1.30",
"futures 0.3.12",
@@ -9292,9 +9321,9 @@ checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e"
[[package]]
name = "target-lexicon"
version = "0.10.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9"
[[package]]
name = "tempfile"
@@ -10259,33 +10288,31 @@ dependencies = [
[[package]]
name = "wasmparser"
version = "0.57.0"
version = "0.71.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6"
[[package]]
name = "wasmparser"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9"
checksum = "89a30c99437829ede826802bfcf28500cf58df00e66cb9114df98813bc145ff1"
[[package]]
name = "wasmtime"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd3c4f449382779ef6e0a7c3ec6752ae614e20a42e4100000c3efdc973100e2"
checksum = "7426055cb92bd9a1e9469b48154d8d6119cd8c498c8b70284e420342c05dc45d"
dependencies = [
"anyhow",
"backtrace",
"cfg-if 0.1.10",
"lazy_static",
"bincode",
"cfg-if 1.0.0",
"cpp_demangle",
"indexmap",
"libc",
"log",
"region",
"rustc-demangle",
"serde",
"smallvec 1.6.1",
"target-lexicon",
"wasmparser 0.59.0",
"wasmparser",
"wasmtime-cache",
"wasmtime-environ",
"wasmtime-jit",
"wasmtime-profiling",
@@ -10295,73 +10322,100 @@ dependencies = [
]
[[package]]
name = "wasmtime-debug"
version = "0.19.0"
name = "wasmtime-cache"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e634af9067a3af6cf2c7d33dc3b84767ddaf5d010ba68e80eecbcea73d4a349"
checksum = "c01d9287e36921e46f5887a47007824ae5dbb9b7517a2d565660ab4471478709"
dependencies = [
"anyhow",
"gimli 0.21.0",
"more-asserts",
"object 0.20.0",
"target-lexicon",
"thiserror",
"wasmparser 0.59.0",
"wasmtime-environ",
]
[[package]]
name = "wasmtime-environ"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f85619a94ee4034bd5bb87fc3dcf71fd2237b81c840809da1201061eec9ab3"
dependencies = [
"anyhow",
"base64 0.12.3",
"base64 0.13.0",
"bincode",
"cfg-if 0.1.10",
"cranelift-codegen",
"cranelift-entity",
"cranelift-frontend",
"cranelift-wasm",
"directories 2.0.2",
"directories-next",
"errno",
"file-per-thread-logger",
"indexmap",
"libc",
"log",
"more-asserts",
"rayon",
"serde",
"sha2 0.8.2",
"thiserror",
"sha2 0.9.3",
"toml",
"wasmparser 0.59.0",
"winapi 0.3.9",
"zstd",
]
[[package]]
name = "wasmtime-jit"
version = "0.19.0"
name = "wasmtime-cranelift"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e914c013c7a9f15f4e429d5431f2830fb8adb56e40567661b69c5ec1d645be23"
checksum = "4134ed3a4316cd0de0e546c6004850afe472b0fa3fcdc2f2c15f8d449562d962"
dependencies = [
"cranelift-codegen",
"cranelift-entity",
"cranelift-frontend",
"cranelift-wasm",
"wasmtime-environ",
]
[[package]]
name = "wasmtime-debug"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91fa931df6dd8af2b02606307674d3bad23f55473d5f4c809dddf7e4c4dc411"
dependencies = [
"anyhow",
"cfg-if 0.1.10",
"gimli",
"more-asserts",
"object 0.22.0",
"target-lexicon",
"thiserror",
"wasmparser",
"wasmtime-environ",
]
[[package]]
name = "wasmtime-environ"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1098871dc3120aaf8190d79153e470658bb79f63ee9ca31716711e123c28220"
dependencies = [
"anyhow",
"cfg-if 1.0.0",
"cranelift-codegen",
"cranelift-entity",
"cranelift-wasm",
"gimli",
"indexmap",
"log",
"more-asserts",
"serde",
"thiserror",
"wasmparser",
]
[[package]]
name = "wasmtime-jit"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "738bfcd1561ede8bb174215776fd7d9a95d5f0a47ca3deabe0282c55f9a89f68"
dependencies = [
"addr2line",
"anyhow",
"cfg-if 1.0.0",
"cranelift-codegen",
"cranelift-entity",
"cranelift-frontend",
"cranelift-native",
"cranelift-wasm",
"gimli 0.21.0",
"gimli",
"log",
"more-asserts",
"object 0.20.0",
"object 0.22.0",
"rayon",
"region",
"serde",
"target-lexicon",
"thiserror",
"wasmparser 0.59.0",
"wasmparser",
"wasmtime-cranelift",
"wasmtime-debug",
"wasmtime-environ",
"wasmtime-obj",
@@ -10372,13 +10426,13 @@ dependencies = [
[[package]]
name = "wasmtime-obj"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e81d8e02e9bc9fe2da9b6d48bbc217f96e089f7df613f11a28a3958abc44641e"
checksum = "3e96d77f1801131c5e86d93e42a3cf8a35402107332c202c245c83f34888a906"
dependencies = [
"anyhow",
"more-asserts",
"object 0.20.0",
"object 0.22.0",
"target-lexicon",
"wasmtime-debug",
"wasmtime-environ",
@@ -10386,16 +10440,16 @@ dependencies = [
[[package]]
name = "wasmtime-profiling"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e8d4d1af8dd5f7096cfcc89dd668d358e52980c38cce199643372ffd6590e27"
checksum = "60bb672c9d894776d7b9250dd9b4fe890f8760201ee4f53e5f2da772b6c4debb"
dependencies = [
"anyhow",
"cfg-if 0.1.10",
"gimli 0.21.0",
"cfg-if 1.0.0",
"gimli",
"lazy_static",
"libc",
"object 0.19.0",
"object 0.22.0",
"scroll",
"serde",
"target-lexicon",
@@ -10405,19 +10459,20 @@ dependencies = [
[[package]]
name = "wasmtime-runtime"
version = "0.19.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a25f140bbbaadb07c531cba99ce1a966dba216138dc1b2a0ddecec851a01a93"
checksum = "a978086740949eeedfefcee667b57a9e98d9a7fc0de382fcfa0da30369e3530d"
dependencies = [
"backtrace",
"cc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"indexmap",
"lazy_static",
"libc",
"log",
"memoffset 0.5.6",
"memoffset 0.6.1",
"more-asserts",
"psm",
"region",
"thiserror",
"wasmtime-environ",
@@ -22,7 +22,7 @@ sp-wasm-interface = { version = "2.0.0", path = "../../../primitives/wasm-interf
sp-runtime-interface = { version = "2.0.0", path = "../../../primitives/runtime-interface" }
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
sp-allocator = { version = "2.0.0", path = "../../../primitives/allocator" }
wasmtime = "0.19"
wasmtime = "0.22"
pwasm-utils = "0.14.0"
[dev-dependencies]
@@ -44,15 +44,17 @@ pub fn resolve_imports(
let mut externs = vec![];
let mut memory_import_index = None;
for import_ty in module.imports() {
let name = import_name(&import_ty)?;
if import_ty.module() != "env" {
return Err(WasmError::Other(format!(
"host doesn't provide any imports from non-env module: {}:{}",
import_ty.module(),
import_ty.name()
name,
)));
}
let resolved = match import_ty.name() {
let resolved = match name {
"memory" => {
memory_import_index = Some(externs.len());
resolve_memory_import(store, &import_ty, heap_pages)?
@@ -72,6 +74,16 @@ pub fn resolve_imports(
})
}
/// When the module linking proposal is supported the import's name can be `None`.
/// Because we are not using this proposal we could safely unwrap the name.
/// However, we opt for an error in order to avoid panics at all costs.
fn import_name<'a, 'b: 'a>(import: &'a ImportType<'b>) -> Result<&'a str, WasmError> {
let name = import.name().ok_or_else(||
WasmError::Other("The module linking proposal is not supported.".to_owned())
)?;
Ok(name)
}
fn resolve_memory_import(
store: &Store,
import_ty: &ImportType,
@@ -83,7 +95,7 @@ fn resolve_memory_import(
return Err(WasmError::Other(format!(
"this import must be of memory type: {}:{}",
import_ty.module(),
import_ty.name()
import_name(&import_ty)?,
)))
}
};
@@ -116,49 +128,46 @@ fn resolve_func_import(
host_functions: &[&'static dyn Function],
allow_missing_func_imports: bool,
) -> Result<Extern, WasmError> {
let name = import_name(&import_ty)?;
let func_ty = match import_ty.ty() {
ExternType::Func(func_ty) => func_ty,
_ => {
return Err(WasmError::Other(format!(
"host doesn't provide any non function imports besides 'memory': {}:{}",
import_ty.module(),
import_ty.name()
name,
)));
}
};
let host_func = match host_functions
.iter()
.find(|host_func| host_func.name() == import_ty.name())
.find(|host_func| host_func.name() == name)
{
Some(host_func) => host_func,
None if allow_missing_func_imports => {
return Ok(MissingHostFuncHandler::new(import_ty).into_extern(store, &func_ty));
return Ok(MissingHostFuncHandler::new(import_ty)?.into_extern(store, &func_ty));
}
None => {
return Err(WasmError::Other(format!(
"host doesn't provide such function: {}:{}",
import_ty.module(),
import_ty.name()
name,
)));
}
};
if !signature_matches(&func_ty, &wasmtime_func_sig(*host_func)) {
if &func_ty != &wasmtime_func_sig(*host_func) {
return Err(WasmError::Other(format!(
"signature mismatch for: {}:{}",
import_ty.module(),
import_ty.name()
name,
)));
}
Ok(HostFuncHandler::new(*host_func).into_extern(store))
}
/// Returns `true` if `lhs` and `rhs` represent the same signature.
fn signature_matches(lhs: &wasmtime::FuncType, rhs: &wasmtime::FuncType) -> bool {
lhs.params() == rhs.params() && lhs.results() == rhs.results()
}
/// This structure implements `Callable` and acts as a bridge between wasmtime and
/// substrate host functions.
struct HostFuncHandler {
@@ -243,11 +252,11 @@ struct MissingHostFuncHandler {
}
impl MissingHostFuncHandler {
fn new(import_ty: &ImportType) -> Self {
Self {
fn new(import_ty: &ImportType) -> Result<Self, WasmError> {
Ok(Self {
module: import_ty.module().to_string(),
name: import_ty.name().to_string(),
}
name: import_name(import_ty)?.to_string(),
})
}
fn into_extern(self, store: &Store, func_ty: &FuncType) -> Extern {
@@ -263,22 +272,17 @@ impl MissingHostFuncHandler {
}
fn wasmtime_func_sig(func: &dyn Function) -> wasmtime::FuncType {
let params = func
.signature()
let signature = func.signature();
let params = signature
.args
.iter()
.cloned()
.map(into_wasmtime_val_type)
.collect::<Vec<_>>()
.into_boxed_slice();
let results = func
.signature()
.map(into_wasmtime_val_type);
let results = signature
.return_value
.iter()
.cloned()
.map(into_wasmtime_val_type)
.collect::<Vec<_>>()
.into_boxed_slice();
.map(into_wasmtime_val_type);
wasmtime::FuncType::new(params, results)
}
@@ -113,7 +113,7 @@ impl EntryPoint {
])
},
})
.map(|results|
.map(|results|
// the signature is checked to have i64 return type
results[0].unwrap_i64() as u64
)
@@ -124,27 +124,28 @@ impl EntryPoint {
}
pub fn direct(func: wasmtime::Func) -> std::result::Result<Self, &'static str> {
match (func.ty().params(), func.ty().results()) {
(&[wasmtime::ValType::I32, wasmtime::ValType::I32], &[wasmtime::ValType::I64]) => {
Ok(Self { func, call_type: EntryPointType::Direct })
}
_ => {
Err("Invalid signature for direct entry point")
}
use wasmtime::ValType;
let entry_point = wasmtime::FuncType::new(
[ValType::I32, ValType::I32].iter().cloned(),
[ValType::I64].iter().cloned(),
);
if func.ty() == entry_point {
Ok(Self { func, call_type: EntryPointType::Direct })
} else {
Err("Invalid signature for direct entry point")
}
}
pub fn wrapped(dispatcher: wasmtime::Func, func: u32) -> std::result::Result<Self, &'static str> {
match (dispatcher.ty().params(), dispatcher.ty().results()) {
(
&[wasmtime::ValType::I32, wasmtime::ValType::I32, wasmtime::ValType::I32],
&[wasmtime::ValType::I64],
) => {
Ok(Self { func: dispatcher, call_type: EntryPointType::Wrapped(func) })
},
_ => {
Err("Invalid signature for wrapped entry point")
}
use wasmtime::ValType;
let entry_point = wasmtime::FuncType::new(
[ValType::I32, ValType::I32, ValType::I32].iter().cloned(),
[ValType::I64].iter().cloned(),
);
if dispatcher.ty() == entry_point {
Ok(Self { func: dispatcher, call_type: EntryPointType::Wrapped(func) })
} else {
Err("Invalid signature for wrapped entry point")
}
}
}