From ff4a127dbb8797c68f0b573c37557344c25d18ae Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 31 May 2021 17:13:14 +0200 Subject: [PATCH 1/2] chore(api): Remove the `deprecated` feature and associated code. --- lib/api/Cargo.toml | 4 -- lib/api/src/externals/function.rs | 115 ------------------------------ lib/api/src/externals/mod.rs | 2 - lib/api/src/lib.rs | 2 - 4 files changed, 123 deletions(-) diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index b46ebf3a2ea..910def5ee9d 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -70,10 +70,6 @@ llvm = [ "wasmer-compiler-llvm", "compiler", ] -# enables internal features used by the deprecated API. -deprecated = [] -default-compiler = [] -default-engine = [] default-singlepass = [ "singlepass", diff --git a/lib/api/src/externals/function.rs b/lib/api/src/externals/function.rs index 8bc8565e707..26061482f33 100644 --- a/lib/api/src/externals/function.rs +++ b/lib/api/src/externals/function.rs @@ -7,8 +7,6 @@ use crate::NativeFunc; use crate::RuntimeError; use crate::WasmerEnv; pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, WithoutEnv}; -#[cfg(feature = "deprecated")] -pub use inner::{UnsafeMutableEnv, WithUnsafeMutableEnv}; use loupe::MemoryUsage; use std::cmp::max; @@ -358,53 +356,6 @@ 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_unsafe_mutable_env( - store: &Store, - env: Env, - func: F, - ) -> Self - where - F: HostFunction, - Args: WasmTypeList, - Rets: WasmTypeList, - Env: UnsafeMutableEnv + WasmerEnv + 'static, - { - if std::mem::size_of::() != 0 { - Self::closures_unsupported_panic(); - } - let function = inner::Function::::new(func); - let address = function.address(); - - let (host_env, metadata) = - build_export_function_metadata::(env, Env::init_with_instance); - - let vmctx = VMFunctionEnvironment { host_env }; - let signature = function.ty(); - - Self { - store: store.clone(), - exported: ExportFunction { - metadata: Some(Arc::new(metadata)), - vm_function: VMFunction { - address, - kind: VMFunctionKind::Static, - vmctx, - signature, - call_trampoline: None, - instance_ref: None, - }, - }, - } - } - /// Returns the [`FunctionType`] of the `Function`. /// /// # Example @@ -1163,14 +1114,6 @@ 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 UnsafeMutableEnv: Sized {} - /// Empty trait to specify the kind of `HostFunction`: With or /// without an environment. /// @@ -1186,18 +1129,6 @@ mod inner { impl HostFunctionKind for WithEnv {} - /// An empty struct to help Rust typing to determine - /// when a `HostFunction` has an environment. - /// - /// This environment is passed by `&mut` and exists solely for the deprecated - /// API. - #[cfg(feature = "deprecated")] - #[doc(hidden)] - pub struct WithUnsafeMutableEnv; - - #[cfg(feature = "deprecated")] - impl HostFunctionKind for WithUnsafeMutableEnv {} - /// An empty struct to help Rust typing to determine /// when a `HostFunction` does not have an environment. #[derive(Clone)] @@ -1423,52 +1354,6 @@ mod inner { func_wrapper::< $( $x, )* Rets, RetsAsResult, Env, Self > as *const VMFunctionBody } } - - // 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, WithUnsafeMutableEnv, Env> - for - Func - where - $( $x: FromToNativeWasmType, )* - Rets: WasmTypeList, - RetsAsResult: IntoResult, - Env: UnsafeMutableEnv, - 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 71ac65b5729..79859c92d9e 100644 --- a/lib/api/src/externals/mod.rs +++ b/lib/api/src/externals/mod.rs @@ -7,8 +7,6 @@ pub use self::function::{ FromToNativeWasmType, Function, HostFunction, WasmTypeList, WithEnv, WithoutEnv, }; -#[cfg(feature = "deprecated")] -pub use self::function::{UnsafeMutableEnv, WithUnsafeMutableEnv}; 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 65d12a4c534..1ce2f0cfd84 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -278,8 +278,6 @@ 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::{UnsafeMutableEnv, WithUnsafeMutableEnv}; pub use crate::externals::{WithEnv, WithoutEnv}; } From 16e18379ebdc5cf184d20e11f81938001cfc356a Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 1 Jun 2021 09:19:35 +0200 Subject: [PATCH 2/2] chore(api) Restore the `default-compiler` and `default-engine` features. They were marked as deprecated but they are actually not :-)! --- lib/api/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index 910def5ee9d..ba16c723b24 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -92,6 +92,9 @@ default-dylib = [ "default-engine" ] +default-compiler = [] +default-engine = [] + # experimental / in-development features experimental-reference-types-extern-ref = [ "wasmer-types/experimental-reference-types-extern-ref",