Enum tinywasm_types::Instruction

source ·
#[non_exhaustive]
pub enum Instruction {
Show 207 variants BrLabel(LabelAddr), I32LocalGetConstAdd(LocalAddr, i32), I32StoreLocal { local: LocalAddr, const_i32: i32, offset: u32, mem_addr: u8, }, I64XorConstRotl(i64), LocalTeeGet(LocalAddr, LocalAddr), LocalGet2(LocalAddr, LocalAddr), LocalGet3(LocalAddr, LocalAddr, LocalAddr), LocalGetSet(LocalAddr, LocalAddr), Unreachable, Nop, Block(BlockArgs, u32), Loop(BlockArgs, u32), If(BlockArgsPacked, u32, u32), Else(u32), EndBlockFrame, Br(LabelAddr), BrIf(LabelAddr), BrTable(u32, u32), Return, Call(FuncAddr), CallIndirect(TypeAddr, TableAddr), Drop, Select(Option<ValType>), LocalGet(LocalAddr), LocalSet(LocalAddr), LocalTee(LocalAddr), GlobalGet(GlobalAddr), GlobalSet(GlobalAddr), I32Load { offset: u64, mem_addr: MemAddr, }, I64Load { offset: u64, mem_addr: MemAddr, }, F32Load { offset: u64, mem_addr: MemAddr, }, F64Load { offset: u64, mem_addr: MemAddr, }, I32Load8S { offset: u64, mem_addr: MemAddr, }, I32Load8U { offset: u64, mem_addr: MemAddr, }, I32Load16S { offset: u64, mem_addr: MemAddr, }, I32Load16U { offset: u64, mem_addr: MemAddr, }, I64Load8S { offset: u64, mem_addr: MemAddr, }, I64Load8U { offset: u64, mem_addr: MemAddr, }, I64Load16S { offset: u64, mem_addr: MemAddr, }, I64Load16U { offset: u64, mem_addr: MemAddr, }, I64Load32S { offset: u64, mem_addr: MemAddr, }, I64Load32U { offset: u64, mem_addr: MemAddr, }, I32Store { offset: u64, mem_addr: MemAddr, }, I64Store { offset: u64, mem_addr: MemAddr, }, F32Store { offset: u64, mem_addr: MemAddr, }, F64Store { offset: u64, mem_addr: MemAddr, }, I32Store8 { offset: u64, mem_addr: MemAddr, }, I32Store16 { offset: u64, mem_addr: MemAddr, }, I64Store8 { offset: u64, mem_addr: MemAddr, }, I64Store16 { offset: u64, mem_addr: MemAddr, }, I64Store32 { offset: u64, mem_addr: MemAddr, }, MemorySize(MemAddr, u8), MemoryGrow(MemAddr, u8), I32Const(i32), I64Const(i64), F32Const(f32), F64Const(f64), RefNull(ValType), RefFunc(FuncAddr), RefIsNull, I32Eqz, I32Eq, I32Ne, I32LtS, I32LtU, I32GtS, I32GtU, I32LeS, I32LeU, I32GeS, I32GeU, I64Eqz, I64Eq, I64Ne, I64LtS, I64LtU, I64GtS, I64GtU, I64LeS, I64LeU, I64GeS, I64GeU, F32Eq, F32Ne, F32Lt, F32Gt, F32Le, F32Ge, F64Eq, F64Ne, F64Lt, F64Gt, F64Le, F64Ge, I32Clz, I32Ctz, I32Popcnt, I32Add, I32Sub, I32Mul, I32DivS, I32DivU, I32RemS, I32RemU, I64Clz, I64Ctz, I64Popcnt, I64Add, I64Sub, I64Mul, I64DivS, I64DivU, I64RemS, I64RemU, I32And, I32Or, I32Xor, I32Shl, I32ShrS, I32ShrU, I32Rotl, I32Rotr, I64And, I64Or, I64Xor, I64Shl, I64ShrS, I64ShrU, I64Rotl, I64Rotr, F32Abs, F32Neg, F32Ceil, F32Floor, F32Trunc, F32Nearest, F32Sqrt, F32Add, F32Sub, F32Mul, F32Div, F32Min, F32Max, F32Copysign, F64Abs, F64Neg, F64Ceil, F64Floor, F64Trunc, F64Nearest, F64Sqrt, F64Add, F64Sub, F64Mul, F64Div, F64Min, F64Max, F64Copysign, I32WrapI64, I32TruncF32S, I32TruncF32U, I32TruncF64S, I32TruncF64U, I32Extend8S, I32Extend16S, I64Extend8S, I64Extend16S, I64Extend32S, I64ExtendI32S, I64ExtendI32U, I64TruncF32S, I64TruncF32U, I64TruncF64S, I64TruncF64U, F32ConvertI32S, F32ConvertI32U, F32ConvertI64S, F32ConvertI64U, F32DemoteF64, F64ConvertI32S, F64ConvertI32U, F64ConvertI64S, F64ConvertI64U, F64PromoteF32, I32ReinterpretF32, I64ReinterpretF64, F32ReinterpretI32, F64ReinterpretI64, I32TruncSatF32S, I32TruncSatF32U, I32TruncSatF64S, I32TruncSatF64U, I64TruncSatF32S, I64TruncSatF32U, I64TruncSatF64S, I64TruncSatF64U, TableInit(TableAddr, ElemAddr), TableGet(TableAddr), TableSet(TableAddr), TableCopy { from: TableAddr, to: TableAddr, }, TableGrow(TableAddr), TableSize(TableAddr), TableFill(TableAddr), MemoryInit(MemAddr, DataAddr), MemoryCopy(MemAddr, MemAddr), MemoryFill(MemAddr), DataDrop(DataAddr),
}
Expand description

