Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed all deprecated functions #3910

Merged
merged 5 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
128 changes: 2 additions & 126 deletions lib/api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use std::sync::Arc;
#[cfg(feature = "sys")]
pub use wasmer_compiler::{Artifact, CompilerConfig, EngineInner, Features, Tunables};
#[cfg(feature = "sys")]
use wasmer_types::{CompileError, DeserializeError, FunctionType, Target};
#[cfg(feature = "sys")]
use wasmer_vm::VMSharedSignatureIndex;
use wasmer_types::DeserializeError;

#[cfg(feature = "js")]
use crate::js::engine as engine_imp;
Expand All @@ -26,115 +24,17 @@ pub(crate) use crate::js::engine::default_engine;
use crate::jsc::engine as engine_imp;
#[cfg(feature = "jsc")]
pub(crate) use crate::jsc::engine::default_engine;
#[cfg(feature = "sys")]
type EngineId = str;

/// The engine type
#[derive(Clone, Debug)]
pub struct Engine(pub(crate) engine_imp::Engine);

impl Engine {
#[deprecated(
since = "3.2.0",
note = "engine.cloned() has been deprecated in favor of engine.clone()"
)]
/// Returns the [`Engine`].
pub fn cloned(&self) -> Self {
self.clone()
}

/// Returns the deterministic id of this engine
pub fn deterministic_id(&self) -> &str {
self.0.deterministic_id()
}

#[deprecated(since = "3.2.0")]
#[cfg(all(feature = "compiler", feature = "sys"))]
/// Create a new `Engine` with the given config
pub fn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self {
Self(engine_imp::Engine::new(compiler_config, target, features))
}

#[cfg(feature = "sys")]
/// Create a headless `Engine`
/// Will be removed in 4.0 in favor of the NativeEngineExt trait
pub fn headless() -> Self {
Self(engine_imp::Engine::headless())
}

#[deprecated(since = "3.2.0")]
#[cfg(feature = "sys")]
/// Get reference to `EngineInner`.
pub fn inner(&self) -> std::sync::MutexGuard<'_, EngineInner> {
self.0.inner()
}

#[deprecated(since = "3.2.0")]
#[cfg(feature = "sys")]
/// Get mutable reference to `EngineInner`.
pub fn inner_mut(&self) -> std::sync::MutexGuard<'_, EngineInner> {
self.0.inner_mut()
}

#[cfg(feature = "sys")]
/// Gets the target
/// Will be removed in 4.0 in favor of the NativeEngineExt trait
pub fn target(&self) -> &Target {
self.0.target()
}

#[deprecated(since = "3.2.0")]
#[cfg(feature = "sys")]
/// Register a signature
#[cfg(not(target_arch = "wasm32"))]
pub fn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex {
let compiler = self.0.inner();
compiler.signatures().register(func_type)
}

#[deprecated(since = "3.2.0")]
#[cfg(feature = "sys")]
/// Lookup a signature
#[cfg(not(target_arch = "wasm32"))]
pub fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option<FunctionType> {
let compiler = self.0.inner();
compiler.signatures().lookup(sig)
}

#[deprecated(since = "3.2.0")]
#[cfg(feature = "sys")]
/// Validates a WebAssembly module
#[cfg(feature = "compiler")]
pub fn validate(&self, binary: &[u8]) -> Result<(), CompileError> {
self.0.inner().validate(binary)
}

#[deprecated(since = "3.2.0")]
#[cfg(all(feature = "sys", feature = "compiler"))]
#[cfg(not(target_arch = "wasm32"))]
/// Compile a WebAssembly binary
pub fn compile(&self, binary: &[u8]) -> Result<Arc<Artifact>, CompileError> {
Ok(Arc::new(Artifact::new(&self.0, binary, self.0.tunables())?))
}

#[deprecated(since = "3.2.0")]
#[cfg(all(feature = "sys", not(feature = "compiler")))]
#[cfg(not(target_arch = "wasm32"))]
/// Compile a WebAssembly binary
pub fn compile(
&self,
_binary: &[u8],
_tunables: &dyn Tunables,
) -> Result<Arc<Artifact>, CompileError> {
Err(CompileError::Codegen(
"The Engine is operating in headless mode, so it can not compile Modules.".to_string(),
))
}

#[cfg(all(feature = "sys", not(target_arch = "wasm32")))]
/// Deserializes a WebAssembly module which was previously serialized with
/// `Module::serialize`.
Expand Down Expand Up @@ -196,32 +96,8 @@ impl Engine {
file.read_to_end(&mut buffer)?;
Ok(Arc::new(Artifact::deserialize(&self.0, buffer.as_slice())?))
}

