wazeroir

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package wazeroir is a pkg to compile down the standard Wasm binary to wazero's specific IR (wazeroir). The wazeroir is inspired by microwasm format (a.k.a. LightbeamIR), previously used in the lightbeam compiler in Wasmtime, though it is not specified and only exists in the previous codebase of wasmtime e.g. https://github.com/bytecodealliance/wasmtime/blob/v0.29.0/crates/lightbeam/src/microwasm.rs

See RATIONALE.md for detail.

Index

Constants

View Source
const EntrypointLabel = ".entrypoint"

Variables

View Source
var NopInclusiveRange = InclusiveRange{Start: -1, End: -1}

NopInclusiveRange is InclusiveRange which corresponds to no-operation.

Functions

func Format

func Format(ops []UnionOperation) string

Types

type CompilationResult

type CompilationResult struct {
	// Operations holds wazeroir operations compiled from Wasm instructions in a Wasm function.
	Operations []UnionOperation

	// IROperationSourceOffsetsInWasmBinary is index-correlated with Operation and maps each operation to the corresponding source instruction's
	// offset in the original WebAssembly binary.
	// Non nil only when the given Wasm module has the DWARF section.
	IROperationSourceOffsetsInWasmBinary []uint64

	// LabelCallers maps Label to the number of callers to that label.
	// Here "callers" means that the call-sites which jumps to the label with br, br_if or br_table
	// instructions.
	//
	// Note: zero possible and allowed in wasm. e.g.
	//
	//	(block
	//	  (br 0)
	//	  (block i32.const 1111)
	//	)
	//
	// This example the label corresponding to `(block i32.const 1111)` is never be reached at runtime because `br 0` exits the function before we reach there
	LabelCallers map[Label]uint32
	// UsesMemory is true if this function might use memory.
	UsesMemory bool

	// Globals holds all the declarations of globals in the module from which this function is compiled.
	Globals []wasm.GlobalType
	// Functions holds all the declarations of function in the module from which this function is compiled, including itself.
	Functions []wasm.Index
	// Types holds all the types in the module from which this function is compiled.
	Types []wasm.FunctionType
	// HasMemory is true if the module from which this function is compiled has memory declaration.
	HasMemory bool
	// HasTable is true if the module from which this function is compiled has table declaration.
	HasTable bool
	// HasDataInstances is true if the module has data instances which might be used by memory.init or data.drop instructions.
	HasDataInstances bool
	// HasDataInstances is true if the module has element instances which might be used by table.init or elem.drop instructions.
	HasElementInstances bool
}

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

Compiler is in charge of lowering raw Wasm function body to get CompilationResult. This is created per *wasm.Module and reused for all functions in it to reduce memory allocations.

func NewCompiler

func NewCompiler(enabledFeatures api.CoreFeatures, callFrameStackSizeInUint64 int, module *wasm.Module, ensureTermination bool) (*Compiler, error)

NewCompiler returns the new *Compiler for the given parameters. Use Compiler.Next function to get compilation result per function.

func (*Compiler) Next

func (c *Compiler) Next() (*CompilationResult, error)

Next returns the next CompilationResult for this Compiler.

type Float

type Float byte

Float represents the scalar double or single precision floating points.

const (
	Float32 Float = iota
	Float64
)

func (Float) String

func (s Float) String() (ret string)

String implements fmt.Stringer.

type InclusiveRange

type InclusiveRange struct {
	Start, End int32
}

InclusiveRange is the range which spans across the value stack starting from the top to the bottom, and both boundary are included in the range.

func InclusiveRangeFromU64

func InclusiveRangeFromU64(v uint64) InclusiveRange

InclusiveRangeFromU64 retrieves InclusiveRange from the given uint64 which is stored in UnionOperation.

func (InclusiveRange) AsU64

func (i InclusiveRange) AsU64() uint64

AsU64 is be used to convert InclusiveRange to uint64 so that it can be stored in UnionOperation.

type Label

type Label uint64

Label is the unique identifier for each block in a single function in wazeroir where "block" consists of multiple operations, and must End with branching operations (e.g. OperationKindBr or OperationKindBrIf).

func NewLabel

func NewLabel(kind LabelKind, frameID uint32) Label

NewLabel is a constructor for a Label.

func (Label) FrameID

func (l Label) FrameID() int

FrameID returns the frame id encoded in this Label.

func (Label) IsReturnTarget

func (l Label) IsReturnTarget() bool

func (Label) Kind

func (l Label) Kind() LabelKind

Kind returns the LabelKind encoded in this Label.

func (Label) String

func (l Label) String() (ret string)

String implements fmt.Stringer.

type LabelKind

type LabelKind = byte

LabelKind is the Kind of the label.

const (
	// LabelKindHeader is the header for various blocks. For example, the "then" block of
	// wasm.OpcodeIfName in Wasm has the label of this Kind.
	LabelKindHeader LabelKind = iota
	// LabelKindElse is the Kind of label for "else" block of wasm.OpcodeIfName in Wasm.
	LabelKindElse
	// LabelKindContinuation is the Kind of label which is the continuation of blocks.
	// For example, for wasm text like
	// (func
	//   ....
	//   (if (local.get 0) (then (nop)) (else (nop)))
	//   return
	// )
	// we have the continuation block (of if-block) corresponding to "return" opcode.
	LabelKindContinuation
	LabelKindReturn
	LabelKindNum
)

type MemoryArg

type MemoryArg struct {
	// Alignment the expected alignment (expressed as the exponent of a power of 2). Default to the natural alignment.
	//
	// "Natural alignment" is defined here as the smallest power of two that can hold the size of the value type. Ex
	// wasm.ValueTypeI64 is encoded in 8 little-endian bytes. 2^3 = 8, so the natural alignment is three.
	Alignment uint32

	// Offset is the address offset added to the instruction's dynamic address operand, yielding a 33-bit effective
	// address that is the zero-based index at which the memory is accessed. Default to zero.
	Offset uint32
}

MemoryArg is the "memarg" to all memory instructions.

See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#memory-instructions%E2%91%A0

type OperationKind

type OperationKind uint16

OperationKind is the Kind of each implementation of Operation interface.

