mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 05:38:19 +00:00
Implement the new Context API for the core API
Co-authored-by: ptitSeb <sebastien.chev@gmail.com>
This commit is contained in:
committed by
Manos Pitsidianakis
parent
f16bd35d3c
commit
738a66f719
@@ -20,8 +20,9 @@
|
||||
)
|
||||
)]
|
||||
|
||||
mod context;
|
||||
mod export;
|
||||
mod func_data_registry;
|
||||
mod extern_ref;
|
||||
mod global;
|
||||
mod imports;
|
||||
mod instance;
|
||||
@@ -35,19 +36,21 @@ mod vmcontext;
|
||||
|
||||
pub mod libcalls;
|
||||
|
||||
use std::ptr::NonNull;
|
||||
|
||||
pub use crate::context::{
|
||||
ContextHandle, ContextId, ContextObjects, InternalContextHandle, MaybeInstanceOwned,
|
||||
};
|
||||
pub use crate::export::*;
|
||||
pub use crate::func_data_registry::{FuncDataRegistry, VMFuncRef};
|
||||
pub use crate::extern_ref::{VMExternObj, VMExternRef};
|
||||
pub use crate::global::*;
|
||||
pub use crate::imports::Imports;
|
||||
pub use crate::instance::{
|
||||
ImportFunctionEnv, ImportInitializerFuncPtr, InstanceAllocator, InstanceHandle,
|
||||
WeakOrStrongInstanceRef,
|
||||
};
|
||||
pub use crate::memory::{LinearMemory, Memory, MemoryError};
|
||||
pub use crate::instance::{InstanceAllocator, InstanceHandle};
|
||||
pub use crate::memory::{MemoryError, VMMemory};
|
||||
pub use crate::mmap::Mmap;
|
||||
pub use crate::probestack::PROBESTACK;
|
||||
pub use crate::sig_registry::SignatureRegistry;
|
||||
pub use crate::table::{LinearTable, Table, TableElement};
|
||||
pub use crate::table::{TableElement, VMTable};
|
||||
pub use crate::trap::*;
|
||||
pub use crate::vmcontext::{
|
||||
VMCallerCheckedAnyfunc, VMContext, VMDynamicFunctionContext, VMFunctionEnvironment,
|
||||
@@ -56,8 +59,8 @@ pub use crate::vmcontext::{
|
||||
};
|
||||
pub use wasmer_types::LibCall;
|
||||
pub use wasmer_types::MemoryStyle;
|
||||
use wasmer_types::RawValue;
|
||||
pub use wasmer_types::TableStyle;
|
||||
pub use wasmer_types::VMExternRef;
|
||||
pub use wasmer_types::{TargetSharedSignatureIndex, VMBuiltinFunctionIndex, VMOffsets};
|
||||
|
||||
#[deprecated(
|
||||
@@ -121,3 +124,25 @@ unsafe impl Send for FunctionBodyPtr {}
|
||||
/// The VMFunctionBody that this points to is opaque, so there's no data to
|
||||
/// read or write through this pointer. This is essentially a usize.
|
||||
unsafe impl Sync for FunctionBodyPtr {}
|
||||
|
||||
/// A function reference. A single word that points to metadata about a function.
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct VMFuncRef(pub NonNull<VMCallerCheckedAnyfunc>);
|
||||
|
||||
impl VMFuncRef {
|
||||
/// Converts the `VMFuncRef` into a `RawValue`.
|
||||
pub fn into_raw(self) -> RawValue {
|
||||
RawValue {
|
||||
funcref: self.0.as_ptr() as usize,
|
||||
}
|
||||
}
|
||||
|
||||
/// Extracts a `VMFuncRef` from a `RawValue`.
|
||||
///
|
||||
/// # Safety
|
||||
/// `raw.funcref` must be a valid pointer.
|
||||
pub unsafe fn from_raw(raw: RawValue) -> Option<Self> {
|
||||
NonNull::new(raw.funcref as *mut VMCallerCheckedAnyfunc).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user