#[deprecated(since = "3.2.0", note = "Use Engine::deterministic_id()")]
#[cfg(all(feature = "sys", not(target_arch = "wasm32")))]
/// A unique identifier for this object.
///
/// This exists to allow us to compare two Engines for equality. Otherwise,
/// comparing two trait objects unsafely relies on implementation details
/// of trait representation.
pub fn id(&self) -> &EngineId {
self.deterministic_id()
}

#[cfg(all(feature = "sys", not(target_arch = "wasm32")))]
/// Attach a Tunable to this engine
/// Will be removed in 4.0 in favor of the NativeEngineExt trait
pub fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static) {
self.0.set_tunables(tunables);
}

#[cfg(all(feature = "sys", not(target_arch = "wasm32")))]
/// Get a reference to attached Tunable of this engine
/// Will be removed in 4.0 in favor of the NativeEngineExt trait
pub fn tunables(&self) -> &dyn Tunables {
self.0.tunables()
}
}

impl AsEngineRef for Engine {
#[inline]
fn as_engine_ref(&self) -> EngineRef {
Expand Down
17 changes: 0 additions & 17 deletions lib/api/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,6 @@ impl Exports {
self.get(name)
}

#[deprecated(
since = "3.0.0",
note = "get_native_function() has been renamed to get_typed_function(), just like NativeFunc has been renamed to TypedFunction."
)]
/// Get an export as a `TypedFunction`.
pub fn get_native_function<Args, Rets>(
&self,
store: &impl AsStoreRef,
name: &str,
) -> Result<TypedFunction<Args, Rets>, ExportError>
where
Args: WasmTypeList,
Rets: WasmTypeList,
{
self.get_typed_function(store, name)
}

/// Get an export as a `TypedFunction`.
pub fn get_typed_function<Args, Rets>(
&self,
Expand Down
46 changes: 0 additions & 46 deletions lib/api/src/externals/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,6 @@ impl Function {
Self(function_impl::Function::new_with_env(store, env, ty, func))
}

#[deprecated(
since = "3.0.0",
note = "new_native() has been renamed to new_typed()."
)]
/// Creates a new host `Function` from a native function.
pub fn new_native<F, Args, Rets>(store: &mut impl AsStoreMut, func: F) -> Self
where
F: HostFunction<(), Args, Rets, WithoutEnv> + 'static + Send + Sync,
Args: WasmTypeList,
Rets: WasmTypeList,
{
Self::new_typed(store, func)
}

/// Creates a new host `Function` from a native function.
pub fn new_typed<F, Args, Rets>(store: &mut impl AsStoreMut, func: F) -> Self
where
Expand All @@ -180,24 +166,6 @@ impl Function {
Self(function_impl::Function::new_typed(store, func))
}

#[deprecated(
since = "3.0.0",
note = "new_native_with_env() has been renamed to new_typed_with_env()."
)]
/// Creates a new host `Function` with an environment from a native function.
pub fn new_native_with_env<T: Send + 'static, F, Args, Rets>(
store: &mut impl AsStoreMut,
env: &FunctionEnv<T>,
func: F,
) -> Self
where
F: HostFunction<T, Args, Rets, WithEnv> + 'static + Send + Sync,
Args: WasmTypeList,
Rets: WasmTypeList,
{
Self::new_typed_with_env(store, env, func)
}

/// Creates a new host `Function` with an environment from a typed function.
///
/// The function signature is automatically retrieved using the
Expand Down Expand Up @@ -352,20 +320,6 @@ impl Function {
Self(function_impl::Function::from_vm_funcref(store, funcref))
}

/// Transform this WebAssembly function into a native function.
/// See [`TypedFunction`] to learn more.
#[deprecated(since = "3.0.0", note = "native() has been renamed to typed().")]
pub fn native<Args, Rets>(
&self,
store: &impl AsStoreRef,
) -> Result<TypedFunction<Args, Rets>, RuntimeError>
where
Args: WasmTypeList,
Rets: WasmTypeList,
{
self.typed(store)
}

/// Transform this WebAssembly function into a typed function.
/// See [`TypedFunction`] to learn more.
///
Expand Down
9 changes: 0 additions & 9 deletions lib/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,5 @@ pub use wat::parse_bytes as wat2wasm;
#[cfg(feature = "wasmparser")]
pub use wasmparser;

// Deprecated types