const (
	// OperationKindUnreachable is the Kind for NewOperationUnreachable.
	OperationKindUnreachable OperationKind = iota
	// OperationKindLabel is the Kind for NewOperationLabel.
	OperationKindLabel
	// OperationKindBr is the Kind for NewOperationBr.
	OperationKindBr
	// OperationKindBrIf is the Kind for NewOperationBrIf.
	OperationKindBrIf
	// OperationKindBrTable is the Kind for NewOperationBrTable.
	OperationKindBrTable
	// OperationKindCall is the Kind for NewOperationCall.
	OperationKindCall
	// OperationKindCallIndirect is the Kind for NewOperationCallIndirect.
	OperationKindCallIndirect
	// OperationKindDrop is the Kind for NewOperationDrop.
	OperationKindDrop
	// OperationKindSelect is the Kind for NewOperationSelect.
	OperationKindSelect
	// OperationKindPick is the Kind for NewOperationPick.
	OperationKindPick
	// OperationKindSet is the Kind for NewOperationSet.
	OperationKindSet
	// OperationKindGlobalGet is the Kind for NewOperationGlobalGet.
	OperationKindGlobalGet
	// OperationKindGlobalSet is the Kind for NewOperationGlobalSet.
	OperationKindGlobalSet
	// OperationKindLoad is the Kind for NewOperationLoad.
	OperationKindLoad
	// OperationKindLoad8 is the Kind for NewOperationLoad8.
	OperationKindLoad8
	// OperationKindLoad16 is the Kind for NewOperationLoad16.
	OperationKindLoad16
	// OperationKindLoad32 is the Kind for NewOperationLoad32.
	OperationKindLoad32
	// OperationKindStore is the Kind for NewOperationStore.
	OperationKindStore
	// OperationKindStore8 is the Kind for NewOperationStore8.
	OperationKindStore8
	// OperationKindStore16 is the Kind for NewOperationStore16.
	OperationKindStore16
	// OperationKindStore32 is the Kind for NewOperationStore32.
	OperationKindStore32
	// OperationKindMemorySize is the Kind for NewOperationMemorySize.
	OperationKindMemorySize
	// OperationKindMemoryGrow is the Kind for NewOperationMemoryGrow.
	OperationKindMemoryGrow
	// OperationKindConstI32 is the Kind for NewOperationConstI32.
	OperationKindConstI32
	// OperationKindConstI64 is the Kind for NewOperationConstI64.
	OperationKindConstI64
	// OperationKindConstF32 is the Kind for NewOperationConstF32.
	OperationKindConstF32
	// OperationKindConstF64 is the Kind for NewOperationConstF64.
	OperationKindConstF64
	// OperationKindEq is the Kind for NewOperationEq.
	OperationKindEq
	// OperationKindNe is the Kind for NewOperationNe.
	OperationKindNe
	// OperationKindEqz is the Kind for NewOperationEqz.
	OperationKindEqz
	// OperationKindLt is the Kind for NewOperationLt.
	OperationKindLt
	// OperationKindGt is the Kind for NewOperationGt.
	OperationKindGt
	// OperationKindLe is the Kind for NewOperationLe.
	OperationKindLe
	// OperationKindGe is the Kind for NewOperationGe.
	OperationKindGe
	// OperationKindAdd is the Kind for NewOperationAdd.
	OperationKindAdd
	// OperationKindSub is the Kind for NewOperationSub.
	OperationKindSub
	// OperationKindMul is the Kind for NewOperationMul.
	OperationKindMul
	// OperationKindClz is the Kind for NewOperationClz.
	OperationKindClz
	// OperationKindCtz is the Kind for NewOperationCtz.
	OperationKindCtz
	// OperationKindPopcnt is the Kind for NewOperationPopcnt.
	OperationKindPopcnt
	// OperationKindDiv is the Kind for NewOperationDiv.
	OperationKindDiv
	// OperationKindRem is the Kind for NewOperationRem.
	OperationKindRem
	// OperationKindAnd is the Kind for NewOperationAnd.
	OperationKindAnd
	// OperationKindOr is the Kind for NewOperationOr.
	OperationKindOr
	// OperationKindXor is the Kind for NewOperationXor.
	OperationKindXor
	// OperationKindShl is the Kind for NewOperationShl.
	OperationKindShl
	// OperationKindShr is the Kind for NewOperationShr.
	OperationKindShr
	// OperationKindRotl is the Kind for NewOperationRotl.
	OperationKindRotl
	// OperationKindRotr is the Kind for NewOperationRotr.
	OperationKindRotr
	// OperationKindAbs is the Kind for NewOperationAbs.
	OperationKindAbs
	// OperationKindNeg is the Kind for NewOperationNeg.
	OperationKindNeg
	// OperationKindCeil is the Kind for NewOperationCeil.
	OperationKindCeil
	// OperationKindFloor is the Kind for NewOperationFloor.
	OperationKindFloor
	// OperationKindTrunc is the Kind for NewOperationTrunc.
	OperationKindTrunc
	// OperationKindNearest is the Kind for NewOperationNearest.
	OperationKindNearest
	// OperationKindSqrt is the Kind for NewOperationSqrt.
	OperationKindSqrt
	// OperationKindMin is the Kind for NewOperationMin.
	OperationKindMin
	// OperationKindMax is the Kind for NewOperationMax.
	OperationKindMax
	// OperationKindCopysign is the Kind for NewOperationCopysign.
	OperationKindCopysign
	// OperationKindI32WrapFromI64 is the Kind for NewOperationI32WrapFromI64.
	OperationKindI32WrapFromI64
	// OperationKindITruncFromF is the Kind for NewOperationITruncFromF.
	OperationKindITruncFromF
	// OperationKindFConvertFromI is the Kind for NewOperationFConvertFromI.
	OperationKindFConvertFromI
	// OperationKindF32DemoteFromF64 is the Kind for NewOperationF32DemoteFromF64.
	OperationKindF32DemoteFromF64
	// OperationKindF64PromoteFromF32 is the Kind for NewOperationF64PromoteFromF32.
	OperationKindF64PromoteFromF32
	// OperationKindI32ReinterpretFromF32 is the Kind for NewOperationI32ReinterpretFromF32.
	OperationKindI32ReinterpretFromF32
	// OperationKindI64ReinterpretFromF64 is the Kind for NewOperationI64ReinterpretFromF64.
	OperationKindI64ReinterpretFromF64
	// OperationKindF32ReinterpretFromI32 is the Kind for NewOperationF32ReinterpretFromI32.
	OperationKindF32ReinterpretFromI32
	// OperationKindF64ReinterpretFromI64 is the Kind for NewOperationF64ReinterpretFromI64.
	OperationKindF64ReinterpretFromI64
	// OperationKindExtend is the Kind for NewOperationExtend.
	OperationKindExtend
	// OperationKindSignExtend32From8 is the Kind for NewOperationSignExtend32From8.
	OperationKindSignExtend32From8
	// OperationKindSignExtend32From16 is the Kind for NewOperationSignExtend32From16.
	OperationKindSignExtend32From16
	// OperationKindSignExtend64From8 is the Kind for NewOperationSignExtend64From8.
	OperationKindSignExtend64From8
	// OperationKindSignExtend64From16 is the Kind for NewOperationSignExtend64From16.
	OperationKindSignExtend64From16
	// OperationKindSignExtend64From32 is the Kind for NewOperationSignExtend64From32.
	OperationKindSignExtend64From32
	// OperationKindMemoryInit is the Kind for NewOperationMemoryInit.
	OperationKindMemoryInit
	// OperationKindDataDrop is the Kind for NewOperationDataDrop.
	OperationKindDataDrop
	// OperationKindMemoryCopy is the Kind for NewOperationMemoryCopy.
	OperationKindMemoryCopy
	// OperationKindMemoryFill is the Kind for NewOperationMemoryFill.
	OperationKindMemoryFill
	// OperationKindTableInit is the Kind for NewOperationTableInit.
	OperationKindTableInit
	// OperationKindElemDrop is the Kind for NewOperationElemDrop.
	OperationKindElemDrop
	// OperationKindTableCopy is the Kind for NewOperationTableCopy.
	OperationKindTableCopy
	// OperationKindRefFunc is the Kind for NewOperationRefFunc.
	OperationKindRefFunc
	// OperationKindTableGet is the Kind for NewOperationTableGet.
	OperationKindTableGet
	// OperationKindTableSet is the Kind for NewOperationTableSet.
	OperationKindTableSet
	// OperationKindTableSize is the Kind for NewOperationTableSize.
	OperationKindTableSize
	// OperationKindTableGrow is the Kind for NewOperationTableGrow.
	OperationKindTableGrow
	// OperationKindTableFill is the Kind for NewOperationTableFill.
	OperationKindTableFill

	// OperationKindV128Const is the Kind for NewOperationV128Const.
	OperationKindV128Const
	// OperationKindV128Add is the Kind for NewOperationV128Add.
	OperationKindV128Add
	// OperationKindV128Sub is the Kind for NewOperationV128Sub.
	OperationKindV128Sub
	// OperationKindV128Load is the Kind for NewOperationV128Load.
	OperationKindV128Load
	// OperationKindV128LoadLane is the Kind for NewOperationV128LoadLane.
	OperationKindV128LoadLane
	// OperationKindV128Store is the Kind for NewOperationV128Store.
	OperationKindV128Store
	// OperationKindV128StoreLane is the Kind for NewOperationV128StoreLane.
	OperationKindV128StoreLane
	// OperationKindV128ExtractLane is the Kind for NewOperationV128ExtractLane.
	OperationKindV128ExtractLane
	// OperationKindV128ReplaceLane is the Kind for NewOperationV128ReplaceLane.
	OperationKindV128ReplaceLane
	// OperationKindV128Splat is the Kind for NewOperationV128Splat.
	OperationKindV128Splat
	// OperationKindV128Shuffle is the Kind for NewOperationV128Shuffle.
	OperationKindV128Shuffle
	// OperationKindV128Swizzle is the Kind for NewOperationV128Swizzle.
	OperationKindV128Swizzle
	// OperationKindV128AnyTrue is the Kind for NewOperationV128AnyTrue.
	OperationKindV128AnyTrue
	// OperationKindV128AllTrue is the Kind for NewOperationV128AllTrue.
	OperationKindV128AllTrue
	// OperationKindV128BitMask is the Kind for NewOperationV128BitMask.
	OperationKindV128BitMask
	// OperationKindV128And is the Kind for NewOperationV128And.
	OperationKindV128And
	// OperationKindV128Not is the Kind for NewOperationV128Not.
	OperationKindV128Not
	// OperationKindV128Or is the Kind for NewOperationV128Or.
	OperationKindV128Or
	// OperationKindV128Xor is the Kind for NewOperationV128Xor.
	OperationKindV128Xor
	// OperationKindV128Bitselect is the Kind for NewOperationV128Bitselect.
	OperationKindV128Bitselect
	// OperationKindV128AndNot is the Kind for NewOperationV128AndNot.
	OperationKindV128AndNot
	// OperationKindV128Shl is the Kind for NewOperationV128Shl.
	OperationKindV128Shl
	// OperationKindV128Shr is the Kind for NewOperationV128Shr.
	OperationKindV128Shr
	// OperationKindV128Cmp is the Kind for NewOperationV128Cmp.
	OperationKindV128Cmp
	// OperationKindV128AddSat is the Kind for NewOperationV128AddSat.
	OperationKindV128AddSat
	// OperationKindV128SubSat is the Kind for NewOperationV128SubSat.
	OperationKindV128SubSat
	// OperationKindV128Mul is the Kind for NewOperationV128Mul.
	OperationKindV128Mul
	// OperationKindV128Div is the Kind for NewOperationV128Div.
	OperationKindV128Div
	// OperationKindV128Neg is the Kind for NewOperationV128Neg.
	OperationKindV128Neg
	// OperationKindV128Sqrt is the Kind for NewOperationV128Sqrt.
	OperationKindV128Sqrt
	// OperationKindV128Abs is the Kind for NewOperationV128Abs.
	OperationKindV128Abs
	// OperationKindV128Popcnt is the Kind for NewOperationV128Popcnt.
	OperationKindV128Popcnt
	// OperationKindV128Min is the Kind for NewOperationV128Min.
	OperationKindV128Min
	// OperationKindV128Max is the Kind for NewOperationV128Max.
	OperationKindV128Max
	// OperationKindV128AvgrU is the Kind for NewOperationV128AvgrU.
	OperationKindV128AvgrU
	// OperationKindV128Pmin is the Kind for NewOperationV128Pmin.
	OperationKindV128Pmin
	// OperationKindV128Pmax is the Kind for NewOperationV128Pmax.
	OperationKindV128Pmax
	// OperationKindV128Ceil is the Kind for NewOperationV128Ceil.
	OperationKindV128Ceil
	// OperationKindV128Floor is the Kind for NewOperationV128Floor.
	OperationKindV128Floor
	// OperationKindV128Trunc is the Kind for NewOperationV128Trunc.
	OperationKindV128Trunc
	// OperationKindV128Nearest is the Kind for NewOperationV128Nearest.
	OperationKindV128Nearest
	// OperationKindV128Extend is the Kind for NewOperationV128Extend.
	OperationKindV128Extend
	// OperationKindV128ExtMul is the Kind for NewOperationV128ExtMul.
	OperationKindV128ExtMul
	// OperationKindV128Q15mulrSatS is the Kind for NewOperationV128Q15mulrSatS.
	OperationKindV128Q15mulrSatS
	// OperationKindV128ExtAddPairwise is the Kind for NewOperationV128ExtAddPairwise.
	OperationKindV128ExtAddPairwise
	// OperationKindV128FloatPromote is the Kind for NewOperationV128FloatPromote.
	OperationKindV128FloatPromote
	// OperationKindV128FloatDemote is the Kind for NewOperationV128FloatDemote.
	OperationKindV128FloatDemote
	// OperationKindV128FConvertFromI is the Kind for NewOperationV128FConvertFromI.
	OperationKindV128FConvertFromI
	// OperationKindV128Dot is the Kind for NewOperationV128Dot.
	OperationKindV128Dot
	// OperationKindV128Narrow is the Kind for NewOperationV128Narrow.
	OperationKindV128Narrow
	// OperationKindV128ITruncSatFromF is the Kind for NewOperationV128ITruncSatFromF.
	OperationKindV128ITruncSatFromF

	// OperationKindBuiltinFunctionCheckExitCode is the Kind for NewOperationBuiltinFunctionCheckExitCode.
	OperationKindBuiltinFunctionCheckExitCode
)

func (OperationKind) String

func (o OperationKind) String() (ret string)

String implements fmt.Stringer.

type Shape

type Shape = byte

Shape corresponds to a shape of v128 values. https://webassembly.github.io/spec/core/syntax/instructions.html#syntax-shape

const (
	ShapeI8x16 Shape = iota
	ShapeI16x8
	ShapeI32x4
	ShapeI64x2
	ShapeF32x4
	ShapeF64x2
)

type SignedInt

type SignedInt byte

SignedInt represents signed or unsigned integers.

const (
	SignedInt32 SignedInt = iota
	SignedInt64
	SignedUint32
	SignedUint64
)

func (SignedInt) String

func (s SignedInt) String() (ret string)

String implements fmt.Stringer.

type SignedType

type SignedType byte

SignedType is the union of SignedInt and Float types.

const (
	SignedTypeInt32 SignedType = iota
	SignedTypeUint32
	SignedTypeInt64
	SignedTypeUint64
	SignedTypeFloat32
	SignedTypeFloat64
)

func (SignedType) String

func (s SignedType) String() (ret string)

String implements fmt.Stringer.

type UnionOperation

type UnionOperation struct {
	// Kind determines how to interpret the other fields in this struct.
	Kind   OperationKind
	B1, B2 byte
	B3     bool
	U1, U2 uint64
	U3     uint64
	Us     []uint64
}

UnionOperation implements Operation and is the compilation (engine.lowerIR) result of a wazeroir.Operation.

Not all operations result in a UnionOperation, e.g. wazeroir.OperationI32ReinterpretFromF32, and some operations are more complex than others, e.g. wazeroir.NewOperationBrTable.