A WebAssembly Instruction

These are our own internal bytecode instructions so they may not match the spec exactly. Wasm Bytecode can map to multiple of these instructions.

§Differences to the spec

  • br_table stores the jump labels in the following br_label instructions to keep this enum small.
  • Lables/Blocks: we store the label end offset in the instruction itself and use EndBlockFrame to mark the end of a block. This makes it easier to implement the label stack iteratively.

See https://webassembly.github.io/spec/core/binary/instructions.html

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

BrLabel(LabelAddr)

§

I32LocalGetConstAdd(LocalAddr, i32)

§

I32StoreLocal

Fields

§const_i32: i32
§offset: u32
§mem_addr: u8
§

I64XorConstRotl(i64)

§

LocalTeeGet(LocalAddr, LocalAddr)

§

LocalGet2(LocalAddr, LocalAddr)

§

LocalGet3(LocalAddr, LocalAddr, LocalAddr)

§

LocalGetSet(LocalAddr, LocalAddr)

§

Unreachable

§

Nop

§

Block(BlockArgs, u32)

§

Loop(BlockArgs, u32)

§

If(BlockArgsPacked, u32, u32)

§

Else(u32)

§

EndBlockFrame

§

Br(LabelAddr)

§

BrIf(LabelAddr)

§

BrTable(u32, u32)

§

Return

§

Call(FuncAddr)

§

CallIndirect(TypeAddr, TableAddr)

§

Drop

§

Select(Option<ValType>)

§

LocalGet(LocalAddr)

§

LocalSet(LocalAddr)

§

LocalTee(LocalAddr)

§

GlobalGet(GlobalAddr)

§

GlobalSet(GlobalAddr)

§

I32Load

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load

Fields

§offset: u64
§mem_addr: MemAddr
§

F32Load

Fields

§offset: u64
§mem_addr: MemAddr
§

F64Load

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Load8S

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Load8U

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Load16S

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Load16U

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load8S

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load8U

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load16S

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load16U

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load32S

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Load32U

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Store

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Store

Fields

§offset: u64
§mem_addr: MemAddr
§

F32Store

Fields

§offset: u64
§mem_addr: MemAddr
§

F64Store

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Store8

Fields

§offset: u64
§mem_addr: MemAddr
§

I32Store16

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Store8

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Store16

Fields

§offset: u64
§mem_addr: MemAddr
§

I64Store32

Fields

§offset: u64
§mem_addr: MemAddr
§

MemorySize(MemAddr, u8)

§

MemoryGrow(MemAddr, u8)

§

I32Const(i32)

§

I64Const(i64)

§

F32Const(f32)

§

F64Const(f64)

§

RefNull(ValType)

§

RefFunc(FuncAddr)

§

RefIsNull

§

I32Eqz

§

I32Eq

§

I32Ne

§

I32LtS

§

I32LtU

§

I32GtS

§

I32GtU

§

I32LeS

§

I32LeU

§

I32GeS

§

I32GeU

§

I64Eqz

§

I64Eq

§

I64Ne

§

I64LtS

§

I64LtU

§

I64GtS

§

I64GtU

§

I64LeS

§

I64LeU

§

I64GeS

§

I64GeU

§

F32Eq

§

F32Ne

§

F32Lt

§

F32Gt

