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 2 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
99 changes: 1 addition & 98 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, Target};

#[cfg(feature = "js")]
use crate::js::engine as engine_imp;
Expand All @@ -26,115 +24,31 @@ 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 @@ -197,17 +111,6 @@ impl Engine {
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
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
6 changes: 3 additions & 3 deletions lib/c-api/src/wasm_c_api/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use std::slice;
#[cfg(feature = "webc_runner")]
use wasmer_api::{AsStoreMut, Imports, Module};
use wasmer_wasix::{
default_fs_backing, get_wasi_version, virtual_fs::AsyncReadExt, Pipe, VirtualTaskManager,
WasiEnv, WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion,
default_fs_backing, get_wasi_version, virtual_fs::AsyncReadExt, virtual_fs::VirtualFile, Pipe,
VirtualTaskManager, WasiEnv, WasiEnvBuilder, WasiFunctionEnv, WasiVersion,
};

#[derive(Debug)]
Expand Down Expand Up @@ -400,7 +400,7 @@ pub unsafe extern "C" fn wasi_env_read_stderr(

fn read_inner(
tasks: &dyn VirtualTaskManager,
wasi_file: &mut Box<dyn WasiFile + Send + Sync + 'static>,
wasi_file: &mut Box<dyn VirtualFile + Send + Sync + 'static>,
inner_buffer: &mut [u8],
) -> isize {
tasks.block_on(async {
Expand Down
4 changes: 0 additions & 4 deletions lib/compiler-cranelift/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ impl CompilerConfig for Cranelift {
self.enable_verifier = true;
}

fn enable_nan_canonicalization(&mut self) {
self.enable_nan_canonicalization = true;
}

fn canonicalize_nans(&mut self, enable: bool) {
self.enable_nan_canonicalization = enable;
}
Expand Down
4 changes: 0 additions & 4 deletions lib/compiler-llvm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ impl CompilerConfig for LLVM {
self.enable_verifier = true;
}

fn enable_nan_canonicalization(&mut self) {
self.enable_nan_canonicalization = true;
}

fn canonicalize_nans(&mut self, enable: bool) {
self.enable_nan_canonicalization = enable;
}
Expand Down
4 changes: 0 additions & 4 deletions lib/compiler-singlepass/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ impl Singlepass {
}
}

fn enable_nan_canonicalization(&mut self) {
self.enable_nan_canonicalization = true;
}

pub fn canonicalize_nans(&mut self, enable: bool) -> &mut Self {
self.enable_nan_canonicalization = enable;
self
Expand Down
Loading