Note: This is a form of union type as it can store fields needed for any operation. Hence, most fields are opaque and only relevant when in context of its kind.

func NewOperationAbs

func NewOperationAbs(b Float) UnionOperation

NewOperationAbs is a constructor for UnionOperation with OperationKindAbs.

This corresponds to wasm.OpcodeF32Abs wasm.OpcodeF64Abs

func NewOperationAdd

func NewOperationAdd(b UnsignedType) UnionOperation

NewOperationAdd is a constructor for UnionOperation with OperationKindAdd.

This corresponds to wasm.OpcodeI32AddName wasm.OpcodeI64AddName wasm.OpcodeF32AddName wasm.OpcodeF64AddName.

func NewOperationAnd

func NewOperationAnd(b UnsignedInt) UnionOperation

NewOperationAnd is a constructor for UnionOperation with OperationKindAnd.

This corresponds to wasm.OpcodeI32AndName wasm.OpcodeI64AndName

The engines are expected to perform "And" operation on top two values on the stack, and pushes the result.

func NewOperationBr

func NewOperationBr(target Label) UnionOperation

NewOperationBr is a constructor for UnionOperation with OperationKindBr.

The engines are expected to branch into U1 label.

func NewOperationBrIf

func NewOperationBrIf(thenTarget, elseTarget Label, thenDrop InclusiveRange) UnionOperation

NewOperationBrIf is a constructor for UnionOperation with OperationKindBrIf.

The engines are expected to pop a value and branch into U1 label if the value equals 1. Otherwise, the code branches into U2 label.

func NewOperationBrTable

func NewOperationBrTable(targetLabelsAndRanges []uint64) UnionOperation

NewOperationBrTable is a constructor for UnionOperation with OperationKindBrTable.

This corresponds to wasm.OpcodeBrTableName except that the label here means the wazeroir level, not the ones of Wasm.

The engines are expected to do the br_table operation based on the default (Us[len(Us)-1], Us[len(Us)-2]) and targets (Us[:len(Us)-1], Rs[:len(Us)-1]). More precisely, this pops a value from the stack (called "index") and decides which branch we go into next based on the value.

For example, assume we have operations like {default: L_DEFAULT, targets: [L0, L1, L2]}. If "index" >= len(defaults), then branch into the L_DEFAULT label. Otherwise, we enter label of targets[index].

func NewOperationBuiltinFunctionCheckExitCode

func NewOperationBuiltinFunctionCheckExitCode() UnionOperation

NewOperationBuiltinFunctionCheckExitCode is a constructor for UnionOperation with Kind OperationKindBuiltinFunctionCheckExitCode.

OperationBuiltinFunctionCheckExitCode corresponds to the instruction to check the api.Module is already closed due to context.DeadlineExceeded, context.Canceled, or the explicit call of CloseWithExitCode on api.Module.

func NewOperationCall

func NewOperationCall(functionIndex uint32) UnionOperation

NewOperationCall is a constructor for UnionOperation with OperationKindCall.

This corresponds to wasm.OpcodeCallName, and engines are expected to enter into a function whose index equals OperationCall.FunctionIndex.

func NewOperationCallIndirect

func NewOperationCallIndirect(typeIndex, tableIndex uint32) UnionOperation

NewOperationCallIndirect implements Operation.

This corresponds to wasm.OpcodeCallIndirectName, and engines are expected to consume the one value from the top of stack (called "offset"), and make a function call against the function whose function address equals Tables[OperationCallIndirect.TableIndex][offset].

Note: This is called indirect function call in the sense that the target function is indirectly determined by the current state (top value) of the stack. Therefore, two checks are performed at runtime before entering the target function: 1) whether "offset" exceeds the length of table Tables[OperationCallIndirect.TableIndex]. 2) whether the type of the function table[offset] matches the function type specified by OperationCallIndirect.TypeIndex.

func NewOperationCeil

func NewOperationCeil(b Float) UnionOperation

NewOperationCeil is a constructor for UnionOperation with OperationKindCeil.

This corresponds to wasm.OpcodeF32CeilName wasm.OpcodeF64CeilName

func NewOperationClz

func NewOperationClz(b UnsignedInt) UnionOperation

NewOperationClz is a constructor for UnionOperation with OperationKindClz.

This corresponds to wasm.OpcodeI32ClzName wasm.OpcodeI64ClzName.

The engines are expected to count up the leading zeros in the current top of the stack, and push the count result. For example, stack of [..., 0x00_ff_ff_ff] results in [..., 8]. See wasm.OpcodeI32Clz wasm.OpcodeI64Clz

func NewOperationConstF32

func NewOperationConstF32(value float32) UnionOperation

NewOperationConstF32 is a constructor for UnionOperation with OperationConstF32.

This corresponds to wasm.OpcodeF32Const.

func NewOperationConstF64

func NewOperationConstF64(value float64) UnionOperation

NewOperationConstF64 is a constructor for UnionOperation with OperationConstF64.

This corresponds to wasm.OpcodeF64Const.

func NewOperationConstI32

func NewOperationConstI32(value uint32) UnionOperation

NewOperationConstI32 is a constructor for UnionOperation with OperationConstI32.

This corresponds to wasm.OpcodeI32Const.

func NewOperationConstI64

func NewOperationConstI64(value uint64) UnionOperation

NewOperationConstI64 is a constructor for UnionOperation with OperationConstI64.

This corresponds to wasm.OpcodeI64Const.

func NewOperationCopysign

func NewOperationCopysign(b Float) UnionOperation

NewOperationCopysign is a constructor for UnionOperation with OperationKindCopysign.

This corresponds to wasm.OpcodeF32CopysignName wasm.OpcodeF64CopysignName

The engines are expected to pop two float values from the stack, and copy the signbit of the first-popped value to the last one. For example, stack [..., 1.213, -5.0] results in [..., -1.213].

func NewOperationCtz

func NewOperationCtz(b UnsignedInt) UnionOperation

NewOperationCtz is a constructor for UnionOperation with OperationKindCtz.

This corresponds to wasm.OpcodeI32CtzName wasm.OpcodeI64CtzName.

The engines are expected to count up the trailing zeros in the current top of the stack, and push the count result. For example, stack of [..., 0xff_ff_ff_00] results in [..., 8].

func NewOperationDataDrop

func NewOperationDataDrop(dataIndex uint32) UnionOperation

NewOperationDataDrop implements Operation.

This corresponds to wasm.OpcodeDataDropName.

dataIndex is the index of the data instance in ModuleInstance.DataInstances which this operation drops.

func NewOperationDiv

func NewOperationDiv(b SignedType) UnionOperation

NewOperationDiv is a constructor for UnionOperation with OperationKindDiv.

This corresponds to wasm.OpcodeI32DivS wasm.OpcodeI32DivU wasm.OpcodeI64DivS

wasm.OpcodeI64DivU wasm.OpcodeF32Div wasm.OpcodeF64Div.

func NewOperationDrop

func NewOperationDrop(depth InclusiveRange) UnionOperation

NewOperationDrop is a constructor for UnionOperation with OperationKindDrop.

The engines are expected to discard the values selected by NewOperationDrop.Depth which starts from the top of the stack to the bottom.

depth spans across the uint64 value stack at runtime to be dropped by this operation.

func NewOperationElemDrop

func NewOperationElemDrop(elemIndex uint32) UnionOperation

NewOperationElemDrop is a constructor for UnionOperation with OperationKindElemDrop.

This corresponds to wasm.OpcodeElemDropName.

elemIndex is the index of the element which this operation drops.

func NewOperationEq

func NewOperationEq(b UnsignedType) UnionOperation

NewOperationEq is a constructor for UnionOperation with OperationKindEq.

This corresponds to wasm.OpcodeI32EqName wasm.OpcodeI64EqName wasm.OpcodeF32EqName wasm.OpcodeF64EqName

func NewOperationEqz

func NewOperationEqz(b UnsignedInt) UnionOperation

NewOperationEqz is a constructor for UnionOperation with OperationKindEqz.

This corresponds to wasm.OpcodeI32EqzName wasm.OpcodeI64EqzName

func NewOperationExtend

func NewOperationExtend(signed bool) UnionOperation

NewOperationExtend is a constructor for UnionOperation with OperationKindExtend.

This corresponds to wasm.OpcodeI64ExtendI32SName wasm.OpcodeI64ExtendI32UName

The engines are expected to extend the 32-bit signed or unsigned int on top of the stack as a 64-bit integer of corresponding signedness. For unsigned case, this is just reinterpreting the underlying bit pattern as 64-bit integer. For signed case, this is sign-extension which preserves the original integer's sign.

func NewOperationF32DemoteFromF64

func NewOperationF32DemoteFromF64() UnionOperation

NewOperationF32DemoteFromF64 is a constructor for UnionOperation with OperationKindF32DemoteFromF64.

This corresponds to wasm.OpcodeF32DemoteF64 and is equivalent float32(float64(v)).

func NewOperationF32ReinterpretFromI32

func NewOperationF32ReinterpretFromI32() UnionOperation

NewOperationF32ReinterpretFromI32 is a constructor for UnionOperation with OperationKindF32ReinterpretFromI32.

This corresponds to wasm.OpcodeF32ReinterpretI32Name.

func NewOperationF64PromoteFromF32

func NewOperationF64PromoteFromF32() UnionOperation

NewOperationF64PromoteFromF32 is a constructor for UnionOperation with OperationKindF64PromoteFromF32.

This corresponds to wasm.OpcodeF64PromoteF32 and is equivalent float64(float32(v)).

func NewOperationF64ReinterpretFromI64

func NewOperationF64ReinterpretFromI64() UnionOperation

NewOperationF64ReinterpretFromI64 is a constructor for UnionOperation with OperationKindF64ReinterpretFromI64.

This corresponds to wasm.OpcodeF64ReinterpretI64Name.

func NewOperationFConvertFromI

func NewOperationFConvertFromI(inputType SignedInt, outputType Float) UnionOperation

NewOperationFConvertFromI is a constructor for UnionOperation with OperationKindFConvertFromI.

This corresponds to

wasm.OpcodeF32ConvertI32SName wasm.OpcodeF32ConvertI32UName wasm.OpcodeF32ConvertI64SName wasm.OpcodeF32ConvertI64UName
wasm.OpcodeF64ConvertI32SName wasm.OpcodeF64ConvertI32UName wasm.OpcodeF64ConvertI64SName wasm.OpcodeF64ConvertI64UName

and equivalent to float32(uint32(x)), float32(int32(x)), etc in Go.

func NewOperationFloor

func NewOperationFloor(b Float) UnionOperation

NewOperationFloor is a constructor for UnionOperation with OperationKindFloor.

This corresponds to wasm.OpcodeF32FloorName wasm.OpcodeF64FloorName

func NewOperationGe

func NewOperationGe(b SignedType) UnionOperation

NewOperationGe is a constructor for UnionOperation with OperationKindGe.

This corresponds to wasm.OpcodeI32GeS wasm.OpcodeI32GeU wasm.OpcodeI64GeS wasm.OpcodeI64GeU wasm.OpcodeF32Ge wasm.OpcodeF64Ge NewOperationGe is the constructor for OperationGe

