diff --git a/examples/imports_function_env.rs b/examples/imports_function_env.rs index 88caf3c6e..7aa4dc559 100644 --- a/examples/imports_function_env.rs +++ b/examples/imports_function_env.rs @@ -74,10 +74,10 @@ fn main() -> Result<(), Box> { } // Create the functions - fn get_counter(env: &mut Env) -> i32 { + fn get_counter(env: &Env) -> i32 { *env.counter.borrow() } - fn add_to_counter(env: &mut Env, add: i32) -> i32 { + fn add_to_counter(env: &Env, add: i32) -> i32 { let mut counter_ref = env.counter.borrow_mut(); *counter_ref += add; diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index 2b364806e..c026d6a10 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -67,6 +67,8 @@ llvm = [ "wasmer-compiler-llvm", "compiler", ] +# enables internal features used by the deprecated API. +deprecated = [] default-compiler = [] default-engine = [] diff --git a/lib/api/src/externals/function.rs b/lib/api/src/externals/function.rs index 76835b22a..226bb80a5 100644 --- a/lib/api/src/externals/function.rs +++ b/lib/api/src/externals/function.rs @@ -6,6 +6,9 @@ use crate::FunctionType; use crate::NativeFunc; use crate::RuntimeError; pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, WithoutEnv}; +#[cfg(feature = "deprecated")] +pub use inner::{LegacyEnv, WithLegacyEnv}; + use std::cmp::max; use std::fmt; use wasmer_vm::{ @@ -253,6 +256,47 @@ impl Function { } } + /// Function used by the deprecated API to call a function with a `&mut` Env. + /// + /// This is not a stable API and may be broken at any time. + /// + /// # Safety + /// - This function is only safe to use from the deprecated API. + #[doc(hidden)] + #[cfg(feature = "deprecated")] + pub unsafe fn new_native_with_env_legacy( + store: &Store, + env: Env, + func: F, + ) -> Self + where + F: HostFunction, + Args: WasmTypeList, + Rets: WasmTypeList, + Env: LegacyEnv + 'static, + { + let function = inner::Function::::new(func); + let address = function.address(); + + let box_env = Box::new(env); + let vmctx = VMFunctionEnvironment { + host_env: Box::into_raw(box_env) as *mut _, + }; + let signature = function.ty(); + + Self { + store: store.clone(), + definition: FunctionDefinition::Host(HostFunctionDefinition { has_env: true }), + exported: ExportFunction { + address, + kind: VMFunctionKind::Static, + vmctx, + signature, + call_trampoline: None, + }, + } + } + /// Returns the [`FunctionType`] of the `Function`. /// /// # Example @@ -976,6 +1020,14 @@ mod inner { fn function_body_ptr(self) -> *const VMFunctionBody; } + /// Marker trait to limit what the hidden APIs needed for the deprecated API + /// can be used on. + /// + /// Marks an environment as being passed by `&mut`. + #[cfg(feature = "deprecated")] + #[doc(hidden)] + pub unsafe trait LegacyEnv: Sized {} + /// Empty trait to specify the kind of `HostFunction`: With or /// without an environment. /// @@ -991,6 +1043,18 @@ mod inner { impl HostFunctionKind for WithEnv {} + /// An empty struct to help Rust typing to determine + /// when a `HostFunction` does have an environment. + /// + /// This environment is passed by `&mut` and exists soley for the deprecated + /// API. + #[cfg(feature = "deprecated")] + #[doc(hidden)] + pub struct WithLegacyEnv; + + #[cfg(feature = "deprecated")] + impl HostFunctionKind for WithLegacyEnv {} + /// An empty struct to help Rust typing to determine /// when a `HostFunction` does not have an environment. pub struct WithoutEnv; @@ -1216,6 +1280,51 @@ mod inner { } } + // Implement `HostFunction` for a function that has the same arity than the tuple. + // This specific function has an environment. + #[doc(hidden)] + #[cfg(feature = "deprecated")] + #[allow(unused_parens)] + impl< $( $x, )* Rets, RetsAsResult, Env, Func > + HostFunction<( $( $x ),* ), Rets, WithLegacyEnv, Env> + for + Func + where + $( $x: FromToNativeWasmType, )* + Rets: WasmTypeList, + RetsAsResult: IntoResult, + Env: LegacyEnv, + Func: Fn(&mut Env, $( $x , )*) -> RetsAsResult + Send + 'static, + { + #[allow(non_snake_case)] + fn function_body_ptr(self) -> *const VMFunctionBody { + /// This is a function that wraps the real host + /// function. Its address will be used inside the + /// runtime. + extern fn func_wrapper<$( $x, )* Rets, RetsAsResult, Env, Func>( env: &mut Env, $( $x: $x::Native, )* ) -> Rets::CStruct + where + $( $x: FromToNativeWasmType, )* + Rets: WasmTypeList, + RetsAsResult: IntoResult, + Env: Sized, + Func: Fn(&mut Env, $( $x ),* ) -> RetsAsResult + 'static + { + let func: &Func = unsafe { &*(&() as *const () as *const Func) }; + + let result = panic::catch_unwind(AssertUnwindSafe(|| { + func(env, $( FromToNativeWasmType::from_native($x) ),* ).into_result() + })); + + match result { + Ok(Ok(result)) => return result.into_c_struct(), + Ok(Err(trap)) => unsafe { raise_user_trap(Box::new(trap)) }, + Err(panic) => unsafe { resume_panic(panic) }, + } + } + + func_wrapper::< $( $x, )* Rets, RetsAsResult, Env, Self > as *const VMFunctionBody + } + } }; } diff --git a/lib/api/src/externals/mod.rs b/lib/api/src/externals/mod.rs index 370a3173d..4466f1dda 100644 --- a/lib/api/src/externals/mod.rs +++ b/lib/api/src/externals/mod.rs @@ -6,6 +6,9 @@ mod table; pub use self::function::{ FromToNativeWasmType, Function, HostFunction, WasmTypeList, WithEnv, WithoutEnv, }; + +#[cfg(feature = "deprecated")] +pub use self::function::{LegacyEnv, WithLegacyEnv}; pub use self::global::Global; pub use self::memory::Memory; pub use self::table::Table; diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index 1be14f354..247deb7eb 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -46,6 +46,8 @@ pub mod internals { //! `wasmer-vm`. Please don't use any of this types directly, as //! they might change frequently or be removed in the future. + #[cfg(feature = "deprecated")] + pub use crate::externals::{LegacyEnv, WithLegacyEnv}; pub use crate::externals::{WithEnv, WithoutEnv}; } diff --git a/lib/deprecated/runtime-core/Cargo.lock b/lib/deprecated/runtime-core/Cargo.lock index 8b2331c57..d971b374e 100644 --- a/lib/deprecated/runtime-core/Cargo.lock +++ b/lib/deprecated/runtime-core/Cargo.lock @@ -120,6 +120,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -128,18 +134,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", "cranelift-bforest", @@ -149,7 +155,6 @@ dependencies = [ "gimli 0.21.0", "log", "regalloc", - "serde", "smallvec", "target-lexicon", "thiserror", @@ -157,9 +162,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -167,24 +172,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" +checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" [[package]] name = "cranelift-entity" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ "cranelift-codegen", "log", @@ -202,50 +207,49 @@ dependencies = [ ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", - "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", "lazy_static", - "maybe-uninit", "memoffset", "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils", - "maybe-uninit", -] - [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" dependencies = [ "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "lazy_static", ] @@ -570,12 +574,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.3.3" @@ -637,20 +635,20 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" + +[[package]] +name = "object" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" - [[package]] name = "once_cell" version = "1.4.0" @@ -793,9 +791,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque", @@ -805,12 +803,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -824,9 +822,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.26" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", @@ -1011,9 +1009,9 @@ dependencies = [ [[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" @@ -1115,7 +1113,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1137,7 +1135,7 @@ dependencies = [ [[package]] name = "wasmer-cache" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "blake3", "hex", @@ -1148,7 +1146,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "enumset", "raw-cpuid", @@ -1164,7 +1162,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1172,6 +1170,7 @@ dependencies = [ "more-asserts", "rayon", "serde", + "smallvec", "tracing", "wasmer-compiler", "wasmer-types", @@ -1180,7 +1179,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-llvm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "cc", @@ -1202,7 +1201,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "dynasm", @@ -1219,7 +1218,7 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "bincode", @@ -1237,7 +1236,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1253,7 +1252,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1272,9 +1271,9 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ - "object 0.19.0", + "object 0.21.1", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1300,7 +1299,7 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-entity", "serde", @@ -1308,7 +1307,7 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "cc", @@ -1326,9 +1325,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" diff --git a/lib/deprecated/runtime-core/Cargo.toml b/lib/deprecated/runtime-core/Cargo.toml index 12d26452c..432676017 100644 --- a/lib/deprecated/runtime-core/Cargo.toml +++ b/lib/deprecated/runtime-core/Cargo.toml @@ -15,7 +15,7 @@ maintenance = { status = "deprecated" } [dependencies] wasmer-types = { path = "../../wasmer-types", version = "1.0.0-alpha5" } -wasmer = { path = "../../api", version = "1.0.0-alpha5" } +wasmer = { path = "../../api", version = "1.0.0-alpha5", features = ["deprecated"] } wasmer-cache = { path = "../../cache", version = "1.0.0-alpha5" } wasmer-compiler = { path = "../../compiler", version = "1.0.0-alpha5", features = ["translator"] } wasmer-compiler-llvm = { path = "../../compiler-llvm", version = "1.0.0-alpha5", optional = true } diff --git a/lib/deprecated/runtime-core/src/typed_func.rs b/lib/deprecated/runtime-core/src/typed_func.rs index a1b8d7468..8596bc2b3 100644 --- a/lib/deprecated/runtime-core/src/typed_func.rs +++ b/lib/deprecated/runtime-core/src/typed_func.rs @@ -6,6 +6,7 @@ use crate::{ }; use std::marker::PhantomData; +pub use new::wasmer::internals::LegacyEnv; pub use new::wasmer::{HostFunction, WasmTypeList}; /// Represents a function that can be used by WebAssembly. @@ -27,17 +28,19 @@ where /// Creates a new `Func`. pub fn new(func: F) -> Self where - F: HostFunction, + F: HostFunction + Send, { // Create an empty `vm::Ctx`, that is going to be overwritten by `Instance::new`. let ctx = unsafe { vm::Ctx::new_uninit() }; Self { - new_function: new::wasmer::Function::new_native_with_env::( - &get_global_store(), - ctx, - func, - ), + new_function: unsafe { + new::wasmer::Function::new_native_with_env_legacy::( + &get_global_store(), + ctx, + func, + ) + }, _phantom: PhantomData, } } @@ -234,35 +237,36 @@ use std::{ /// `module::Module::instantiate`. pub(crate) struct DynamicCtx { pub(crate) vmctx: Rc>, + inner_func: + Box Result, RuntimeError> + Send + 'static>, } impl DynamicFunc { /// Create a new `DynamicFunc`. pub fn new(signature: &FuncSig, func: F) -> Self where - F: Fn(&mut vm::Ctx, &[Value]) -> Result, RuntimeError> + 'static, + F: Fn(&mut vm::Ctx, &[Value]) -> Result, RuntimeError> + Send + 'static, { // Create an empty `vm::Ctx`, that is going to be overwritten by `Instance::new`. let ctx = DynamicCtx { vmctx: Rc::new(RefCell::new(unsafe { vm::Ctx::new_uninit() })), + inner_func: Box::new(func), }; - Self { - new_function: new::wasmer::Function::new_with_env( - &get_global_store(), - signature, - ctx, - // Wrapper to safely extract a `&mut vm::Ctx` to pass - // to `func`. - move |dyn_ctx: &mut DynamicCtx, - params: &[Value]| - -> Result, RuntimeError> { - let cell: Rc> = dyn_ctx.vmctx.clone(); - let mut vmctx: RefMut = cell.borrow_mut(); + // Wrapper to safely extract a `&mut vm::Ctx` to pass + // to `func`. + fn inner(dyn_ctx: &DynamicCtx, params: &[Value]) -> Result, RuntimeError> { + let cell: Rc> = dyn_ctx.vmctx.clone(); + let mut vmctx: RefMut = cell.borrow_mut(); - func(vmctx.deref_mut(), params) - }, - ), + (dyn_ctx.inner_func)(vmctx.deref_mut(), params) + } + + Self { + new_function: new::wasmer::Function::new_with_env::< + fn(&DynamicCtx, &[Value]) -> Result, RuntimeError>, + DynamicCtx, + >(&get_global_store(), signature, ctx, inner), } } diff --git a/lib/deprecated/runtime-core/src/vm.rs b/lib/deprecated/runtime-core/src/vm.rs index 8b129e3c6..829a5f617 100644 --- a/lib/deprecated/runtime-core/src/vm.rs +++ b/lib/deprecated/runtime-core/src/vm.rs @@ -1,6 +1,8 @@ -use crate::module::ModuleInfo; +use crate::{module::ModuleInfo, new}; use std::{ffi::c_void, ptr}; +use new::wasmer::internals::LegacyEnv; + /// The context of the currently running WebAssembly instance. /// /// This is implicitly passed to every WebAssembly function. @@ -38,6 +40,9 @@ pub struct Ctx { pub data_finalizer: Option, } +/// We mark `Ctx` as a legacy env that can be passed by `&mut`. +unsafe impl LegacyEnv for Ctx {} + impl Ctx { pub(crate) unsafe fn new_uninit() -> Self { Self { diff --git a/lib/deprecated/runtime/Cargo.lock b/lib/deprecated/runtime/Cargo.lock index e4cfe7113..a3584c588 100644 --- a/lib/deprecated/runtime/Cargo.lock +++ b/lib/deprecated/runtime/Cargo.lock @@ -120,6 +120,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -128,18 +134,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", "cranelift-bforest", @@ -149,7 +155,6 @@ dependencies = [ "gimli 0.21.0", "log", "regalloc", - "serde", "smallvec", "target-lexicon", "thiserror", @@ -157,9 +162,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -167,24 +172,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" +checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" [[package]] name = "cranelift-entity" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ "cranelift-codegen", "log", @@ -202,50 +207,49 @@ dependencies = [ ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", - "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", "lazy_static", - "maybe-uninit", "memoffset", "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils", - "maybe-uninit", -] - [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" dependencies = [ "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "lazy_static", ] @@ -570,12 +574,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.3.3" @@ -637,20 +635,20 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" + +[[package]] +name = "object" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" - [[package]] name = "once_cell" version = "1.4.0" @@ -793,9 +791,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque", @@ -805,12 +803,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -824,9 +822,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.26" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", @@ -1011,9 +1009,9 @@ dependencies = [ [[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" @@ -1115,7 +1113,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1137,7 +1135,7 @@ dependencies = [ [[package]] name = "wasmer-cache" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "blake3", "hex", @@ -1148,7 +1146,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "enumset", "raw-cpuid", @@ -1164,7 +1162,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1172,6 +1170,7 @@ dependencies = [ "more-asserts", "rayon", "serde", + "smallvec", "tracing", "wasmer-compiler", "wasmer-types", @@ -1180,7 +1179,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-llvm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "cc", @@ -1202,7 +1201,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "dynasm", @@ -1219,7 +1218,7 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "bincode", @@ -1237,7 +1236,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1253,7 +1252,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1272,9 +1271,9 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ - "object 0.19.0", + "object 0.21.1", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1307,7 +1306,7 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-entity", "serde", @@ -1315,7 +1314,7 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "cc", @@ -1333,9 +1332,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" diff --git a/lib/vm/src/instance.rs b/lib/vm/src/instance.rs index 456125dbd..59de46391 100644 --- a/lib/vm/src/instance.rs +++ b/lib/vm/src/instance.rs @@ -278,8 +278,8 @@ impl Instance { } /// Return a raw pointer to the vmctx used by compiled wasm code. - pub fn vmctx_ptr(&self) -> *const VMContext { - self.vmctx() as *const VMContext + pub fn vmctx_ptr(&self) -> *mut VMContext { + self.vmctx() as *const VMContext as *mut VMContext } /// Lookup an export with the given name. @@ -1021,7 +1021,7 @@ impl InstanceHandle { } /// Return a raw pointer to the vmctx used by compiled wasm code. - pub fn vmctx_ptr(&self) -> *const VMContext { + pub fn vmctx_ptr(&self) -> *mut VMContext { self.instance().vmctx_ptr() }