Skip to content

Commit

Permalink
Un-gate Func::new on compiler features (#8646)
Browse files Browse the repository at this point in the history
This commit enables the `Func::new` constructor and related other
functions when `cranelift` and `winch` features are both disabled,
meaning this is now available in compiler-less builds. This builds on
the support of #8629.
  • Loading branch information
alexcrichton committed May 17, 2024
1 parent 7e8abe3 commit a77e877
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
4 changes: 0 additions & 4 deletions crates/wasmtime/src/runtime/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ impl Func {
///
/// Panics if the given function type is not associated with this store's
/// engine.
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn new<T>(
store: impl AsContextMut<Data = T>,
ty: FuncType,
Expand Down Expand Up @@ -489,7 +488,6 @@ impl Func {
///
/// Panics if the given function type is not associated with this store's
/// engine.
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub unsafe fn new_unchecked<T>(
mut store: impl AsContextMut<Data = T>,
ty: FuncType,
Expand Down Expand Up @@ -2199,7 +2197,6 @@ impl HostFunc {
///
/// Panics if the given function type is not associated with the given
/// engine.
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn new<T>(
engine: &Engine,
ty: FuncType,
Expand All @@ -2220,7 +2217,6 @@ impl HostFunc {
///
/// Panics if the given function type is not associated with the given
/// engine.
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub unsafe fn new_unchecked<T>(
engine: &Engine,
ty: FuncType,
Expand Down
5 changes: 0 additions & 5 deletions crates/wasmtime/src/runtime/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ impl<T> Linker<T> {
/// # Ok(())
/// # }
/// ```
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn define_unknown_imports_as_traps(&mut self, module: &Module) -> anyhow::Result<()> {
for import in module.imports() {
if let Err(import_err) = self._get_by_import(&import) {
Expand Down Expand Up @@ -310,7 +309,6 @@ impl<T> Linker<T> {
/// # Ok(())
/// # }
/// ```
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn define_unknown_imports_as_default_values(
&mut self,
module: &Module,
Expand Down Expand Up @@ -428,7 +426,6 @@ impl<T> Linker<T> {
///
/// Panics if the given function type is not associated with the same engine
/// as this linker.
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn func_new(
&mut self,
module: &str,
Expand All @@ -451,7 +448,6 @@ impl<T> Linker<T> {
///
/// Panics if the given function type is not associated with the same engine
/// as this linker.
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub unsafe fn func_new_unchecked(
&mut self,
module: &str,
Expand Down Expand Up @@ -781,7 +777,6 @@ impl<T> Linker<T> {
/// # Ok(())
/// # }
/// ```
#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn module(
&mut self,
mut store: impl AsContextMut<Data = T>,
Expand Down
6 changes: 2 additions & 4 deletions crates/wasmtime/src/runtime/trampoline/func.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! Support for a calling of an imported function.

use crate::prelude::*;
use crate::runtime::vm::{
StoreBox, VMArrayCallHostFuncContext, VMContext, VMFuncRef, VMOpaqueContext,
};
use crate::type_registry::RegisteredType;
use crate::{FuncType, ValRaw};
use anyhow::Result;
use core::ptr;

struct TrampolineState<F> {
func: F,
Expand Down Expand Up @@ -67,17 +69,13 @@ unsafe extern "C" fn array_call_shim<F>(
}
}

#[cfg(any(feature = "cranelift", feature = "winch"))]
pub fn create_array_call_function<F>(
ft: &FuncType,
func: F,
) -> Result<StoreBox<VMArrayCallHostFuncContext>>
where
F: Fn(*mut VMContext, &mut [ValRaw]) -> Result<()> + Send + Sync + 'static,
{
use crate::prelude::*;
use std::ptr;

let array_call = array_call_shim::<F>;

let sig = ft.clone().into_registered_type();
Expand Down

0 comments on commit a77e877

Please sign in to comment.