Merge pull request #3281 from alexcrichton/small-opts
Some small optimizations for calling wasm functions
This commit is contained in:
@@ -87,7 +87,7 @@ impl Engine {
|
||||
/// latency of WebAssembly calls are extra-important, which is not
|
||||
/// necessarily true of all embeddings.
|
||||
pub fn tls_eager_initialize() -> Result<(), Trap> {
|
||||
wasmtime_runtime::tls_eager_initialize().map_err(Trap::from_runtime)
|
||||
wasmtime_runtime::tls_eager_initialize().map_err(Trap::from_runtime_box)
|
||||
}
|
||||
|
||||
/// Returns the configuration settings that this engine is using.
|
||||
|
||||
@@ -1056,7 +1056,7 @@ pub(crate) fn invoke_wasm_and_catch_traps<T>(
|
||||
);
|
||||
exit_wasm(store, exit);
|
||||
store.0.entering_native_hook()?;
|
||||
result.map_err(Trap::from_runtime)
|
||||
result.map_err(Trap::from_runtime_box)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,6 +368,7 @@ macro_rules! impl_wasm_params {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn into_abi(self, _store: &mut StoreOpaque) -> Option<Self::Abi> {
|
||||
let ($($t,)*) = self;
|
||||
$(
|
||||
@@ -446,6 +447,7 @@ macro_rules! impl_wasm_results {
|
||||
{
|
||||
type ResultAbi = ($($t::Abi,)*);
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_abi(store: &mut StoreOpaque, abi: Self::ResultAbi) -> Self {
|
||||
let ($($t,)*) = abi;
|
||||
($($t::from_abi($t, store),)*)
|
||||
|
||||
@@ -726,6 +726,7 @@ impl StoreInnermost {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn async_support(&self) -> bool {
|
||||
cfg!(feature = "async") && self.engine().config().async_support
|
||||
@@ -736,10 +737,12 @@ impl StoreInnermost {
|
||||
&self.engine
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn store_data(&self) -> &StoreData {
|
||||
&self.store_data
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn store_data_mut(&mut self) -> &mut StoreData {
|
||||
&mut self.store_data
|
||||
}
|
||||
@@ -1230,9 +1233,9 @@ impl AsyncCx {
|
||||
Poll::Pending => {}
|
||||
}
|
||||
|
||||
let before = wasmtime_runtime::TlsRestore::take().map_err(Trap::from_runtime)?;
|
||||
let before = wasmtime_runtime::TlsRestore::take().map_err(Trap::from_runtime_box)?;
|
||||
let res = (*suspend).suspend(());
|
||||
before.replace().map_err(Trap::from_runtime)?;
|
||||
before.replace().map_err(Trap::from_runtime_box)?;
|
||||
res?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +161,11 @@ impl Trap {
|
||||
)
|
||||
}
|
||||
|
||||
#[cold] // see Trap::new
|
||||
pub(crate) fn from_runtime_box(runtime_trap: Box<wasmtime_runtime::Trap>) -> Self {
|
||||
Self::from_runtime(*runtime_trap)
|
||||
}
|
||||
|
||||
#[cold] // see Trap::new
|
||||
pub(crate) fn from_runtime(runtime_trap: wasmtime_runtime::Trap) -> Self {
|
||||
match runtime_trap {
|
||||
|
||||
Reference in New Issue
Block a user