diff --git a/lib/compiler/src/translator/environ.rs b/lib/compiler/src/translator/environ.rs index ed5fc406a..240314c44 100644 --- a/lib/compiler/src/translator/environ.rs +++ b/lib/compiler/src/translator/environ.rs @@ -14,9 +14,10 @@ use wasm_common::FunctionType; use wasm_common::{ CustomSectionIndex, DataIndex, DataInitializer, DataInitializerLocation, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, GlobalInit, GlobalType, ImportIndex, - LocalFunctionIndex, MemoryIndex, MemoryType, SignatureIndex, TableIndex, TableType, + LocalFunctionIndex, MemoryIndex, MemoryType, SignatureIndex, TableIndex, TableInitializer, + TableType, }; -use wasmer_vm::{ModuleInfo, TableInitializer}; +use wasmer_vm::ModuleInfo; /// Contains function data: bytecode and its offset in the module. #[derive(Hash)] diff --git a/lib/deprecated/runtime-core/src/module.rs b/lib/deprecated/runtime-core/src/module.rs index 67c8bd272..9328b91ea 100644 --- a/lib/deprecated/runtime-core/src/module.rs +++ b/lib/deprecated/runtime-core/src/module.rs @@ -16,12 +16,11 @@ use std::{ ptr, }; -pub use new::wasm_common::{DataInitializer, ExportIndex}; +pub use new::wasm_common::{DataInitializer, ExportIndex, TableInitializer}; pub use new::wasmer_vm::{ // MemoryStyle as MemoryType, ModuleInfo, - TableInitializer, }; /// A compiled WebAssembly module. diff --git a/lib/vm/src/instance.rs b/lib/vm/src/instance.rs index d3aafba67..5843fff7b 100644 --- a/lib/vm/src/instance.rs +++ b/lib/vm/src/instance.rs @@ -16,7 +16,7 @@ use crate::vmcontext::{ VMSharedSignatureIndex, VMTableDefinition, VMTableImport, }; use crate::{ExportFunction, ExportGlobal, ExportMemory, ExportTable}; -use crate::{FunctionBodyPtr, ModuleInfo, TableInitializer, VMOffsets}; +use crate::{FunctionBodyPtr, ModuleInfo, VMOffsets}; use memoffset::offset_of; use more_asserts::assert_lt; use std::alloc::{self, Layout}; @@ -31,7 +31,7 @@ use wasm_common::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, P use wasm_common::{ DataIndex, DataInitializer, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, GlobalInit, LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, Pages, - SignatureIndex, TableIndex, + SignatureIndex, TableIndex, TableInitializer, }; cfg_if::cfg_if! { diff --git a/lib/vm/src/lib.rs b/lib/vm/src/lib.rs index 5dff3b8bb..d03050db7 100644 --- a/lib/vm/src/lib.rs +++ b/lib/vm/src/lib.rs @@ -45,7 +45,7 @@ pub use crate::mmap::Mmap; pub use crate::module::{ExportsIterator, ImportsIterator, ModuleInfo}; pub use crate::probestack::PROBESTACK; pub use crate::sig_registry::SignatureRegistry; -pub use crate::table::{LinearTable, Table, TableInitializer, TableStyle}; +pub use crate::table::{LinearTable, Table, TableStyle}; pub use crate::trap::*; pub use crate::vmcontext::{ VMBuiltinFunctionIndex, VMCallerCheckedAnyfunc, VMContext, VMDynamicFunctionContext, diff --git a/lib/vm/src/module.rs b/lib/vm/src/module.rs index a011c44be..3e46823a2 100644 --- a/lib/vm/src/module.rs +++ b/lib/vm/src/module.rs @@ -4,7 +4,6 @@ //! Data structure for representing WebAssembly modules //! in a [`Module`]. -use crate::table::TableInitializer; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -17,7 +16,7 @@ use wasm_common::{ CustomSectionIndex, DataIndex, ElemIndex, ExportIndex, ExportType, ExternType, FunctionIndex, FunctionType, GlobalIndex, GlobalInit, GlobalType, ImportIndex, ImportType, LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, MemoryType, SignatureIndex, - TableIndex, TableType, + TableIndex, TableInitializer, TableType, }; #[derive(Debug)] diff --git a/lib/vm/src/table.rs b/lib/vm/src/table.rs index 64b4ed017..9e06497be 100644 --- a/lib/vm/src/table.rs +++ b/lib/vm/src/table.rs @@ -14,20 +14,7 @@ use std::convert::TryFrom; use std::fmt; use std::ptr::NonNull; use std::sync::Mutex; -use wasm_common::{FunctionIndex, GlobalIndex, TableIndex, TableType, Type as ValType}; - -/// A WebAssembly table initializer. -#[derive(Clone, Debug, Hash, Serialize, Deserialize)] -pub struct TableInitializer { - /// The index of a table to initialize. - pub table_index: TableIndex, - /// Optionally, a global variable giving a base index. - pub base: Option, - /// The offset to add to the base. - pub offset: usize, - /// The values to write into the table elements. - pub elements: Box<[FunctionIndex]>, -} +use wasm_common::{TableType, Type as ValType}; /// Implementation styles for WebAssembly tables. #[derive(Debug, Clone, Hash, Serialize, Deserialize)] diff --git a/lib/wasm-common/src/data_initializer.rs b/lib/wasm-common/src/initializers.rs similarity index 75% rename from lib/wasm-common/src/data_initializer.rs rename to lib/wasm-common/src/initializers.rs index dad69a545..0d47554c5 100644 --- a/lib/wasm-common/src/data_initializer.rs +++ b/lib/wasm-common/src/initializers.rs @@ -1,9 +1,22 @@ -use crate::indexes::{GlobalIndex, MemoryIndex}; +use crate::indexes::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex}; use crate::lib::std::boxed::Box; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; +/// A WebAssembly table initializer. +#[derive(Clone, Debug, Hash, Serialize, Deserialize)] +pub struct TableInitializer { + /// The index of a table to initialize. + pub table_index: TableIndex, + /// Optionally, a global variable giving a base index. + pub base: Option, + /// The offset to add to the base. + pub offset: usize, + /// The values to write into the table elements. + pub elements: Box<[FunctionIndex]>, +} + /// A memory index and offset within that memory where a data initialization /// should be performed. #[derive(Clone, Debug)] diff --git a/lib/wasm-common/src/lib.rs b/lib/wasm-common/src/lib.rs index 2f7aa534b..3004ea503 100644 --- a/lib/wasm-common/src/lib.rs +++ b/lib/wasm-common/src/lib.rs @@ -50,9 +50,9 @@ mod lib { } } -mod data_initializer; mod features; mod indexes; +mod initializers; mod memory_view; mod native; mod r#ref; @@ -65,13 +65,15 @@ pub mod entity { pub use cranelift_entity::*; } -pub use crate::data_initializer::{DataInitializer, DataInitializerLocation, OwnedDataInitializer}; pub use crate::features::Features; pub use crate::indexes::{ CustomSectionIndex, DataIndex, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, ImportIndex, LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, SignatureIndex, TableIndex, }; +pub use crate::initializers::{ + DataInitializer, DataInitializerLocation, OwnedDataInitializer, TableInitializer, +}; pub use crate::memory_view::{Atomically, MemoryView}; pub use crate::native::{NativeWasmType, ValueType}; pub use crate::r#ref::{ExternRef, HostInfo, HostRef};