func NewOperationGlobalGet

func NewOperationGlobalGet(index uint32) UnionOperation

NewOperationGlobalGet is a constructor for UnionOperation with OperationKindGlobalGet.

The engines are expected to read the global value specified by OperationGlobalGet.Index, and push the copy of the value onto the stack.

See wasm.OpcodeGlobalGet.

func NewOperationGlobalSet

func NewOperationGlobalSet(index uint32) UnionOperation

NewOperationGlobalSet is a constructor for UnionOperation with OperationKindGlobalSet.

The engines are expected to consume the value from the top of the stack, and write the value into the global specified by OperationGlobalSet.Index.

See wasm.OpcodeGlobalSet.

func NewOperationGt

func NewOperationGt(b SignedType) UnionOperation

NewOperationGt is a constructor for UnionOperation with OperationKindGt.

This corresponds to wasm.OpcodeI32GtS wasm.OpcodeI32GtU wasm.OpcodeI64GtS wasm.OpcodeI64GtU wasm.OpcodeF32Gt wasm.OpcodeF64Gt

func NewOperationI32ReinterpretFromF32

func NewOperationI32ReinterpretFromF32() UnionOperation

NewOperationI32ReinterpretFromF32 is a constructor for UnionOperation with OperationKindI32ReinterpretFromF32.

This corresponds to wasm.OpcodeI32ReinterpretF32Name.

func NewOperationI32WrapFromI64

func NewOperationI32WrapFromI64() UnionOperation

NewOperationI32WrapFromI64 is a constructor for UnionOperation with OperationKindI32WrapFromI64.

This corresponds to wasm.OpcodeI32WrapI64 and equivalent to uint64(uint32(v)) in Go.

The engines are expected to replace the 64-bit int on top of the stack with the corresponding 32-bit integer.

func NewOperationI64ReinterpretFromF64

func NewOperationI64ReinterpretFromF64() UnionOperation

NewOperationI64ReinterpretFromF64 is a constructor for UnionOperation with OperationKindI64ReinterpretFromF64.

This corresponds to wasm.OpcodeI64ReinterpretF64Name.

func NewOperationITruncFromF

func NewOperationITruncFromF(inputType Float, outputType SignedInt, nonTrapping bool) UnionOperation

NewOperationITruncFromF is a constructor for UnionOperation with OperationKindITruncFromF.

This corresponds to

wasm.OpcodeI32TruncF32SName wasm.OpcodeI32TruncF32UName wasm.OpcodeI32TruncF64SName
wasm.OpcodeI32TruncF64UName wasm.OpcodeI64TruncF32SName wasm.OpcodeI64TruncF32UName wasm.OpcodeI64TruncF64SName
wasm.OpcodeI64TruncF64UName. wasm.OpcodeI32TruncSatF32SName wasm.OpcodeI32TruncSatF32UName
wasm.OpcodeI32TruncSatF64SName wasm.OpcodeI32TruncSatF64UName wasm.OpcodeI64TruncSatF32SName
wasm.OpcodeI64TruncSatF32UName wasm.OpcodeI64TruncSatF64SName wasm.OpcodeI64TruncSatF64UName

See [1] and [2] for when we encounter undefined behavior in the WebAssembly specification if NewOperationITruncFromF.NonTrapping == false. To summarize, if the source float value is NaN or doesn't fit in the destination range of integers (incl. +=Inf), then the runtime behavior is undefined. In wazero, the engines are expected to exit the execution in these undefined cases with wasmruntime.ErrRuntimeInvalidConversionToInteger error.

[1] https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#-hrefop-trunc-umathrmtruncmathsfu_m-n-z for unsigned integers. [2] https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#-hrefop-trunc-smathrmtruncmathsfs_m-n-z for signed integers.

nonTrapping true if this conversion is "nontrapping" in the sense of the https://github.com/WebAssembly/spec/blob/ce4b6c4d47eb06098cc7ab2e81f24748da822f20/proposals/nontrapping-float-to-int-conversion/Overview.md

func NewOperationLabel

func NewOperationLabel(label Label) UnionOperation

NewOperationLabel is a constructor for UnionOperation with OperationKindLabel.

This is used to inform the engines of the beginning of a label.

func NewOperationLe

func NewOperationLe(b SignedType) UnionOperation

NewOperationLe is a constructor for UnionOperation with OperationKindLe.

This corresponds to wasm.OpcodeI32LeS wasm.OpcodeI32LeU wasm.OpcodeI64LeS wasm.OpcodeI64LeU wasm.OpcodeF32Le wasm.OpcodeF64Le

func NewOperationLoad

func NewOperationLoad(unsignedType UnsignedType, arg MemoryArg) UnionOperation

NewOperationLoad is a constructor for UnionOperation with OperationKindLoad.

This corresponds to wasm.OpcodeI32LoadName wasm.OpcodeI64LoadName wasm.OpcodeF32LoadName and wasm.OpcodeF64LoadName.

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise load the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationLoad16

func NewOperationLoad16(signedInt SignedInt, arg MemoryArg) UnionOperation

NewOperationLoad16 is a constructor for UnionOperation with OperationKindLoad16.

This corresponds to wasm.OpcodeI32Load16SName wasm.OpcodeI32Load16UName wasm.OpcodeI64Load16SName wasm.OpcodeI64Load16UName.

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise load the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationLoad32

func NewOperationLoad32(signed bool, arg MemoryArg) UnionOperation

NewOperationLoad32 is a constructor for UnionOperation with OperationKindLoad32.

This corresponds to wasm.OpcodeI64Load32SName wasm.OpcodeI64Load32UName.

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise load the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationLoad8

func NewOperationLoad8(signedInt SignedInt, arg MemoryArg) UnionOperation

NewOperationLoad8 is a constructor for UnionOperation with OperationKindLoad8.

This corresponds to wasm.OpcodeI32Load8SName wasm.OpcodeI32Load8UName wasm.OpcodeI64Load8SName wasm.OpcodeI64Load8UName.

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise load the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationLt

func NewOperationLt(b SignedType) UnionOperation

NewOperationLt is a constructor for UnionOperation with OperationKindLt.

This corresponds to wasm.OpcodeI32LtS wasm.OpcodeI32LtU wasm.OpcodeI64LtS wasm.OpcodeI64LtU wasm.OpcodeF32Lt wasm.OpcodeF64Lt

func NewOperationMax

func NewOperationMax(b Float) UnionOperation

NewOperationMax is a constructor for UnionOperation with OperationKindMax.

This corresponds to wasm.OpcodeF32MaxName wasm.OpcodeF64MaxName

The engines are expected to pop two values from the stack, and push back the maximum of these two values onto the stack. For example, stack [..., 100.1, 1.9] results in [..., 100.1].

Note: WebAssembly specifies that min/max must always return NaN if one of values is NaN, which is a different behavior different from math.Max.

func NewOperationMemoryCopy

func NewOperationMemoryCopy() UnionOperation

NewOperationMemoryCopy is a consuctor for UnionOperation with OperationKindMemoryCopy.

This corresponds to wasm.OpcodeMemoryCopyName.

func NewOperationMemoryFill

func NewOperationMemoryFill() UnionOperation

NewOperationMemoryFill is a consuctor for UnionOperation with OperationKindMemoryFill.

func NewOperationMemoryGrow

func NewOperationMemoryGrow() UnionOperation

NewOperationMemoryGrow is a constructor for UnionOperation with OperationKindMemoryGrow.

This corresponds to wasm.OpcodeMemoryGrow.

The engines are expected to pop one value from the top of the stack, then execute wasm.MemoryInstance Grow with the value, and push the previous page size of the memory onto the stack.

func NewOperationMemoryInit

func NewOperationMemoryInit(dataIndex uint32) UnionOperation

NewOperationMemoryInit is a constructor for UnionOperation with OperationKindMemoryInit.

This corresponds to wasm.OpcodeMemoryInitName.

dataIndex is the index of the data instance in ModuleInstance.DataInstances by which this operation instantiates a part of the memory.

func NewOperationMemorySize

func NewOperationMemorySize() UnionOperation

NewOperationMemorySize is a constructor for UnionOperation with OperationKindMemorySize.

This corresponds to wasm.OpcodeMemorySize.

The engines are expected to push the current page size of the memory onto the stack.

func NewOperationMin

func NewOperationMin(b Float) UnionOperation

NewOperationMin is a constructor for UnionOperation with OperationKindMin.

This corresponds to wasm.OpcodeF32MinName wasm.OpcodeF64MinName

The engines are expected to pop two values from the stack, and push back the maximum of these two values onto the stack. For example, stack [..., 100.1, 1.9] results in [..., 1.9].

Note: WebAssembly specifies that min/max must always return NaN if one of values is NaN, which is a different behavior different from math.Min.

func NewOperationMul

func NewOperationMul(b UnsignedType) UnionOperation

NewOperationMul is a constructor for UnionOperation with wperationKindMul.

This corresponds to wasm.OpcodeI32MulName wasm.OpcodeI64MulName wasm.OpcodeF32MulName wasm.OpcodeF64MulName. NewOperationMul is the constructor for OperationMul

func NewOperationNe

func NewOperationNe(b UnsignedType) UnionOperation

NewOperationNe is a constructor for UnionOperation with OperationKindNe.

This corresponds to wasm.OpcodeI32NeName wasm.OpcodeI64NeName wasm.OpcodeF32NeName wasm.OpcodeF64NeName

func NewOperationNearest

func NewOperationNearest(b Float) UnionOperation

NewOperationNearest is a constructor for UnionOperation with OperationKindNearest.

This corresponds to wasm.OpcodeF32NearestName wasm.OpcodeF64NearestName

Note: this is *not* equivalent to math.Round and instead has the same the semantics of LLVM's rint intrinsic. See https://llvm.org/docs/LangRef.html#llvm-rint-intrinsic. For example, math.Round(-4.5) produces -5 while we want to produce -4.

func NewOperationNeg

func NewOperationNeg(b Float) UnionOperation

NewOperationNeg is a constructor for UnionOperation with OperationKindNeg.

This corresponds to wasm.OpcodeF32Neg wasm.OpcodeF64Neg

func NewOperationOr

func NewOperationOr(b UnsignedInt) UnionOperation

NewOperationOr is a constructor for UnionOperation with OperationKindOr.

This corresponds to wasm.OpcodeI32OrName wasm.OpcodeI64OrName

The engines are expected to perform "Or" operation on top two values on the stack, and pushes the result.

func NewOperationPick

func NewOperationPick(depth int, isTargetVector bool) UnionOperation

NewOperationPick is a constructor for UnionOperation with OperationKindPick.

The engines are expected to copy a value pointed by depth, and push the copied value onto the top of the stack.

depth is the location of the pick target in the uint64 value stack at runtime. If isTargetVector=true, this points to the location of the lower 64-bits of the vector.

func NewOperationPopcnt

func NewOperationPopcnt(b UnsignedInt) UnionOperation

NewOperationPopcnt is a constructor for UnionOperation with OperationKindPopcnt.

