text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|> store: &mut impl AsStoreMut,
module: &Module,
handle: &mut VMInstance,
) -> Exports {
module
.exports()
.map(|export| {
let name = export.name().to_string();
let export = handle.lookup(&name).expect("export");
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>n.try_into().unwrap() {
warn!(
"attempted to write ({} bytes) beyond the bounds of the memory view ({} > {})",
data.len(),
end,
self.len
);
return Err(MemoryAccessError::HeapOutOfBounds);
}
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::MemoryAccessError;
use crate::store::AsStoreRef;
use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::slice;
use std::{convert::TryInto, ops::Range};
use wasmer_types::Pages;
use wasmer_vm::LinearMemory;
use super::{Memory, MemoryBuffer};
/// A WebAssembly `memory` view.
///
/// ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ernal;
pub mod function;
pub mod global;
pub mod instance;
pub mod memory;
pub mod module;
pub mod store;
pub mod table;
pub mod tag;
<|fim_prefix|>pub mod engine;
pu<|fim_middle|>b mod exception;
pub mod ext<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>oreContext::ensure_installed(store_ptr);
// After the instance handle is created, we need to initialize
// the data, call the start function and so. However, if any
// of this steps traps, we still need to keep the instance alive
// as some of the Instance ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>r::StoreNotRunning)
) {
#[cfg(feature = "experimental-async")]
crate::backend::sys::async_runtime::notify_pending_futures_of_interrupt(self.store_id);
}
}
}
<|fim_prefix|>//! Data types, functions and traits for `sys` runtime's `Store` implementation.
use crate:... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>Not a `sys` store!"),
}
}
/// Convert a mutable reference to store objects into a mutable reference [`crate::backend::sys::store::StoreObjects`].
pub fn as_sys_mut(&mut self) -> &mut crate::backend::sys::store::StoreObjects {
match self {
Self::Sys(s) => s,
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Data types, functions and traits for `sys` runtime's `Table` implementation.
use crate::{
BackendTable, ExternRef, Function, Value,
backend::sys::entities::engine::NativeEngineExt,
entities::store::{AsStoreMut, AsStoreRef},
error::RuntimeError,
vm::{VMExtern, VMExternTable},
};
use... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> given store.
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
self.handle.store_id() == store.as_store_ref().objects().id()
}
pub(crate) fn to_vm_extern(&self) -> VMExtern {
VMExtern::Sys(wasmer_vm::VMExtern::Tag(self.handle.internal_handle()))
}
}
#[cfg(fe... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>f trap.is::<Self>() {
return trap.downcast::<Self>().unwrap();
}
let (wasm_trace, trap_code) = wasmer_compiler::get_trace_and_trapcode(&trap);
Self::new_from_source(crate::BackendTrap::Sys(trap), wasm_trace, trap_code)
}
}
<|fim_prefix|>use crate::LinkError;
use was... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>unctionExtent, Tunables};
pub use wasmer_types::MiddlewareError;
pub use wasmer_types::target::{Architecture, CpuFeature, OperatingSystem, Target, Triple};
#[cfg(feature = "cranelift")]
pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};
#[cfg(feature = "llvm")]
pub use wasmer_compiler_ll... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub use wasmer_compiler::BaseTunables;
// All BaseTunable definition now is in wasmer_compile crate
// Tests are still here
#[cfg(test)]
mod tests {
use super::*;
use crate::TableType;
#[allow(unused)]
use crate::sys::NativeEngineExt;
use std::cell::UnsafeCell;
use std::ptr::NonN... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> )),
Self::Global(g) => crate::Extern::Global(Global::from_vm_extern(
store,
crate::vm::VMExternGlobal::Sys(g),
)),
Self::Table(t) => crate::Extern::Table(Table::from_vm_extern(
store,
crate::vm::VMEx... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)<|fim_suffix|>OUT_DIR"), "/v8_bindings.rs"));
<|fim_middle|>]
#![allow(non_snake_case)]
#![allow(unused)]
// This matches bindgen::Builder output
include!(concat!(env!("<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Data types, functions and traits for `sys` runtime's `Engine` implementation.
use crate::{
BackendEngine,
backend::v8::bindings::{wasm_engine_delete, wasm_engine_new, wasm_engine_t},
};
use std::sync::Arc;
use wasmer_types::{Features, target::Target};
// A handle to an engine, which we want t... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>rted in v8");
}
}
<|fim_prefix|>//! Data types, functions and traits for `sys` runtime's `Tag` implementation.
use std::any::Any;
use wasmer_types::{TagType, Type};
use crate::{
AsStoreMut, AsStoreRef, Tag, Value,
v8::vm::{VMException, VMExceptionRef},
};
use super::store::StoreHandle;
#[d... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>plemented!("ExternRef is not yet supported in wasm_c_api");
}
pub(crate) fn vm_externref(&self) -> VMExternRef {
unimplemented!("ExternRef is not yet supported in wasm_c_api");
}
pub(crate) unsafe fn from_vm_externref(
_store: &mut impl AsStoreMut,
_vm_externref: ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{any::Any, fmt::Debug, marker::PhantomData};
use crate::{
StoreMut,
store::{AsStoreMut, AsStoreRef, StoreRef},
v8::{store::StoreHandle, vm::VMFunctionEnvironment},
};
#[derive(Debug)]
#[repr(transparent)]
/// An opaque reference to a function environment.
/// The function environmen... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> func,
env_handle: None,
}));
let wasm_function = unsafe {
wasm_func_new_with_env(
inner,
wasm_functype,
Some(callback),
callback_env as _,
None,
)
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ts.get_function("function_name")?;
//! let add_one_native: TypedFunction<i32, i32> = add_one.typed().unwrap();
//! ```
use std::iter::FromIterator;
use crate::{
AsStoreMut, FromToNativeWasmType, NativeWasmType, NativeWasmTypeInto, RuntimeError,
TypedFunction, Value, WasmTypeList,
backend::v8... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> fn from_vm_extern(store: &mut impl AsStoreMut, vm_global: VMExternGlobal) -> Self {
check_isolate(store);
Self {
handle: vm_global.unwrap_v_8(),
}
}
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
check_isolate(store);
true
}... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ports,
) -> Result<(Self, Exports), InstantiationError> {
check_isolate(store);
let mut store = store.as_store_mut();
let externs = imports
.imports_for_module(module)
.map_err(InstantiationError::Link)?;
Self::new_by_index(&mut store, module, ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> "failed to allocate copied V8 memory".to_owned(),
));
}
let copied = Self {
handle: VMMemory(copied_memory),
};
let src_view = self.view(store);
let dst_view = copied.view(store);
let src_pages = src_view.size();
let dst_pa... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> self.buffer.len.try_into().unwrap()
}
/// Retrieve a slice of the memory contents.
///
/// # Safety
///
/// Until the returned slice is dropped, it is undefined behaviour to
/// modify the memory contents in any way including by calling a wasm
/// function that writ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>(crate) mod instance;
pub(crate) mod memory;
pub(crate) mod module;
pub(crate) mod store;
pub(crate) mod table;
pub(crate) mod tag;
fn check_isolate(store: &impl crate::AsStoreRef) {
let store = store.as_store_ref();
let v8_store = store.inner.store.as_v8();
if v8_store.thread_id != std::thr... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Data types, functions and traits for `v8` runtime's `Module` implementation.
use std::{
collections::{BTreeMap, <|fim_suffix|>ry_unchecked(
engine: &impl AsEngineRef,
binary: &[u8],
) -> Result<Self, CompileError> {
tracing::info!("Creating module from binary unchecked"... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>&mut crate::backend::v8::store::Store {
match self {
Self::V8(s) => s,
_ => panic!("Not a `v8` store!"),
}
}
/// Return true if [`self`] is a store from the `v8` runtime.
pub fn is_v8(&self) -> bool {
matches!(self, Self::V8(_))
}
}
impl cr... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{fmt, marker::PhantomData, num::NonZeroUsize};
use crate::{
AsStoreMut,
backend::v8::vm::{VMFunctionEnvironment, VMGlobal},
};
pub use wasmer_types::StoreId;
impl crate::StoreObjects {
/// Consume [`self`] into [`crate::backend::v8::store::StoreObjects`].
pub fn into_v8(self) -... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> kind,
of: bindings::wasm_val_t__bindgen_ty_1 { ref_ },
};
Some(value.into_wv())
}
}
pub fn set(
&self,
store: &mut impl AsStoreMut,
index: u32,
val: Value,
) -> Result<(), RuntimeError> {
chec... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>&impl AsStoreRef) -> bool {
check_isolate(store);
true
}
pub(crate) fn to_vm_extern(&self) -> VMExtern {
let extern_ = unsafe { wasm_tag_as_extern(self.handle) };
assert!(
!extern_.is_null(),
"Returned null Tag extern from wasm-c-api"
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> Sync + 'static>)
};
Self {
inner: InnerTrap::User(ptr),
}
} else {
Self {
inner: InnerTrap::CApi(value),
}
}
}
}
impl std::error::Error for Trap {
fn source(&self) -> Option<&(dyn std::er... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
pub use entities::{engine::Engine as V8, *};
<|fim_prefix|>//! Data types, functions and traits for the `v8` backend.
pub(crate) mod bindings;
pub(crate) mod entities;
pub(crate) mod error;
pub(cra<|fim_middle|>te) mod utils;
pub(crate) mod vm;
<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>eturns.is_null() {
vec![]
} else {
std::slice::from_raw_parts((*returns).data, (*returns).size)
.to_vec()
.into_iter()
.map(|v| v.into_wt())
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pu<|fim_suffix|>d convert;
<|fim_middle|>b(crate) mo<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>rence to the underlying value.
pub fn as_mut(&mut self) -> &mut (dyn Any + Send + 'static) {
&mut *self.contents
}
}
<|fim_prefix|>use std::any::Any;
/// Underlying FunctionEnvironment used by a `VMFunction`.
#[derive(Debug)]
pub struct VMFunctionEnvironment {
pub(crate) contents: Box... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>mod env;
use std::sync::Arc;
pub use env::*;
use super::{
bindings::*, entities::function::env::FunctionEnv, function::Function, global::Global,
memory::Memory, table::Table,
};
use crate::{
AsStoreMut, BackendFunction, BackendGlobal, BackendMemory, BackendTable, Extern,
v8::store::Store... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::entities::store::StoreRef;
use super::Engine;
/// A temporary handle to an [`Engine`].
///
/// An [`EngineRef`] can be used to build a [`Module`][crate::entities::Module], and can be created directly
/// from an [`Engine`] or from anything implementing [`AsEngineRef`], like a
<|fim_suffix|>lf... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> {
return Self::Js(crate::backend::js::entities::engine::default_engine());
}
#[cfg(feature = "sys")]
{
return Self::Sys(crate::backend::sys::entities::engine::default_engine());
}
#[cfg(feature = "v8")]
{
return Sel... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>s_for_target(target)
}
#[cfg(feature = "singlepass")]
crate::BackendKind::Singlepass => wasmer_compiler_singlepass::Singlepass::default()
.supported_features_for_target(target),
#[cfg(feature = "v8")]
crate::BackendKind::V8 => {
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::vm::VMExceptionRef;
use crate::{
AsStoreMut, AsStoreRef, BackendTag, ExportError, Exportable, Extern, Tag, Value,
macros::backend::{gen_rt_ty, match_rt},
vm::{VMExtern, VMExternTag},
};
/// A WebAssembly `global` instance.
///
/// A global instance is the runtime representation of ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub(crate) mod inner;
pub(crate) use inner::*;
use wasmer_types::{TagType, Type};
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern, Tag, Value,
vm::{VMExceptionRef, VMExtern, VMEx<|fim_suffix|>erive_more::From)]
#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>gs: WasmTypeList, Rets: WasmTypeList>: Sized {
/// Get an export with the given generics.
fn get_self_from_extern_with_generics(_extern: &'a Extern) -> Result<Self, ExportError>;
}
/// We implement it for all concrete [`Exportable`] types (that are `Clone`)
/// with empty `Args` and `Rets`.
impl<... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ature = "sys")]
crate::BackendStore::Sys(_) => Self::Sys(unsafe {
crate::backend::sys::entities::external::ExternRef::from_vm_externref(
store,
vm_externref.unwrap_sys(),
)
}),
#[cfg(feature = "v8")... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ref(store, vm_externref) })
}
/// Checks whether this `ExternRef` can be used with the given context.
///
/// Primitive (`i32`, `i64`, etc) and null funcref/externref values are not
/// tied to a context and can be freely shared between contexts.
///
/// Externref and funcref ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub(crate) mod extref;
pub use extref::*;
use wasmer_types::ExternType;
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Function, Global, Memory, Table, Tag,
vm::VMExtern,
};
/// Trait convert a VMExtern to a Extern
pub trait VMExternToExtern {
/// Convert to [`Extern`]
fn... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{future::Future, marker::PhantomData, pin::Pin};
use crate::{
AsyncFunctionEnvMut, HostFunctionKind, RuntimeError, WasmTypeList, WithEnv, WithoutEnv,
utils::{FromToNativeWasmType, IntoResult},
};
/// Wrapper conveying whether an async host function receives an environment.
pub enum Asyn... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>kendFunctionEnvMut<'_, T> {
fn as_store_ref(&self) -> StoreRef<'_> {
match_rt!(on self => s {
s.as_store_ref()
})
}
}
impl<T> AsStoreMut for BackendFunctionEnvMut<'_, T> {
fn as_store_mut(&mut self) -> StoreMut<'_> {
match_rt!(on self => s {
s.a... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> {
self.0.data_and_store()
}
}
#[cfg(feature = "experimental-async")]
impl<T: 'static> AsStoreRef for AsyncFunctionEnvHandle<T> {
fn as_store_ref(&self) -> StoreRef<'_> {
AsStoreRef::as_store_ref(&self.0)
}
}
#[cfg(feature = "experimental-async")]
impl<T: 'static> AsyncFuncti... | fim | wasmerio/wasmer | rust |
use crate::{
AsStoreMut, AsStoreRef, BackendFunctionEnv, BackendFunctionEnvMut, FunctionEnvMut,
FunctionType, HostFunction, RuntimeError, StoreInner, StoreMut, StoreRef, Value, WithEnv,
WithoutEnv,
utils::{FromToNativeWasmType, IntoResult, NativeWasmTypeInto, WasmTypeList},
};
use std::panic::{self, As... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>mod imp;
use crate::{
BackendKind, WasmTypeList,
vm::{VMFunctionCallback, VMTrampoline},
};
/// The `HostFunction` trait represents the set of functions that
/// can be used as host function. To uphold this statement, it is
/// necessary for a function to be transformed into a
/// `VMFunctionCal... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::pin::Pin;
use wasmer_types::{FunctionType, RawValue};
#[cfg(feature = "experimental-async")]
use crate::{AsStoreAsync, AsyncFunctionEnvMut, entities::function::async_host::AsyncHostFunction};
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern, FunctionEnv, FunctionEnvMut,
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Defines the [`Function`] and [`HostFunction`] types and useful traits and data types to
//! interact with them.
pub(crate) mod inner;
pub use inner::*;
pub(crate) mod host;
pub use host::*;
pub(crate) mod env;
pub use env::*;
#[cfg(feature = "experimental-async")]
pub(crate) mod async_host;
#[cfg(... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::{
ExportError, Exportable, Extern,
error::RuntimeError,
macros::backend::{gen_rt_ty, match_rt},
store::{AsStoreMut, AsStoreRef, StoreMut, StoreRef},
value::Value,
vm::{VMExtern, VMExternGlobal},
};
use wasmer_types::{GlobalType, Mutability};
/// A WebAssembly `global` i... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>obal);
impl Global {
/// Create a new global with the initial [`Value`].
///
/// # Example
///
/// ```
/// # use wasmer::{Global, Mutability, Store, Value};
/// # let mut store = Store::default();
/// #
/// let g = Global::new(&mut store, Value::I32(1));
///
//... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> "func" => Function::new_typed(&mut store, func),
},
"abc" => {
"def" => Function::new_typed(&mut store, func),
}
};
let _ = imports! {
"env" => {
"func" => Function::new_typed(&mut store, func)
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>);
}
<|fim_prefix|>use crate::{
Extern, error::InstantiationError, exports::Exports, imports::Imports,
macros::backend::gen_rt_ty, module::Module, store::AsStoreMut,
};
/// A WebAssembly Instance is a stateful, executable
/// instance of a WebAssembly [`Module`].
///
/// Instance objects contain ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{marker::PhantomData, mem::MaybeUninit};
use crate::{
MemoryAccessError,
macros::backend::{gen_rt_ty, match_rt},
};
/// Underlying buffer for a memory.
gen_rt_ty! {
#[derive(Debug, Copy, Clone, derive_more::From)]
pub BackendMemoryBuffer<'a>(entities::memory::MemoryBuffer<'a>);
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{marker::PhantomData, mem::MaybeUninit};
use crate::MemoryAccessError;
pub(crate) mod inner;
pub(crate) use inner::*;
/// Underlying buffer for a memory.
#[derive(Debug, Copy, Clone, derive_more::From)]
pub(crate) struct MemoryBuffer<'a>(pub(crate) BackendMemoryBuffer<'a>);
impl MemoryBuffer<... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use super::{SharedMemory, shared_memory_detach_error, view::*};
use wasmer_types::{MemoryError, MemoryType, Pages};
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern, StoreMut, StoreRef,
macros::backend::{gen_rt_ty, match_rt},
vm::{VMExtern, VMExternMemory, VMMemory},
};
g... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use crate::error::AtomicsError;
/// Location in a WebAssembly memory.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MemoryLocation {
// NOTE: must be expanded to an enum that also supports 64bit memory in
// the future
// That's why this is private.
pub(cr... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>the thread owning the other `Store`.
pub fn copy_to_store(
&self,
store: &impl AsStoreRef,
new_store: &mut impl AsStoreMut,
) -> Result<Self, MemoryError> {
self.copy(store).map(|memory| memory.attach(new_store))
}
pub(crate) fn from_vm_extern(store: &mut i... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::sync::Arc;
use crate::{
AsStoreMut, Memory,
error::AtomicsError,
location::{MemoryLocation, SharedMemoryOps},
vm::VMMemory,
vm::VMSharedMemory,
};
/// A shared memory instance that can be shared across multiple stores and threads,
/// not attached to any specific store.
pub ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> self => s {
s.data_ptr()
})
}
/// Returns the size (in bytes) of the `Memory`.
#[inline]
pub fn data_size(&self) -> u64 {
match_rt!(on self => s {
s.data_size()
})
}
/// Retrieve a slice of the memory contents.
///
/// # Sa... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{mem::MaybeUninit, ops::Range};
use wasmer_types::Pages;
use crate::{AsStoreRef, Memory, MemoryAccessError, buffer::MemoryBuffer};
pub(crate) mod inner;
pub(crate) use inner::*;
/// A WebAssembly `memory` view.
///
/// A memory view is used to read and write to the linear memory.
///
/// After... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> use memory::*;
pub(crate) mod exports;
pub use exports::*;
pub(crate) mod imports;
pub use imports::*;
<|fim_prefix|>//! This module defines data types, functions and traits used to describe and interact with
//! various WebAssembly entities such as [`Value`], [`Module`] and [`Store`]. It also describe... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Defines the [`BackendModule`] data type and various useful traits and data types to interact with
//! a concrete module from a backend.
use std::{fs, path::Path};
use bytes::Bytes;
use thiserror::Error;
#[cfg(feature = "wat")]
use wasmer_types::WasmError;
use wasmer_types::{
CompilationProgressC... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Defines the [`Module`] data type and various useful traits and data types to interact with a
//! module.
pub(crate) mod inner;
pub(crate) use inner::*;
use std::{fs, path::Path};
use bytes::Bytes;
use thiserror::Error;
#[cfg(feature = "wat")]
use wasmer_types::WasmError;
use wasmer_types::{
Com... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::{fmt::Debug, marker::PhantomData};
use crate::{
AsStoreMut, AsStoreRef, LocalRwLock, LocalRwLockReadGuard, LocalRwLockWriteGuard, Store,
StoreContext, StoreInner, StoreMut, StorePtrWrapper, StoreRef,
};
use wasmer_types::StoreId;
/// A store that can be used to invoke
/// [`Function:<|... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> })
}
}
impl Drop for StorePtrPauseGuard {
fn drop(&mut self) {
if std::thread::panicking() {
return;
}
STORE_CONTEXT_STACK.with(|cell| {
let mut stack = cell.borrow_mut();
let top = stack
.last_mut()
.ex... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> => s {
s.engine_mut()
})
}
}
impl AsEngineRef for BackendStore {
#[inline]
fn as_engine_ref(&self) -> crate::EngineRef<'_> {
match_rt!(on self => s {
s.as_engine_ref()
})
}
}
<|fim_prefix|>use crate::{
AsStoreMut, AsStoreRef, StoreRef,
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>get() {
let waiters = if is_write {
&self.write_waiters
} else {
&self.read_waiters
};
let mut waiters = waiters.borrow_mut();
if index < waiters.len() {
waiters[index] = None;
}
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Defines the [`Store`] data type and various useful traits and data types to interact with a
//! store.
/// Defines the [`AsStoreAsync`] trait and its supporting types.
#[cfg(feature = "experimental-async")]
mod async_;
#[cfg(feature = "experimental-async")]
pub use async_::*;
/// Defines the [`Store... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> s.id()
})
}
#[inline]
pub(crate) fn from_store_ref(store: &BackendStore) -> Self {
match store {
#[cfg(feature = "sys")]
BackendStore::Sys(_) => Self::Sys(Default::default()),
#[cfg(feature = "v8")]
BackendStore::V8(_) => Sel... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ineRef<'_> {
self.inner.store.as_engine_ref()
}
}
<|fim_prefix|>use std::ops::{Deref, DerefMut};
use super::{StoreObjects, inner::StoreInner};
use crate::entities::engine::{AsEngineRef, Engine, EngineRef};
#[cfg(feature = "experimental-async")]
use crate::{AsStoreAsync, StoreAsync};
use wasme... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>xtern(store, ext),
),
#[cfg(feature = "js")]
BackendStore::Js(_) => Self::Js(
crate::backend::js::entities::table::Table::from_vm_extern(store, ext),
),
}
}
/// Checks whether this `Table` can be used with the given context.
... | fim | wasmerio/wasmer | rust |
use wasmer_types::TableType;
pub(crate) mod inner;
pub(crate) use inner::*;
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern, StoreMut, StoreRef, Value,
error::RuntimeError,
store::BackendStore,
vm::{VMExtern, VMExternTable},
};
/// A WebAssembly `table` instance.
///
/// The `Tab... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use wasmer_types::{TagType, Type};
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern,
macros::backend::{gen_rt_ty, match_rt},
vm::{VMExtern, VMExternTag},
};
/// A WebAssembly `global` instance.
///
/// A global instance is the runtime representation of a global variable.
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub(crate) mod inner;
pub(crate) use inner::*;
use wasmer_types::{TagType, Type};
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern,
vm::{VMExtern, VMExternTag},
};
/// A WebAssembly `tag` instance.
///
/// A tag instance is the runtime representation of a tag variable.
///
//... | fim | wasmerio/wasmer | rust |
use std::{any::Any, error::Error, fmt::Debug};
#[cfg(feature = "sys")]
use crate::BackendException;
use crate::{Exception, RuntimeError, macros::backend::match_rt};
/// An enumeration of all the trap kinds supported by the runtimes.
#[derive(Debug, derive_more::From)]
pub enum BackendTrap {
#[cfg(feature = "sys")... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use wasmer_types::{RawValue, Type};
use crate::{
AsStoreRef, Tag,
entities::{Exception, ExternRef, Function},
vm::{VMExceptionRef, VMExternRef, VMFuncRef},
};
/// WebAssembly computations manipulate values of basic value types:
/// * Integers (32 or 64 bit width)
/// * Floating-point (32 or ... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> }
_ => panic!("exceptions are only supported in the `sys` backend"),
}
}
/// Returns a reference the `message` stored in `Trap`.
pub fn message(&self) -> String {
if let Some(trap_code) = self.inner.trap_code {
trap_code.message().to_string()
... | fim | wasmerio/wasmer | rust |
#![doc(
html_logo_url = "https://github.com/wasmerio.png?size=200",
html_favicon_url = "https://wasmer.io/images/icons/favicon-32x32.png"
)]
#![deny(
missing_docs,
trivial_numeric_casts,
unused_extern_crates,
rustdoc::broken_intra_doc_links
)]
#![warn(unused_import_braces)]
#![allow(
clippy:... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>n into_bytes(self) -> Bytes {
Bytes::from(self.clone())
}
}
impl IntoBytes for &[u8] {
fn into_bytes(self) -> Bytes {
Bytes::from(self.to_vec())
}
}
impl<const N: usize> IntoBytes for &[u8; N] {
fn into_bytes(self) -> Bytes {
Bytes::from(self.to_vec())
}
}
im... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>/// Automatically generate "backend" types.
#[macro_use]
macro_rules! gen_rt_ty {
{
$(#[$meta:meta])*
$vis:vis
$id:ident$(<
$($lt:lifetime),*
$(,)?
$($param:ident),*
>)?(
$path:path
) $(;)?
} => {
paste... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub(crate)<|fim_suffix|>
<|fim_middle|> mod backend;<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::mem::{self, MaybeUninit};
use std::slice;
use crate::{
MemoryAccessError,
utils::mem::{WasmRef, WasmSlice},
};
pub(crate) enum SliceCow<'a, T> {
#[allow(dead_code)]
Borrowed(&'a mut [T]),
#[allow(dead_code)]
Owned(Vec<T>, bool),
}
impl<T> AsRef<[T]> for SliceCow<'_, T> ... | fim | wasmerio/wasmer | rust |
pub(crate) mod access;
pub(crate) mod ptr;
pub use ptr::*;
use std::{
marker::PhantomData,
mem::{self, MaybeUninit},
ops::Range,
slice,
string::FromUtf8Error,
};
use crate::{buffer::MemoryBuffer, error::RuntimeError, view::MemoryView};
use access::{WasmRefAccess, WasmSliceAccess};
use thiserror::E... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>rySize> std::fmt::Debug for WasmPtr<T, M> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}(@{})", std::any::type_name::<T>(), self.offset.into())
}
}
<|fim_prefix|>use std::marker::PhantomData;
use wasmer_types::{Memory32, Memory64, MemorySize, ValueType};
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>b(crate) mod native;
pub use native::*;
/// Useful data types, functions and traits for interacting with the memory of a [`crate::Instance`].
pub(crate) mod mem;
pub use mem::*;
/// Useful macros to generate enums to represent `Runtime`-types.
pub(crate) mod rt_macros;
#[cfg(feature = "wasm-types-polyf... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>pub use wasmer_types::NativeWasmType;
use wasmer_types::{RawValue, Type};
use crate::store::AsStoreRef;
use crate::{
ExternRef, Function, TypedFunction,
vm::{VMExternRef, VMFuncRef},
};
use std::error::Error;
use std::{
array::TryFromSliceError,
convert::{Infallible, TryInto},
};
use cr... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ctions.
pub(crate) mod typed_func;
pub use typed_func::*;
<|fim_prefix|>/// Traits <|fim_middle|>and implementations used to convert between native values and WebAssembly ones.
pub(crate) mod convert;
pub use convert::*;
/// Trait to interact with native fun<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>tore.read_lock().await;
match read_lock.as_store_ref().inner.store {
#[cfg(feature = "sys")]
BackendStore::Sys(_) => {
drop(read_lock);
Self::call_async_sys(func, store, $([<p_ $x>])... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Polyfill skeleton that traverses the whole WebAssembly module and
//! creates the corresponding import and export types.
//!
//! This shall not be needed once the JS type reflection API is available
//! for the Wasm imports and exports.//!
//! <https://github.com/WebAssembly/js-types/blob/master/propo... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ch_rt!(on self => s {
s.into_raw()
})
}
}
impl VMMemory {
/// Attempts to share this memory and return a shared detached memory.
pub(crate) fn as_shared(&self) -> Result<VMSharedMemory, wasmer_types::MemoryError> {
match self {
#[cfg(feature = "sys")]
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! This module defines traits to handle abstractions created by the runtimes.
mod impls;
use crate::{VMExternToExtern, macros::backend::gen_rt_ty};
use wasmer_types::RawValue;
macro_rules! define_vm_like {
($name:ident $(, $derives:ident)*) => {
paste::paste! {
gen_rt_ty! {
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>);
let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]);
let function = Function::new_with_env(
&mut store,
&env,
&function_type,
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
);
assert_eq!(func... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>lue = data.global.get(&mut storemut).unwrap_i32() + 10;
data.global
.set(&mut storemut, Value::I32(data.value))
.unwrap();
assert_eq!(data.global.get(&mut storemut), Value::I32(data.value));
Ok(())
}
<|fim_prefix|>use macro_wasmer_engine_test::engine_test;
#[cfg(feature = "j... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use macro_wasmer_engine_test::engine_test;
#[cfg(feature = "js")]
use wasm_bindgen_test::*;
use anyhow::Result;
use wasmer::*;
#[engine_test]
#[cfg_attr(
all(target_os = "windows", feature = "v8"),
ignore = "flaky test on windows when using v8"
)]
fn pass_i64_between_host_and_plugin() -> Result<... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use macro_wasmer_engine_test::engine_test;
#[cfg(feature = "js")]
use wasm_bindgen_test::*;
use wasmer::*;
#[engine_test]
fn exports_work_after_multiple_instances_have_been_freed() -> Result<(), String> {
let mut store = Store::default();
let module = Module::new(
&store,
"
(modu... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#![cfg(all(unix, feature = "experimental-host-interrupt"))]
// TODO: tests for recursive function calls across different stores
use std::{
sync::{
Arc, Barrier, Mutex,
atomic::{AtomicBool, Ordering},
},
thread,
time::Duration,
};
use anyhow::Result;
use wasmer::{
AsS... | fim | wasmerio/wasmer | rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.