diff options
Diffstat (limited to 'crates/types')
| -rw-r--r-- | crates/types/src/instructions.rs | 83 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 27 |
2 files changed, 8 insertions, 102 deletions
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 797f703..c9786d3 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -799,89 +799,6 @@ pub enum Instruction { const _: () = assert!(core::mem::size_of::<Instruction>() == 8); -impl Instruction { - /// Returns the largest module-local memory index used by this instruction. - #[inline] - pub fn memory_addr(&self, data: &super::WasmFunctionData) -> Option<MemAddr> { - use Instruction::*; - match *self { - IncMemoryLocal32(arg) - | IncMemoryLocal64(arg) - | StoreLocalLocal32(arg) - | StoreLocalLocal64(arg) - | StoreLocalLocal128(arg) - | LoadLocal32(arg) - | LoadLocal64(arg) - | LoadLocal8S32(arg) - | LoadLocal8U32(arg) - | LoadLocal16S32(arg) - | LoadLocal16U32(arg) - | LoadLocalTee32(arg) - | LoadLocalSet32(arg) - | LoadLocalTee8S32(arg) - | LoadLocalTee8U32(arg) - | LoadLocalTee16S32(arg) - | LoadLocalTee16U32(arg) - | LoadLocalSet8S32(arg) - | LoadLocalSet8U32(arg) - | LoadLocalSet16S32(arg) - | LoadLocalSet16U32(arg) - | LoadLocalTee128(arg) - | LoadLocalSet128(arg) => Some(arg.memory_arg_idx.get(data).mem_addr()), - I32Load(index) - | I64Load(index) - | F32Load(index) - | F64Load(index) - | I32Load8S(index) - | I32Load8U(index) - | I32Load16S(index) - | I32Load16U(index) - | I64Load8S(index) - | I64Load8U(index) - | I64Load16S(index) - | I64Load16U(index) - | I64Load32S(index) - | I64Load32U(index) - | I32Store(index) - | I64Store(index) - | F32Store(index) - | F64Store(index) - | I32Store8(index) - | I32Store16(index) - | I64Store8(index) - | I64Store16(index) - | I64Store32(index) - | V128Load(index) - | V128Load8x8S(index) - | V128Load8x8U(index) - | V128Load16x4S(index) - | V128Load16x4U(index) - | V128Load32x2S(index) - | V128Load32x2U(index) - | V128Load8Splat(index) - | V128Load16Splat(index) - | V128Load32Splat(index) - | V128Load64Splat(index) - | V128Load32Zero(index) - | V128Load64Zero(index) - | V128Store(index) => Some(index.get(data).mem_addr()), - V128Load8Lane(arg) | V128Load16Lane(arg) | V128Load32Lane(arg) | V128Load64Lane(arg) - | V128Store8Lane(arg) | V128Store16Lane(arg) | V128Store32Lane(arg) | V128Store64Lane(arg) => { - Some(arg.memory_arg_idx.get(data).mem_addr()) - } - FMaStoreF32(arg) | FMaStoreF64(arg) => Some(arg.mem_addr()), - MemorySize(memory) | MemoryGrow(memory) | MemoryFill(memory) => Some(memory), - MemoryFillConst(index) => Some(index.get(data).memory), - MemoryInit(index) => Some(index.get(data).second), - MemoryCopy(index) => { - let value = index.get(data); - Some(value.first.max(value.second)) - } - _ => None, - } - } -} - #[cfg(test)] mod tests { use alloc::vec; diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index bd92753..d1f7453 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -133,9 +133,6 @@ pub struct ModuleInner { /// /// Corresponds to the `elem` section of the original WebAssembly module. pub elements: Box<[Element]>, - - /// How instantiation should prepare the module's local memories. - pub local_memory_allocation: LocalMemoryAllocation, } impl Module { @@ -297,20 +294,6 @@ pub enum ExportType<'a> { Tag(&'a FuncType), } -/// How instantiation should prepare local memories declared by the module. -#[derive(Clone, Copy, PartialEq, Eq, Default)] -#[cfg_attr(feature = "debug", derive(Debug))] -#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] -pub enum LocalMemoryAllocation { - /// The module's local memories are unobservable and can be skipped entirely. - #[default] - Skip, - /// The module's local memories may be observed through exports, but can be delayed until first use. - Lazy, - /// The module's local memories must be allocated during instantiation. - Eager, -} - /// A WebAssembly External Kind. /// /// See <https://webassembly.github.io/spec/core/syntax/types.html#external-types> @@ -614,6 +597,12 @@ impl MemoryType { } } + /// The declared maximum page count, or `None` when the memory is unbounded. + #[inline] + pub const fn page_count_max_declared(&self) -> Option<u64> { + self.page_count_max + } + #[inline] pub const fn page_size(&self) -> u64 { if let Some(page_size) = self.page_size { page_size } else { MEM_PAGE_SIZE } @@ -711,7 +700,7 @@ impl From<&ImportKind> for ExternalKind { #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub struct Data { pub data: Box<[u8]>, - pub range: Range<usize>, + pub range: Range<u64>, pub kind: DataKind, } @@ -729,7 +718,7 @@ pub enum DataKind { pub struct Element { pub kind: ElementKind, pub items: Box<[ElementItem]>, - pub range: Range<usize>, + pub range: Range<u64>, pub ty: RefType, } |