This corresponds to wasm.OpcodeI32PopcntName wasm.OpcodeI64PopcntName.

The engines are expected to count up the number of set bits in the current top of the stack, and push the count result. For example, stack of [..., 0b00_00_00_11] results in [..., 2].

func NewOperationRefFunc

func NewOperationRefFunc(functionIndex uint32) UnionOperation

NewOperationRefFunc constructor for UnionOperation with OperationKindRefFunc.

This corresponds to wasm.OpcodeRefFuncName, and engines are expected to push the opaque pointer value of engine specific func for the given FunctionIndex.

Note: in wazero, we express any reference types (funcref or externref) as opaque pointers which is uint64. Therefore, the engine implementations emit instructions to push the address of *function onto the stack.

func NewOperationRem

func NewOperationRem(b SignedInt) UnionOperation

NewOperationRem is a constructor for UnionOperation with OperationKindRem.

This corresponds to wasm.OpcodeI32RemS wasm.OpcodeI32RemU wasm.OpcodeI64RemS wasm.OpcodeI64RemU.

The engines are expected to perform division on the top two values of integer type on the stack and puts the remainder of the result onto the stack. For example, stack [..., 10, 3] results in [..., 1] where the quotient is discarded. NewOperationRem is the constructor for OperationRem

func NewOperationRotl

func NewOperationRotl(b UnsignedInt) UnionOperation

NewOperationRotl is a constructor for UnionOperation with OperationKindRotl.

This corresponds to wasm.OpcodeI32RotlName wasm.OpcodeI64RotlName

The engines are expected to perform "Rotl" operation on top two values on the stack, and pushes the result.

func NewOperationRotr

func NewOperationRotr(b UnsignedInt) UnionOperation

NewOperationRotr is a constructor for UnionOperation with OperationKindRotr.

This corresponds to wasm.OpcodeI32RotrName wasm.OpcodeI64RotrName

The engines are expected to perform "Rotr" operation on top two values on the stack, and pushes the result.

func NewOperationSelect

func NewOperationSelect(isTargetVector bool) UnionOperation

NewOperationSelect is a constructor for UnionOperation with OperationKindSelect.

This corresponds to wasm.OpcodeSelect.

The engines are expected to pop three values, say [..., x2, x1, c], then if the value "c" equals zero, "x1" is pushed back onto the stack and, otherwise "x2" is pushed back.

isTargetVector true if the selection target value's type is wasm.ValueTypeV128.

func NewOperationSet

func NewOperationSet(depth int, isTargetVector bool) UnionOperation

NewOperationSet is a constructor for UnionOperation with OperationKindSet.

The engines are expected to set the top value of the stack to the location specified by depth.

depth is the location of the set target in the uint64 value stack at runtime. If isTargetVector=true, this points the location of the lower 64-bits of the vector.

func NewOperationShl

func NewOperationShl(b UnsignedInt) UnionOperation

NewOperationShl is a constructor for UnionOperation with OperationKindShl.

This corresponds to wasm.OpcodeI32ShlName wasm.OpcodeI64ShlName

The engines are expected to perform "Shl" operation on top two values on the stack, and pushes the result.

func NewOperationShr

func NewOperationShr(b SignedInt) UnionOperation

NewOperationShr is a constructor for UnionOperation with OperationKindShr.

This corresponds to wasm.OpcodeI32ShrSName wasm.OpcodeI32ShrUName wasm.OpcodeI64ShrSName wasm.OpcodeI64ShrUName

If OperationShr.Type is signed integer, then, the engines are expected to perform arithmetic right shift on the two top values on the stack, otherwise do the logical right shift.

func NewOperationSignExtend32From16

func NewOperationSignExtend32From16() UnionOperation

NewOperationSignExtend32From16 is a constructor for UnionOperation with OperationKindSignExtend32From16.

This corresponds to wasm.OpcodeI32Extend16SName.

The engines are expected to sign-extend the first 16-bits of 32-bit in as signed 32-bit int.

func NewOperationSignExtend32From8

func NewOperationSignExtend32From8() UnionOperation

NewOperationSignExtend32From8 is a constructor for UnionOperation with OperationKindSignExtend32From8.

This corresponds to wasm.OpcodeI32Extend8SName.

The engines are expected to sign-extend the first 8-bits of 32-bit in as signed 32-bit int.

func NewOperationSignExtend64From16

func NewOperationSignExtend64From16() UnionOperation

NewOperationSignExtend64From16 is a constructor for UnionOperation with OperationKindSignExtend64From16.

This corresponds to wasm.OpcodeI64Extend16SName.

The engines are expected to sign-extend the first 16-bits of 64-bit in as signed 32-bit int.

func NewOperationSignExtend64From32

func NewOperationSignExtend64From32() UnionOperation

NewOperationSignExtend64From32 is a constructor for UnionOperation with OperationKindSignExtend64From32.

This corresponds to wasm.OpcodeI64Extend32SName.

The engines are expected to sign-extend the first 32-bits of 64-bit in as signed 32-bit int.

func NewOperationSignExtend64From8

func NewOperationSignExtend64From8() UnionOperation

NewOperationSignExtend64From8 is a constructor for UnionOperation with OperationKindSignExtend64From8.

This corresponds to wasm.OpcodeI64Extend8SName.

The engines are expected to sign-extend the first 8-bits of 64-bit in as signed 32-bit int.

func NewOperationSqrt

func NewOperationSqrt(b Float) UnionOperation

NewOperationSqrt is a constructor for UnionOperation with OperationKindSqrt.

This corresponds to wasm.OpcodeF32SqrtName wasm.OpcodeF64SqrtName

func NewOperationStore

func NewOperationStore(unsignedType UnsignedType, arg MemoryArg) UnionOperation

NewOperationStore is a constructor for UnionOperation with OperationKindStore.

This corresponds to wasm.OpcodeI32StoreName wasm.OpcodeI64StoreName wasm.OpcodeF32StoreName wasm.OpcodeF64StoreName

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise store the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationStore16

func NewOperationStore16(arg MemoryArg) UnionOperation

NewOperationStore16 is a constructor for UnionOperation with OperationKindStore16.

This corresponds to wasm.OpcodeI32Store16Name wasm.OpcodeI64Store16Name

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise store the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationStore32

func NewOperationStore32(arg MemoryArg) UnionOperation

NewOperationStore32 is a constructor for UnionOperation with OperationKindStore32.

This corresponds to wasm.OpcodeI64Store32Name

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise store the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationStore8

func NewOperationStore8(arg MemoryArg) UnionOperation

NewOperationStore8 is a constructor for UnionOperation with OperationKindStore8.

This corresponds to wasm.OpcodeI32Store8Name wasm.OpcodeI64Store8Name

The engines are expected to check the boundary of memory length, and exit the execution if this exceeds the boundary, otherwise store the corresponding value following the semantics of the corresponding WebAssembly instruction.

func NewOperationSub

func NewOperationSub(b UnsignedType) UnionOperation

NewOperationSub is a constructor for UnionOperation with OperationKindSub.

This corresponds to wasm.OpcodeI32SubName wasm.OpcodeI64SubName wasm.OpcodeF32SubName wasm.OpcodeF64SubName.

func NewOperationTableCopy

func NewOperationTableCopy(srcTableIndex, dstTableIndex uint32) UnionOperation

NewOperationTableCopy implements Operation.

This corresponds to wasm.OpcodeTableCopyName.

func NewOperationTableFill

func NewOperationTableFill(tableIndex uint32) UnionOperation

NewOperationTableFill constructor for UnionOperation with OperationKindTableFill.

This corresponds to wasm.OpcodeTableFillName.

func NewOperationTableGet

func NewOperationTableGet(tableIndex uint32) UnionOperation

NewOperationTableGet constructor for UnionOperation with OperationKindTableGet.

This corresponds to wasm.OpcodeTableGetName.

func NewOperationTableGrow

func NewOperationTableGrow(tableIndex uint32) UnionOperation

NewOperationTableGrow constructor for UnionOperation with OperationKindTableGrow.

This corresponds to wasm.OpcodeTableGrowName.

func NewOperationTableInit

func NewOperationTableInit(elemIndex, tableIndex uint32) UnionOperation

NewOperationTableInit is a constructor for UnionOperation with OperationKindTableInit.

This corresponds to wasm.OpcodeTableInitName.

elemIndex is the index of the element by which this operation initializes a part of the table. tableIndex is the index of the table on which this operation initialize by the target element.

func NewOperationTableSet

func NewOperationTableSet(tableIndex uint32) UnionOperation

NewOperationTableSet constructor for UnionOperation with OperationKindTableSet.

This corresponds to wasm.OpcodeTableSetName.

func NewOperationTableSize

func NewOperationTableSize(tableIndex uint32) UnionOperation

NewOperationTableSize constructor for UnionOperation with OperationKindTableSize.

This corresponds to wasm.OpcodeTableSizeName.

func NewOperationTrunc

func NewOperationTrunc(b Float) UnionOperation

NewOperationTrunc is a constructor for UnionOperation with OperationKindTrunc.

This corresponds to wasm.OpcodeF32TruncName wasm.OpcodeF64TruncName

func NewOperationUnreachable

func NewOperationUnreachable() UnionOperation

NewOperationUnreachable is a constructor for UnionOperation with OperationKindUnreachable

This corresponds to wasm.OpcodeUnreachable.

The engines are expected to exit the execution with wasmruntime.ErrRuntimeUnreachable error.

func NewOperationV128Abs

func NewOperationV128Abs(shape Shape) UnionOperation

NewOperationV128Abs is a constructor for UnionOperation with OperationKindV128Abs.

This corresponds to wasm.OpcodeVecI8x16AbsName wasm.OpcodeVecI16x8AbsName wasm.OpcodeVecI32x4AbsName

wasm.OpcodeVecI64x2AbsName wasm.OpcodeVecF32x4AbsName wasm.OpcodeVecF64x2AbsName.

func NewOperationV128Add

func NewOperationV128Add(shape Shape) UnionOperation

NewOperationV128Add constructor for UnionOperation with OperationKindV128Add.

This corresponds to wasm.OpcodeVecI8x16AddName wasm.OpcodeVecI16x8AddName wasm.OpcodeVecI32x4AddName

wasm.OpcodeVecI64x2AddName wasm.OpcodeVecF32x4AddName wasm.OpcodeVecF64x2AddName

func NewOperationV128AddSat

func NewOperationV128AddSat(shape Shape, signed bool) UnionOperation

NewOperationV128AddSat is a constructor for UnionOperation with OperationKindV128AddSat.

This corresponds to wasm.OpcodeVecI8x16AddSatUName wasm.OpcodeVecI8x16AddSatSName

wasm.OpcodeVecI16x8AddSatUName wasm.OpcodeVecI16x8AddSatSName

shape is either ShapeI8x16 or ShapeI16x8.

func NewOperationV128AllTrue

func NewOperationV128AllTrue(shape Shape) UnionOperation

NewOperationV128AllTrue is a constructor for UnionOperation with OperationKindV128AllTrue.

This corresponds to