/// This type is deprecated, it has been replaced by TypedFunction.
#[deprecated(
since = "3.0.0",
note = "NativeFunc has been replaced by TypedFunction"
)]
pub type NativeFunc<Args = (), Rets = ()> = TypedFunction<Args, Rets>;

/// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
55 changes: 0 additions & 55 deletions lib/api/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,47 +75,12 @@ impl Store {
}
}

#[deprecated(
since = "3.0.0",
note = "Store::new_with_engine has been deprecated in favor of Store::new"
)]
/// Creates a new `Store` with a specific [`Engine`].
pub fn new_with_engine(engine: impl Into<Engine>) -> Self {
Self::new(engine)
}

#[cfg(feature = "sys")]
/// Set the trap handler in this store.
pub fn set_trap_handler(&mut self, handler: Option<Box<TrapHandlerFn<'static>>>) {
self.inner.trap_handler = handler;
}

#[cfg(feature = "sys")]
#[deprecated(
since = "3.2.0",
note = "store.new_with_tunables() has been deprecated in favor of engine.set_tunables()"
)]
/// Creates a new `Store` with a specific [`Engine`] and [`Tunables`].
pub fn new_with_tunables(
engine: impl Into<Engine>,
tunables: impl Tunables + Send + Sync + 'static,
) -> Self {
let mut engine = engine.into();
engine.set_tunables(tunables);

Self::new(engine)
}

#[cfg(feature = "sys")]
#[deprecated(
since = "3.2.0",
note = "store.tunables() has been deprecated in favor of store.engine().tunables()"
)]
/// Returns the [`Tunables`].
pub fn tunables(&self) -> &dyn Tunables {
self.inner.engine.tunables()
}

/// Returns the [`Engine`].
pub fn engine(&self) -> &Engine {
&self.inner.engine
Expand Down Expand Up @@ -201,16 +166,6 @@ impl<'a> StoreRef<'a> {
&self.inner.objects
}

#[cfg(feature = "sys")]
#[deprecated(
since = "3.2.0",
note = "store.tunables() has been deprecated in favor of store.engine().tunables()"
)]
/// Returns the [`Tunables`].
pub fn tunables(&self) -> &dyn Tunables {
self.inner.engine.tunables()
}

/// Returns the [`Engine`].
pub fn engine(&self) -> &Engine {
&self.inner.engine
Expand Down Expand Up @@ -239,16 +194,6 @@ pub struct StoreMut<'a> {
}

impl<'a> StoreMut<'a> {
/// Returns the [`Tunables`].
#[cfg(feature = "sys")]
#[deprecated(
since = "3.2.0",
note = "store.tunables() has been deprecated in favor of store.engine().tunables()"
)]
pub fn tunables(&self) -> &dyn Tunables {
self.inner.engine.tunables()
}

/// Returns the [`Engine`].
pub fn engine(&self) -> &Engine {
&self.inner.engine
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/sys/externals/function.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::externals::function::{HostFunction, WithEnv, WithoutEnv};
use crate::native_type::{FromToNativeWasmType, IntoResult, NativeWasmTypeInto, WasmTypeList};
use crate::store::{AsStoreMut, AsStoreRef, StoreInner, StoreMut};
use crate::sys::engine::NativeEngineExt;
use crate::vm::{VMExternFunction, VMFunctionCallback};
use crate::{FunctionEnv, FunctionEnvMut, FunctionType, RuntimeError, Value};
use std::panic::{self, AssertUnwindSafe};
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/sys/externals/memory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::memory_view::MemoryView;
use crate::store::{AsStoreMut, AsStoreRef};
use crate::sys::engine::NativeEngineExt;
use crate::vm::VMExternMemory;
use crate::MemoryAccessError;
use crate::MemoryType;
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/sys/externals/table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::store::{AsStoreMut, AsStoreRef};
use crate::sys::engine::NativeEngineExt;
use crate::TableType;
use crate::Value;
use crate::{vm::VMExternTable, ExternRef, Function, RuntimeError};
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/sys/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use wasmer_types::{
};
use wasmer_types::{ExportType, ImportType};

use crate::sys::engine::NativeEngineExt;
use crate::vm::VMInstance;
use crate::{AsStoreMut, AsStoreRef, InstantiationError, IntoBytes};

Expand Down
1 change: 1 addition & 0 deletions lib/api/src/sys/typed_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use wasmer_types::RawValue;

use crate::native_type::NativeWasmTypeInto;
use crate::store::{AsStoreMut, AsStoreRef};
use crate::sys::engine::NativeEngineExt;

macro_rules! impl_native_traits {
( $( $x:ident ),* ) => {
Expand Down
Loading