From 3b0ee715f7edabed7fa4206c63b19d3012eace82 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Mon, 13 Feb 2023 17:05:46 -0800 Subject: [PATCH] Created vm module --- lib/api/src/function_env.rs | 5 +---- lib/api/src/js/vm.rs | 5 +++++ lib/api/src/lib.rs | 1 + lib/api/src/sys/mod.rs | 16 +++++++++++----- lib/api/src/vm.rs | 22 ++++++++++++++++++++++ 5 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 lib/api/src/vm.rs diff --git a/lib/api/src/function_env.rs b/lib/api/src/function_env.rs index c5f65a640..beac6c520 100644 --- a/lib/api/src/function_env.rs +++ b/lib/api/src/function_env.rs @@ -1,9 +1,6 @@ use std::{any::Any, marker::PhantomData}; -#[cfg(feature = "js")] -use crate::js::vm::VMFunctionEnvironment; -#[cfg(feature = "sys")] -use wasmer_vm::VMFunctionEnvironment; +use crate::vm::VMFunctionEnvironment; use crate::store::{AsStoreMut, AsStoreRef, StoreHandle, StoreMut, StoreObjects, StoreRef}; diff --git a/lib/api/src/js/vm.rs b/lib/api/src/js/vm.rs index 460f66474..1960c71a1 100644 --- a/lib/api/src/js/vm.rs +++ b/lib/api/src/js/vm.rs @@ -211,3 +211,8 @@ impl VMFunctionEnvironment { &mut *self.contents } } + +pub(crate) type VMExternTable = VMTable; +pub(crate) type VMExternMemory = VMMemory; +pub(crate) type VMExternGlobal = VMGlobal; +pub(crate) type VMExternFunction = VMFunction; diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index d6f9c1520..4e0207b44 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -445,6 +445,7 @@ mod ptr; mod store; mod typed_function; mod value; +pub mod vm; #[cfg(feature = "sys")] mod sys; diff --git a/lib/api/src/sys/mod.rs b/lib/api/src/sys/mod.rs index dc6bf5cdd..8a38f9f94 100644 --- a/lib/api/src/sys/mod.rs +++ b/lib/api/src/sys/mod.rs @@ -16,13 +16,19 @@ pub use wasmer_compiler::{Features, FrameInfo, LinkError, RuntimeError, Tunables // TODO: should those be moved into wasmer::vm as well? pub use wasmer_vm::{raise_user_trap, MemoryError}; -pub mod vm { +pub(crate) mod vm { //! The `vm` module re-exports wasmer-vm types. - - pub use wasmer_vm::{ - MemoryError, MemoryStyle, TableStyle, VMExtern, VMMemory, VMMemoryDefinition, - VMOwnedMemory, VMSharedMemory, VMTable, VMTableDefinition, + use wasmer_vm::InternalStoreHandle; + pub(crate) use wasmer_vm::{ + MemoryError, MemoryStyle, TableStyle, VMExtern, VMFunction, VMFunctionEnvironment, + VMGlobal, VMMemory, VMMemoryDefinition, VMOwnedMemory, VMSharedMemory, VMTable, + VMTableDefinition, }; + + pub(crate) type VMExternTable = InternalStoreHandle; + pub(crate) type VMExternMemory = InternalStoreHandle; + pub(crate) type VMExternGlobal = InternalStoreHandle; + pub(crate) type VMExternFunction = InternalStoreHandle; } #[cfg(feature = "wat")] diff --git a/lib/api/src/vm.rs b/lib/api/src/vm.rs new file mode 100644 index 000000000..40f59a50a --- /dev/null +++ b/lib/api/src/vm.rs @@ -0,0 +1,22 @@ +//! The `vm` module re-exports wasmer-vm types. + +#[cfg(feature = "js")] +pub(crate) use crate::js::vm::{ + VMExtern, VMExternFunction, VMExternGlobal, VMExternMemory, VMExternTable, VMFunction, + VMFunctionEnvironment, VMGlobal, VMMemory, VMTable, +}; + +#[cfg(feature = "sys")] +pub(crate) use crate::sys::vm::{ + VMExtern, VMExternFunction, VMExternGlobal, VMExternMemory, VMExternTable, + VMFunctionEnvironment, +}; + +// Needed for tunables customization +#[cfg(feature = "sys")] +pub use wasmer_vm::{ + VMFunction, VMGlobal, VMMemory, VMMemoryDefinition, VMTable, VMTableDefinition, +}; + +// Deprecated exports +pub use wasmer_types::{MemoryError, MemoryStyle, TableStyle};