wasm.OpcodeVecI8x16AllTrueName wasm.OpcodeVecI16x8AllTrueName
wasm.OpcodeVecI32x4AllTrueName wasm.OpcodeVecI64x2AllTrueName.

func NewOperationV128And

func NewOperationV128And() UnionOperation

NewOperationV128And is a constructor for UnionOperation with OperationKindV128And.

This corresponds to wasm.OpcodeVecV128And.

func NewOperationV128AndNot

func NewOperationV128AndNot() UnionOperation

NewOperationV128AndNot is a constructor for UnionOperation with OperationKindV128AndNot.

This corresponds to wasm.OpcodeVecV128AndNot.

func NewOperationV128AnyTrue

func NewOperationV128AnyTrue() UnionOperation

NewOperationV128AnyTrue is a constructor for UnionOperation with OperationKindV128AnyTrue.

This corresponds to wasm.OpcodeVecV128AnyTrueName.

func NewOperationV128AvgrU

func NewOperationV128AvgrU(shape Shape) UnionOperation

NewOperationV128AvgrU is a constructor for UnionOperation with OperationKindV128AvgrU.

This corresponds to wasm.OpcodeVecI8x16AvgrUName.

func NewOperationV128BitMask

func NewOperationV128BitMask(shape Shape) UnionOperation

NewOperationV128BitMask is a constructor for UnionOperation with OperationKindV128BitMask.

This corresponds to

wasm.OpcodeVecI8x16BitMaskName wasm.OpcodeVecI16x8BitMaskName
wasm.OpcodeVecI32x4BitMaskName wasm.OpcodeVecI64x2BitMaskName.

func NewOperationV128Bitselect

func NewOperationV128Bitselect() UnionOperation

NewOperationV128Bitselect is a constructor for UnionOperation with OperationKindV128Bitselect.

This corresponds to wasm.OpcodeVecV128Bitselect.

func NewOperationV128Ceil

func NewOperationV128Ceil(shape Shape) UnionOperation

NewOperationV128Ceil is a constructor for UnionOperation with OperationKindV128Ceil.

This corresponds to wasm.OpcodeVecF32x4CeilName wasm.OpcodeVecF64x2CeilName

func NewOperationV128Cmp

func NewOperationV128Cmp(cmpType V128CmpType) UnionOperation

NewOperationV128Cmp is a constructor for UnionOperation with OperationKindV128Cmp.

This corresponds to

wasm.OpcodeVecI8x16EqName, wasm.OpcodeVecI8x16NeName, wasm.OpcodeVecI8x16LtSName, wasm.OpcodeVecI8x16LtUName, wasm.OpcodeVecI8x16GtSName,
wasm.OpcodeVecI8x16GtUName, wasm.OpcodeVecI8x16LeSName, wasm.OpcodeVecI8x16LeUName, wasm.OpcodeVecI8x16GeSName, wasm.OpcodeVecI8x16GeUName,
wasm.OpcodeVecI16x8EqName, wasm.OpcodeVecI16x8NeName, wasm.OpcodeVecI16x8LtSName, wasm.OpcodeVecI16x8LtUName, wasm.OpcodeVecI16x8GtSName,
wasm.OpcodeVecI16x8GtUName, wasm.OpcodeVecI16x8LeSName, wasm.OpcodeVecI16x8LeUName, wasm.OpcodeVecI16x8GeSName, wasm.OpcodeVecI16x8GeUName,
wasm.OpcodeVecI32x4EqName, wasm.OpcodeVecI32x4NeName, wasm.OpcodeVecI32x4LtSName, wasm.OpcodeVecI32x4LtUName, wasm.OpcodeVecI32x4GtSName,
wasm.OpcodeVecI32x4GtUName, wasm.OpcodeVecI32x4LeSName, wasm.OpcodeVecI32x4LeUName, wasm.OpcodeVecI32x4GeSName, wasm.OpcodeVecI32x4GeUName,
wasm.OpcodeVecI64x2EqName, wasm.OpcodeVecI64x2NeName, wasm.OpcodeVecI64x2LtSName, wasm.OpcodeVecI64x2GtSName, wasm.OpcodeVecI64x2LeSName,
wasm.OpcodeVecI64x2GeSName, wasm.OpcodeVecF32x4EqName, wasm.OpcodeVecF32x4NeName, wasm.OpcodeVecF32x4LtName, wasm.OpcodeVecF32x4GtName,
wasm.OpcodeVecF32x4LeName, wasm.OpcodeVecF32x4GeName, wasm.OpcodeVecF64x2EqName, wasm.OpcodeVecF64x2NeName, wasm.OpcodeVecF64x2LtName,
wasm.OpcodeVecF64x2GtName, wasm.OpcodeVecF64x2LeName, wasm.OpcodeVecF64x2GeName

func NewOperationV128Const

func NewOperationV128Const(lo, hi uint64) UnionOperation

NewOperationV128Const constructor for UnionOperation with OperationKindV128Const

func NewOperationV128Div

func NewOperationV128Div(shape Shape) UnionOperation

NewOperationV128Div is a constructor for UnionOperation with OperationKindV128Div.

This corresponds to wasm.OpcodeVecF32x4DivName wasm.OpcodeVecF64x2DivName. shape is either ShapeF32x4 or ShapeF64x2.

func NewOperationV128Dot

func NewOperationV128Dot() UnionOperation

NewOperationV128Dot is a constructor for UnionOperation with OperationKindV128Dot.

This corresponds to wasm.OpcodeVecI32x4DotI16x8SName

func NewOperationV128ExtAddPairwise

func NewOperationV128ExtAddPairwise(originShape Shape, signed bool) UnionOperation

NewOperationV128ExtAddPairwise is a constructor for UnionOperation with OperationKindV128ExtAddPairwise.

This corresponds to

wasm.OpcodeVecI16x8ExtaddPairwiseI8x16SName wasm.OpcodeVecI16x8ExtaddPairwiseI8x16UName
wasm.OpcodeVecI32x4ExtaddPairwiseI16x8SName wasm.OpcodeVecI32x4ExtaddPairwiseI16x8UName.

originShape is the shape of the original lanes for extension which is either ShapeI8x16, or ShapeI16x8.

func NewOperationV128ExtMul

func NewOperationV128ExtMul(originShape Shape, signed bool, useLow bool) UnionOperation

NewOperationV128ExtMul is a constructor for UnionOperation with OperationKindV128ExtMul.

This corresponds to

	wasm.OpcodeVecI16x8ExtMulLowI8x16SName wasm.OpcodeVecI16x8ExtMulLowI8x16UName
	wasm.OpcodeVecI16x8ExtMulHighI8x16SName wasm.OpcodeVecI16x8ExtMulHighI8x16UName
 wasm.OpcodeVecI32x4ExtMulLowI16x8SName wasm.OpcodeVecI32x4ExtMulLowI16x8UName
	wasm.OpcodeVecI32x4ExtMulHighI16x8SName wasm.OpcodeVecI32x4ExtMulHighI16x8UName
 wasm.OpcodeVecI64x2ExtMulLowI32x4SName wasm.OpcodeVecI64x2ExtMulLowI32x4UName
	wasm.OpcodeVecI64x2ExtMulHighI32x4SName wasm.OpcodeVecI64x2ExtMulHighI32x4UName.

originShape is the shape of the original lanes for extension which is either ShapeI8x16, ShapeI16x8, or ShapeI32x4. useLow true if it uses the lower half of vector for extension.

func NewOperationV128Extend

func NewOperationV128Extend(originShape Shape, signed bool, useLow bool) UnionOperation

NewOperationV128Extend is a constructor for UnionOperation with OperationKindV128Extend.

This corresponds to

wasm.OpcodeVecI16x8ExtendLowI8x16SName wasm.OpcodeVecI16x8ExtendHighI8x16SName
wasm.OpcodeVecI16x8ExtendLowI8x16UName wasm.OpcodeVecI16x8ExtendHighI8x16UName
wasm.OpcodeVecI32x4ExtendLowI16x8SName wasm.OpcodeVecI32x4ExtendHighI16x8SName
wasm.OpcodeVecI32x4ExtendLowI16x8UName wasm.OpcodeVecI32x4ExtendHighI16x8UName
wasm.OpcodeVecI64x2ExtendLowI32x4SName wasm.OpcodeVecI64x2ExtendHighI32x4SName
wasm.OpcodeVecI64x2ExtendLowI32x4UName wasm.OpcodeVecI64x2ExtendHighI32x4UName

originShape is the shape of the original lanes for extension which is either ShapeI8x16, ShapeI16x8, or ShapeI32x4. useLow true if it uses the lower half of vector for extension.

func NewOperationV128ExtractLane

func NewOperationV128ExtractLane(laneIndex byte, signed bool, shape Shape) UnionOperation

NewOperationV128ExtractLane is a constructor for UnionOperation with OperationKindV128ExtractLane.

This corresponds to

wasm.OpcodeVecI8x16ExtractLaneSName wasm.OpcodeVecI8x16ExtractLaneUName
wasm.OpcodeVecI16x8ExtractLaneSName wasm.OpcodeVecI16x8ExtractLaneUName
wasm.OpcodeVecI32x4ExtractLaneName wasm.OpcodeVecI64x2ExtractLaneName
wasm.OpcodeVecF32x4ExtractLaneName wasm.OpcodeVecF64x2ExtractLaneName.

laneIndex is >=0 && <M where shape = NxM. signed is used when shape is either i8x16 or i16x2 to specify whether to sign-extend or not.

func NewOperationV128FConvertFromI

func NewOperationV128FConvertFromI(destinationShape Shape, signed bool) UnionOperation

NewOperationV128FConvertFromI is a constructor for UnionOperation with NewOperationV128FConvertFromI.

This corresponds to

wasm.OpcodeVecF32x4ConvertI32x4SName wasm.OpcodeVecF32x4ConvertI32x4UName
wasm.OpcodeVecF64x2ConvertLowI32x4SName wasm.OpcodeVecF64x2ConvertLowI32x4UName.

destinationShape is the shape of the destination lanes for conversion which is either ShapeF32x4, or ShapeF64x2.

func NewOperationV128FloatDemote

func NewOperationV128FloatDemote() UnionOperation

NewOperationV128FloatDemote is a constructor for UnionOperation with NewOperationV128FloatDemote.

This corresponds to wasm.OpcodeVecF32x4DemoteF64x2ZeroName.

func NewOperationV128FloatPromote

func NewOperationV128FloatPromote() UnionOperation

NewOperationV128FloatPromote is a constructor for UnionOperation with NewOperationV128FloatPromote.

This corresponds to wasm.OpcodeVecF64x2PromoteLowF32x4ZeroName This discards the higher 64-bit of a vector, and promotes two 32-bit floats in the lower 64-bit as two 64-bit floats.

func NewOperationV128Floor

func NewOperationV128Floor(shape Shape) UnionOperation

NewOperationV128Floor is a constructor for UnionOperation with OperationKindV128Floor.

This corresponds to wasm.OpcodeVecF32x4FloorName wasm.OpcodeVecF64x2FloorName

func NewOperationV128ITruncSatFromF

func NewOperationV128ITruncSatFromF(originShape Shape, signed bool) UnionOperation