§

F32Le

§

F32Ge

§

F64Eq

§

F64Ne

§

F64Lt

§

F64Gt

§

F64Le

§

F64Ge

§

I32Clz

§

I32Ctz

§

I32Popcnt

§

I32Add

§

I32Sub

§

I32Mul

§

I32DivS

§

I32DivU

§

I32RemS

§

I32RemU

§

I64Clz

§

I64Ctz

§

I64Popcnt

§

I64Add

§

I64Sub

§

I64Mul

§

I64DivS

§

I64DivU

§

I64RemS

§

I64RemU

§

I32And

§

I32Or

§

I32Xor

§

I32Shl

§

I32ShrS

§

I32ShrU

§

I32Rotl

§

I32Rotr

§

I64And

§

I64Or

§

I64Xor

§

I64Shl

§

I64ShrS

§

I64ShrU

§

I64Rotl

§

I64Rotr

§

F32Abs

§

F32Neg

§

F32Ceil

§

F32Floor

§

F32Trunc

§

F32Nearest

§

F32Sqrt

§

F32Add

§

F32Sub

§

F32Mul

§

F32Div

§

F32Min

§

F32Max

§

F32Copysign

§

F64Abs

§

F64Neg

§

F64Ceil

§

F64Floor

§

F64Trunc

§

F64Nearest

§

F64Sqrt

§

F64Add

§

F64Sub

§

F64Mul

§

F64Div

§

F64Min

§

F64Max

§

F64Copysign

§

I32WrapI64

§

I32TruncF32S

§

I32TruncF32U

§

I32TruncF64S

§

I32TruncF64U

§

I32Extend8S

§

I32Extend16S

§

I64Extend8S

§

I64Extend16S

§

I64Extend32S

§

I64ExtendI32S

§

I64ExtendI32U

§

I64TruncF32S

§

I64TruncF32U

§

I64TruncF64S

§

I64TruncF64U

§

F32ConvertI32S

§

F32ConvertI32U

§

F32ConvertI64S

§

F32ConvertI64U

§

F32DemoteF64

§

F64ConvertI32S

§

F64ConvertI32U

§

F64ConvertI64S

§

F64ConvertI64U

§

F64PromoteF32

§

I32ReinterpretF32

§

I64ReinterpretF64

§

F32ReinterpretI32

§

F64ReinterpretI64

§

I32TruncSatF32S

§

I32TruncSatF32U

§

I32TruncSatF64S

§

I32TruncSatF64U

§

I64TruncSatF32S

§

I64TruncSatF32U

§

I64TruncSatF64S

§

I64TruncSatF64U

§

TableInit(TableAddr, ElemAddr)

§

TableGet(TableAddr)

§

TableSet(TableAddr)

§

TableCopy

Fields

§

TableGrow(TableAddr)

§

TableSize(TableAddr)

§

TableFill(TableAddr)

§

MemoryInit(MemAddr, DataAddr)

§

MemoryCopy(MemAddr, MemAddr)

§

MemoryFill(MemAddr)

§

DataDrop(DataAddr)

Trait Implementations§

source§

impl Archive for Instruction

§

type Archived = ArchivedInstruction

The archived representation of this type. Read more
§

type Resolver = InstructionResolver

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
source§

unsafe fn resolve( &self, pos: usize, resolver: <Self as Archive>::Resolver, out: *mut <Self as Archive>::Archived )

Creates the archived version of this value at the given position and writes it to the given output. Read more
source§

impl Clone for Instruction

source§

fn clone(&self) -> Instruction

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Instruction

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<__D: Fallible + ?Sized> Deserialize<Instruction, __D> for Archived<Instruction>

source§

fn deserialize(&self, deserializer: &mut __D) -> Result<Instruction, __D::Error>

Deserializes using the given deserializer
source§

impl PartialEq for Instruction

source§

fn eq(&self, other: &Instruction) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<__S: Fallible + ?Sized> Serialize<__S> for Instruction

source§

fn serialize( &self, serializer: &mut __S ) -> Result<<Self as Archive>::Resolver, __S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> ArchiveUnsized for T
where T: Archive,

§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
§

type MetadataResolver = ()

The resolver for the metadata of this type. Read more
source§

unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata )

Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
source§

unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived, <isize as Archive>::Archived> )

Resolves a relative pointer to this value with the given from and to and writes it to the given output. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Serializer + ?Sized,

source§

fn serialize_unsized( &self, serializer: &mut S ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
source§

fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>

Serializes the metadata for the given type.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.