NewOperationV128ITruncSatFromF is a constructor for UnionOperation with OperationKindV128ITruncSatFromF.

This corresponds to

wasm.OpcodeVecI32x4TruncSatF64x2UZeroName wasm.OpcodeVecI32x4TruncSatF64x2SZeroName
wasm.OpcodeVecI32x4TruncSatF32x4UName wasm.OpcodeVecI32x4TruncSatF32x4SName.

originShape is the shape of the original lanes for truncation which is either ShapeF32x4, or ShapeF64x2.

func NewOperationV128Load

func NewOperationV128Load(loadType V128LoadType, arg MemoryArg) UnionOperation

NewOperationV128Load is a constructor for UnionOperation with OperationKindV128Load.

This corresponds to

wasm.OpcodeVecV128LoadName wasm.OpcodeVecV128Load8x8SName wasm.OpcodeVecV128Load8x8UName
wasm.OpcodeVecV128Load16x4SName wasm.OpcodeVecV128Load16x4UName wasm.OpcodeVecV128Load32x2SName
wasm.OpcodeVecV128Load32x2UName wasm.OpcodeVecV128Load8SplatName wasm.OpcodeVecV128Load16SplatName
wasm.OpcodeVecV128Load32SplatName wasm.OpcodeVecV128Load64SplatName wasm.OpcodeVecV128Load32zeroName
wasm.OpcodeVecV128Load64zeroName

func NewOperationV128LoadLane

func NewOperationV128LoadLane(laneIndex, laneSize byte, arg MemoryArg) UnionOperation

NewOperationV128LoadLane is a constructor for UnionOperation with OperationKindV128LoadLane.

This corresponds to wasm.OpcodeVecV128Load8LaneName wasm.OpcodeVecV128Load16LaneName

wasm.OpcodeVecV128Load32LaneName wasm.OpcodeVecV128Load64LaneName.

laneIndex is >=0 && <(128/LaneSize). laneSize is either 8, 16, 32, or 64.

func NewOperationV128Max

func NewOperationV128Max(shape Shape, signed bool) UnionOperation

NewOperationV128Max is a constructor for UnionOperation with OperationKindV128Max.

This corresponds to

wasm.OpcodeVecI8x16MaxSName wasm.OpcodeVecI8x16MaxUName wasm.OpcodeVecI16x8MaxSName wasm.OpcodeVecI16x8MaxUName
wasm.OpcodeVecI32x4MaxSName wasm.OpcodeVecI32x4MaxUName wasm.OpcodeVecI16x8MaxSName wasm.OpcodeVecI16x8MaxUName
wasm.OpcodeVecF32x4MaxName wasm.OpcodeVecF64x2MaxName.

func NewOperationV128Min

func NewOperationV128Min(shape Shape, signed bool) UnionOperation

NewOperationV128Min is a constructor for UnionOperation with OperationKindV128Min.

This corresponds to

wasm.OpcodeVecI8x16MinSName wasm.OpcodeVecI8x16MinUName wasm.OpcodeVecI16x8MinSName wasm.OpcodeVecI16x8MinUName
wasm.OpcodeVecI32x4MinSName wasm.OpcodeVecI32x4MinUName wasm.OpcodeVecI16x8MinSName wasm.OpcodeVecI16x8MinUName
wasm.OpcodeVecF32x4MinName wasm.OpcodeVecF64x2MinName

func NewOperationV128Mul

func NewOperationV128Mul(shape Shape) UnionOperation

NewOperationV128Mul is a constructor for UnionOperation with OperationKindV128Mul

This corresponds to wasm.OpcodeVecF32x4MulName wasm.OpcodeVecF64x2MulName

	wasm.OpcodeVecI16x8MulName wasm.OpcodeVecI32x4MulName wasm.OpcodeVecI64x2MulName.
 shape is either ShapeI16x8, ShapeI32x4, ShapeI64x2, ShapeF32x4 or ShapeF64x2.

func NewOperationV128Narrow

func NewOperationV128Narrow(originShape Shape, signed bool) UnionOperation

NewOperationV128Narrow is a constructor for UnionOperation with OperationKindV128Narrow.

This corresponds to

wasm.OpcodeVecI8x16NarrowI16x8SName wasm.OpcodeVecI8x16NarrowI16x8UName
wasm.OpcodeVecI16x8NarrowI32x4SName wasm.OpcodeVecI16x8NarrowI32x4UName.

originShape is the shape of the original lanes for narrowing which is either ShapeI16x8, or ShapeI32x4.

func NewOperationV128Nearest

func NewOperationV128Nearest(shape Shape) UnionOperation

NewOperationV128Nearest is a constructor for UnionOperation with OperationKindV128Nearest.

This corresponds to wasm.OpcodeVecF32x4NearestName wasm.OpcodeVecF64x2NearestName

func NewOperationV128Neg

func NewOperationV128Neg(shape Shape) UnionOperation

NewOperationV128Neg is a constructor for UnionOperation with OperationKindV128Neg.

This corresponds to wasm.OpcodeVecI8x16NegName wasm.OpcodeVecI16x8NegName wasm.OpcodeVecI32x4NegName

wasm.OpcodeVecI64x2NegName wasm.OpcodeVecF32x4NegName wasm.OpcodeVecF64x2NegName.

func NewOperationV128Not

func NewOperationV128Not() UnionOperation

NewOperationV128Not is a constructor for UnionOperation with OperationKindV128Not.

This corresponds to wasm.OpcodeVecV128Not.

func NewOperationV128Or

func NewOperationV128Or() UnionOperation

NewOperationV128Or is a constructor for UnionOperation with OperationKindV128Or.

This corresponds to wasm.OpcodeVecV128Or.

func NewOperationV128Pmax

func NewOperationV128Pmax(shape Shape) UnionOperation

NewOperationV128Pmax is a constructor for UnionOperation with OperationKindV128Pmax.

This corresponds to wasm.OpcodeVecF32x4PmaxName wasm.OpcodeVecF64x2PmaxName.

func NewOperationV128Pmin

func NewOperationV128Pmin(shape Shape) UnionOperation

NewOperationV128Pmin is a constructor for UnionOperation with OperationKindV128Pmin.

This corresponds to wasm.OpcodeVecF32x4PminName wasm.OpcodeVecF64x2PminName.

func NewOperationV128Popcnt

func NewOperationV128Popcnt(shape Shape) UnionOperation

NewOperationV128Popcnt is a constructor for UnionOperation with OperationKindV128Popcnt.

This corresponds to wasm.OpcodeVecI8x16PopcntName.

func NewOperationV128Q15mulrSatS

func NewOperationV128Q15mulrSatS() UnionOperation

NewOperationV128Q15mulrSatS is a constructor for UnionOperation with OperationKindV128Q15mulrSatS.

This corresponds to wasm.OpcodeVecI16x8Q15mulrSatSName

func NewOperationV128ReplaceLane

func NewOperationV128ReplaceLane(laneIndex byte, shape Shape) UnionOperation

NewOperationV128ReplaceLane is a constructor for UnionOperation with OperationKindV128ReplaceLane.

This corresponds to

wasm.OpcodeVecI8x16ReplaceLaneName wasm.OpcodeVecI16x8ReplaceLaneName
wasm.OpcodeVecI32x4ReplaceLaneName wasm.OpcodeVecI64x2ReplaceLaneName
wasm.OpcodeVecF32x4ReplaceLaneName wasm.OpcodeVecF64x2ReplaceLaneName.

laneIndex is >=0 && <M where shape = NxM.

func NewOperationV128Shl

func NewOperationV128Shl(shape Shape) UnionOperation

NewOperationV128Shl is a constructor for UnionOperation with OperationKindV128Shl.

This corresponds to

wasm.OpcodeVecI8x16ShlName wasm.OpcodeVecI16x8ShlName
wasm.OpcodeVecI32x4ShlName wasm.OpcodeVecI64x2ShlName

func NewOperationV128Shr

func NewOperationV128Shr(shape Shape, signed bool) UnionOperation

NewOperationV128Shr is a constructor for UnionOperation with OperationKindV128Shr.

This corresponds to

wasm.OpcodeVecI8x16ShrSName wasm.OpcodeVecI8x16ShrUName wasm.OpcodeVecI16x8ShrSName
wasm.OpcodeVecI16x8ShrUName wasm.OpcodeVecI32x4ShrSName wasm.OpcodeVecI32x4ShrUName.
wasm.OpcodeVecI64x2ShrSName wasm.OpcodeVecI64x2ShrUName.

func NewOperationV128Shuffle

func NewOperationV128Shuffle(lanes []uint64) UnionOperation

NewOperationV128Shuffle is a constructor for UnionOperation with OperationKindV128Shuffle.

func NewOperationV128Splat

func NewOperationV128Splat(shape Shape) UnionOperation

NewOperationV128Splat is a constructor for UnionOperation with OperationKindV128Splat.

This corresponds to

wasm.OpcodeVecI8x16SplatName wasm.OpcodeVecI16x8SplatName
wasm.OpcodeVecI32x4SplatName wasm.OpcodeVecI64x2SplatName
wasm.OpcodeVecF32x4SplatName wasm.OpcodeVecF64x2SplatName.

func NewOperationV128Sqrt

func NewOperationV128Sqrt(shape Shape) UnionOperation

NewOperationV128Sqrt is a constructor for UnionOperation with 128OperationKindV128Sqrt.

shape is either ShapeF32x4 or ShapeF64x2. This corresponds to wasm.OpcodeVecF32x4SqrtName wasm.OpcodeVecF64x2SqrtName.

func NewOperationV128Store

func NewOperationV128Store(arg MemoryArg) UnionOperation

NewOperationV128Store is a constructor for UnionOperation with OperationKindV128Store.

This corresponds to wasm.OpcodeVecV128Load8LaneName wasm.OpcodeVecV128Load16LaneName

wasm.OpcodeVecV128Load32LaneName wasm.OpcodeVecV128Load64LaneName.

func NewOperationV128StoreLane

func NewOperationV128StoreLane(laneIndex byte, laneSize byte, arg MemoryArg) UnionOperation

NewOperationV128StoreLane implements Operation.

This corresponds to wasm.OpcodeVecV128Load8LaneName wasm.OpcodeVecV128Load16LaneName

wasm.OpcodeVecV128Load32LaneName wasm.OpcodeVecV128Load64LaneName.

laneIndex is >=0 && <(128/LaneSize). laneSize is either 8, 16, 32, or 64.

func NewOperationV128Sub

func NewOperationV128Sub(shape Shape) UnionOperation

NewOperationV128Sub constructor for UnionOperation with OperationKindV128Sub.

This corresponds to wasm.OpcodeVecI8x16SubName wasm.OpcodeVecI16x8SubName wasm.OpcodeVecI32x4SubName

wasm.OpcodeVecI64x2SubName wasm.OpcodeVecF32x4SubName wasm.OpcodeVecF64x2SubName

func NewOperationV128SubSat

func NewOperationV128SubSat(shape Shape, signed bool) UnionOperation

NewOperationV128SubSat is a constructor for UnionOperation with OperationKindV128SubSat.

This corresponds to wasm.OpcodeVecI8x16SubSatUName wasm.OpcodeVecI8x16SubSatSName

wasm.OpcodeVecI16x8SubSatUName wasm.OpcodeVecI16x8SubSatSName

shape is either ShapeI8x16 or ShapeI16x8.

func NewOperationV128Swizzle

func NewOperationV128Swizzle() UnionOperation

NewOperationV128Swizzle is a constructor for UnionOperation with OperationKindV128Swizzle.

This corresponds to wasm.OpcodeVecI8x16SwizzleName.

func NewOperationV128Trunc

func NewOperationV128Trunc(shape Shape) UnionOperation

NewOperationV128Trunc is a constructor for UnionOperation with OperationKindV128Trunc.

This corresponds to wasm.OpcodeVecF32x4TruncName wasm.OpcodeVecF64x2TruncName

func NewOperationV128Xor

func NewOperationV128Xor() UnionOperation

NewOperationV128Xor is a constructor for UnionOperation with OperationKindV128Xor.

This corresponds to wasm.OpcodeVecV128Xor.

func NewOperationXor

func NewOperationXor(b UnsignedInt) UnionOperation

NewOperationXor is a constructor for UnionOperation with OperationKindXor.

This corresponds to wasm.OpcodeI32XorName wasm.OpcodeI64XorName

The engines are expected to perform "Xor" operation on top two values on the stack, and pushes the result.

func (UnionOperation) String

func (o UnionOperation) String() string

String implements fmt.Stringer.

type UnsignedInt

type UnsignedInt byte

UnsignedInt represents unsigned 32-bit or 64-bit integers.

const (
	UnsignedInt32 UnsignedInt = iota
	UnsignedInt64
)

func (UnsignedInt) String

func (s UnsignedInt) String() (ret string)

String implements fmt.Stringer.

type UnsignedType

type UnsignedType byte

UnsignedType is the union of UnsignedInt, Float and V128 vector type.

const (
	UnsignedTypeI32 UnsignedType = iota
	UnsignedTypeI64
	UnsignedTypeF32
	UnsignedTypeF64
	UnsignedTypeV128
	UnsignedTypeUnknown
)

func (UnsignedType) String

func (s UnsignedType) String() (ret string)

String implements fmt.Stringer.

type V128CmpType

type V128CmpType = byte

V128CmpType represents a type of vector comparison operation.

const (
	// V128CmpTypeI8x16Eq corresponds to wasm.OpcodeVecI8x16EqName.
	V128CmpTypeI8x16Eq V128CmpType = iota
	// V128CmpTypeI8x16Ne corresponds to wasm.OpcodeVecI8x16NeName.
	V128CmpTypeI8x16Ne
	// V128CmpTypeI8x16LtS corresponds to wasm.OpcodeVecI8x16LtSName.
	V128CmpTypeI8x16LtS
	// V128CmpTypeI8x16LtU corresponds to wasm.OpcodeVecI8x16LtUName.
	V128CmpTypeI8x16LtU
	// V128CmpTypeI8x16GtS corresponds to wasm.OpcodeVecI8x16GtSName.
	V128CmpTypeI8x16GtS
	// V128CmpTypeI8x16GtU corresponds to wasm.OpcodeVecI8x16GtUName.
	V128CmpTypeI8x16GtU
	// V128CmpTypeI8x16LeS corresponds to wasm.OpcodeVecI8x16LeSName.
	V128CmpTypeI8x16LeS
	// V128CmpTypeI8x16LeU corresponds to wasm.OpcodeVecI8x16LeUName.
	V128CmpTypeI8x16LeU
	// V128CmpTypeI8x16GeS corresponds to wasm.OpcodeVecI8x16GeSName.
	V128CmpTypeI8x16GeS
	// V128CmpTypeI8x16GeU corresponds to wasm.OpcodeVecI8x16GeUName.
	V128CmpTypeI8x16GeU
	// V128CmpTypeI16x8Eq corresponds to wasm.OpcodeVecI16x8EqName.
	V128CmpTypeI16x8Eq
	// V128CmpTypeI16x8Ne corresponds to wasm.OpcodeVecI16x8NeName.
	V128CmpTypeI16x8Ne
	// V128CmpTypeI16x8LtS corresponds to wasm.OpcodeVecI16x8LtSName.
	V128CmpTypeI16x8LtS
	// V128CmpTypeI16x8LtU corresponds to wasm.OpcodeVecI16x8LtUName.
	V128CmpTypeI16x8LtU
	// V128CmpTypeI16x8GtS corresponds to wasm.OpcodeVecI16x8GtSName.
	V128CmpTypeI16x8GtS
	// V128CmpTypeI16x8GtU corresponds to wasm.OpcodeVecI16x8GtUName.
	V128CmpTypeI16x8GtU
	// V128CmpTypeI16x8LeS corresponds to wasm.OpcodeVecI16x8LeSName.
	V128CmpTypeI16x8LeS
	// V128CmpTypeI16x8LeU corresponds to wasm.OpcodeVecI16x8LeUName.
	V128CmpTypeI16x8LeU
	// V128CmpTypeI16x8GeS corresponds to wasm.OpcodeVecI16x8GeSName.
	V128CmpTypeI16x8GeS
	// V128CmpTypeI16x8GeU corresponds to wasm.OpcodeVecI16x8GeUName.
	V128CmpTypeI16x8GeU
	// V128CmpTypeI32x4Eq corresponds to wasm.OpcodeVecI32x4EqName.
	V128CmpTypeI32x4Eq
	// V128CmpTypeI32x4Ne corresponds to wasm.OpcodeVecI32x4NeName.
	V128CmpTypeI32x4Ne
	// V128CmpTypeI32x4LtS corresponds to wasm.OpcodeVecI32x4LtSName.
	V128CmpTypeI32x4LtS
	// V128CmpTypeI32x4LtU corresponds to wasm.OpcodeVecI32x4LtUName.
	V128CmpTypeI32x4LtU
	// V128CmpTypeI32x4GtS corresponds to wasm.OpcodeVecI32x4GtSName.
	V128CmpTypeI32x4GtS
	// V128CmpTypeI32x4GtU corresponds to wasm.OpcodeVecI32x4GtUName.
	V128CmpTypeI32x4GtU
	// V128CmpTypeI32x4LeS corresponds to wasm.OpcodeVecI32x4LeSName.
	V128CmpTypeI32x4LeS
	// V128CmpTypeI32x4LeU corresponds to wasm.OpcodeVecI32x4LeUName.
	V128CmpTypeI32x4LeU
	// V128CmpTypeI32x4GeS corresponds to wasm.OpcodeVecI32x4GeSName.
	V128CmpTypeI32x4GeS
	// V128CmpTypeI32x4GeU corresponds to wasm.OpcodeVecI32x4GeUName.
	V128CmpTypeI32x4GeU
	// V128CmpTypeI64x2Eq corresponds to wasm.OpcodeVecI64x2EqName.
	V128CmpTypeI64x2Eq
	// V128CmpTypeI64x2Ne corresponds to wasm.OpcodeVecI64x2NeName.
	V128CmpTypeI64x2Ne
	// V128CmpTypeI64x2LtS corresponds to wasm.OpcodeVecI64x2LtSName.
	V128CmpTypeI64x2LtS
	// V128CmpTypeI64x2GtS corresponds to wasm.OpcodeVecI64x2GtSName.
	V128CmpTypeI64x2GtS
	// V128CmpTypeI64x2LeS corresponds to wasm.OpcodeVecI64x2LeSName.
	V128CmpTypeI64x2LeS
	// V128CmpTypeI64x2GeS corresponds to wasm.OpcodeVecI64x2GeSName.
	V128CmpTypeI64x2GeS
	// V128CmpTypeF32x4Eq corresponds to wasm.OpcodeVecF32x4EqName.
	V128CmpTypeF32x4Eq
	// V128CmpTypeF32x4Ne corresponds to wasm.OpcodeVecF32x4NeName.
	V128CmpTypeF32x4Ne
	// V128CmpTypeF32x4Lt corresponds to wasm.OpcodeVecF32x4LtName.
	V128CmpTypeF32x4Lt
	// V128CmpTypeF32x4Gt corresponds to wasm.OpcodeVecF32x4GtName.
	V128CmpTypeF32x4Gt
	// V128CmpTypeF32x4Le corresponds to wasm.OpcodeVecF32x4LeName.
	V128CmpTypeF32x4Le
	// V128CmpTypeF32x4Ge corresponds to wasm.OpcodeVecF32x4GeName.
	V128CmpTypeF32x4Ge
	// V128CmpTypeF64x2Eq corresponds to wasm.OpcodeVecF64x2EqName.
	V128CmpTypeF64x2Eq
	// V128CmpTypeF64x2Ne corresponds to wasm.OpcodeVecF64x2NeName.
	V128CmpTypeF64x2Ne
	// V128CmpTypeF64x2Lt corresponds to wasm.OpcodeVecF64x2LtName.
	V128CmpTypeF64x2Lt
	// V128CmpTypeF64x2Gt corresponds to wasm.OpcodeVecF64x2GtName.
	V128CmpTypeF64x2Gt
	// V128CmpTypeF64x2Le corresponds to wasm.OpcodeVecF64x2LeName.
	V128CmpTypeF64x2Le
	// V128CmpTypeF64x2Ge corresponds to wasm.OpcodeVecF64x2GeName.
	V128CmpTypeF64x2Ge
)

type V128LoadType

type V128LoadType = byte

V128LoadType represents a type of wasm.OpcodeVecV128Load* instructions.

const (
	// V128LoadType128 corresponds to wasm.OpcodeVecV128LoadName.
	V128LoadType128 V128LoadType = iota
	// V128LoadType8x8s corresponds to wasm.OpcodeVecV128Load8x8SName.
	V128LoadType8x8s
	// V128LoadType8x8u corresponds to wasm.OpcodeVecV128Load8x8UName.
	V128LoadType8x8u
	// V128LoadType16x4s corresponds to wasm.OpcodeVecV128Load16x4SName
	V128LoadType16x4s
	// V128LoadType16x4u corresponds to wasm.OpcodeVecV128Load16x4UName
	V128LoadType16x4u
	// V128LoadType32x2s corresponds to wasm.OpcodeVecV128Load32x2SName
	V128LoadType32x2s
	// V128LoadType32x2u corresponds to wasm.OpcodeVecV128Load32x2UName
	V128LoadType32x2u
	// V128LoadType8Splat corresponds to wasm.OpcodeVecV128Load8SplatName
	V128LoadType8Splat
	// V128LoadType16Splat corresponds to wasm.OpcodeVecV128Load16SplatName
	V128LoadType16Splat
	// V128LoadType32Splat corresponds to wasm.OpcodeVecV128Load32SplatName
	V128LoadType32Splat
	// V128LoadType64Splat corresponds to wasm.OpcodeVecV128Load64SplatName
	V128LoadType64Splat
	// V128LoadType32zero corresponds to wasm.OpcodeVecV128Load32zeroName
	V128LoadType32zero
	// V128LoadType64zero corresponds to wasm.OpcodeVecV128Load64zeroName
	V128LoadType64zero
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL