wazeroir: rm nullary Operations, move interpreterOp to UnionOperation (#1310)

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
Edoardo Vacchi
2023-03-30 09:57:41 +02:00
committed by GitHub
parent 035c0ffaf4
commit 37135067b6
7 changed files with 708 additions and 822 deletions

View File

@@ -1094,8 +1094,6 @@ func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (*code, e
switch o := op.(type) {
case wazeroir.OperationLabel:
// Label op is already handled ^^.
case wazeroir.OperationUnreachable:
err = cmp.compileUnreachable()
case wazeroir.OperationBr:
err = cmp.compileBr(o)
case wazeroir.OperationBrIf:
@@ -1134,10 +1132,6 @@ func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (*code, e
err = cmp.compileStore16(o)
case wazeroir.OperationStore32:
err = cmp.compileStore32(o)
case wazeroir.OperationMemorySize:
err = cmp.compileMemorySize()
case wazeroir.OperationMemoryGrow:
err = cmp.compileMemoryGrow()
case wazeroir.OperationConstI32:
err = cmp.compileConstI32(o)
case wazeroir.OperationConstI64:
@@ -1210,44 +1204,16 @@ func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (*code, e
err = cmp.compileMax(o)
case wazeroir.OperationCopysign:
err = cmp.compileCopysign(o)
case wazeroir.OperationI32WrapFromI64:
err = cmp.compileI32WrapFromI64()
case wazeroir.OperationITruncFromF:
err = cmp.compileITruncFromF(o)
case wazeroir.OperationFConvertFromI:
err = cmp.compileFConvertFromI(o)
case wazeroir.OperationF32DemoteFromF64:
err = cmp.compileF32DemoteFromF64()
case wazeroir.OperationF64PromoteFromF32:
err = cmp.compileF64PromoteFromF32()
case wazeroir.OperationI32ReinterpretFromF32:
err = cmp.compileI32ReinterpretFromF32()
case wazeroir.OperationI64ReinterpretFromF64:
err = cmp.compileI64ReinterpretFromF64()
case wazeroir.OperationF32ReinterpretFromI32:
err = cmp.compileF32ReinterpretFromI32()
case wazeroir.OperationF64ReinterpretFromI64:
err = cmp.compileF64ReinterpretFromI64()
case wazeroir.OperationExtend:
err = cmp.compileExtend(o)
case wazeroir.OperationSignExtend32From8:
err = cmp.compileSignExtend32From8()
case wazeroir.OperationSignExtend32From16:
err = cmp.compileSignExtend32From16()
case wazeroir.OperationSignExtend64From8:
err = cmp.compileSignExtend64From8()
case wazeroir.OperationSignExtend64From16:
err = cmp.compileSignExtend64From16()
case wazeroir.OperationSignExtend64From32:
err = cmp.compileSignExtend64From32()
case wazeroir.OperationDataDrop:
err = cmp.compileDataDrop(o)
case wazeroir.OperationMemoryInit:
err = cmp.compileMemoryInit(o)
case wazeroir.OperationMemoryCopy:
err = cmp.compileMemoryCopy()
case wazeroir.OperationMemoryFill:
err = cmp.compileMemoryFill()
case wazeroir.OperationTableInit:
err = cmp.compileTableInit(o)
case wazeroir.OperationTableCopy:
@@ -1368,8 +1334,54 @@ func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (*code, e
err = cmp.compileV128Narrow(o)
case wazeroir.OperationV128ITruncSatFromF:
err = cmp.compileV128ITruncSatFromF(o)
case wazeroir.OperationBuiltinFunctionCheckExitCode:
err = cmp.compileBuiltinFunctionCheckExitCode()
case wazeroir.UnionOperation:
switch op.Kind() {
case wazeroir.OperationKindUnreachable:
err = cmp.compileUnreachable()
case wazeroir.OperationKindMemorySize:
err = cmp.compileMemorySize()
case wazeroir.OperationKindMemoryGrow:
err = cmp.compileMemoryGrow()
case wazeroir.OperationKindI32WrapFromI64:
err = cmp.compileI32WrapFromI64()
case wazeroir.OperationKindF32DemoteFromF64:
err = cmp.compileF32DemoteFromF64()
case wazeroir.OperationKindF64PromoteFromF32:
err = cmp.compileF64PromoteFromF32()
case wazeroir.OperationKindI32ReinterpretFromF32:
err = cmp.compileI32ReinterpretFromF32()
case wazeroir.OperationKindI64ReinterpretFromF64:
err = cmp.compileI64ReinterpretFromF64()
case wazeroir.OperationKindF32ReinterpretFromI32:
err = cmp.compileF32ReinterpretFromI32()
case wazeroir.OperationKindF64ReinterpretFromI64:
err = cmp.compileF64ReinterpretFromI64()
// OperationExtend
case wazeroir.OperationKindSignExtend32From8:
err = cmp.compileSignExtend32From8()
case wazeroir.OperationKindSignExtend32From16:
err = cmp.compileSignExtend32From16()
case wazeroir.OperationKindSignExtend64From8:
err = cmp.compileSignExtend64From8()
case wazeroir.OperationKindSignExtend64From16:
err = cmp.compileSignExtend64From16()
case wazeroir.OperationKindSignExtend64From32:
err = cmp.compileSignExtend64From32()
// Drop..Init
//
case wazeroir.OperationKindMemoryCopy:
err = cmp.compileMemoryCopy()
case wazeroir.OperationKindMemoryFill:
err = cmp.compileMemoryFill()
// ...
case wazeroir.OperationKindBuiltinFunctionCheckExitCode:
err = cmp.compileBuiltinFunctionCheckExitCode()
}
default:
err = errors.New("unsupported")
}

File diff suppressed because it is too large Load Diff

View File

@@ -325,29 +325,29 @@ func TestInterpreter_NonTrappingFloatToIntConversion(t *testing.T) {
for i := 0; i < casenum; i++ {
i := i
t.Run(strconv.Itoa(i), func(t *testing.T) {
var body []*interpreterOp
var body []*wazeroir.UnionOperation
if in32bit {
body = append(body, &interpreterOp{
kind: wazeroir.OperationKindConstF32,
u1: uint64(math.Float32bits(tc.input32bit[i])),
body = append(body, &wazeroir.UnionOperation{
OpKind: wazeroir.OperationKindConstF32,
U1: uint64(math.Float32bits(tc.input32bit[i])),
})
} else {
body = append(body, &interpreterOp{
kind: wazeroir.OperationKindConstF64,
u1: uint64(math.Float64bits(tc.input64bit[i])),
body = append(body, &wazeroir.UnionOperation{
OpKind: wazeroir.OperationKindConstF64,
U1: uint64(math.Float64bits(tc.input64bit[i])),
})
}
body = append(body, &interpreterOp{
kind: wazeroir.OperationKindITruncFromF,
b1: byte(tc.inputType),
b2: byte(tc.outputType),
b3: true, // NonTrapping = true.
body = append(body, &wazeroir.UnionOperation{
OpKind: wazeroir.OperationKindITruncFromF,
B1: byte(tc.inputType),
B2: byte(tc.outputType),
B3: true, // NonTrapping = true.
})
// Return from function.
body = append(body,
&interpreterOp{kind: wazeroir.OperationKindBr, u1: uint64(math.MaxUint64)},
&wazeroir.UnionOperation{OpKind: wazeroir.OperationKindBr, U1: uint64(math.MaxUint64)},
)
ce := &callEngine{}
@@ -416,10 +416,10 @@ func TestInterpreter_CallEngine_callNativeFunc_signExtend(t *testing.T) {
ce := &callEngine{}
f := &function{
moduleInstance: &wasm.ModuleInstance{Engine: &moduleEngine{}},
parent: &code{body: []*interpreterOp{
{kind: wazeroir.OperationKindConstI32, u1: uint64(uint32(tc.in))},
{kind: translateToIROperationKind(tc.opcode)},
{kind: wazeroir.OperationKindBr, u1: uint64(math.MaxUint64)},
parent: &code{body: []*wazeroir.UnionOperation{
{OpKind: wazeroir.OperationKindConstI32, U1: uint64(uint32(tc.in))},
{OpKind: translateToIROperationKind(tc.opcode)},
{OpKind: wazeroir.OperationKindBr, U1: uint64(math.MaxUint64)},
}},
}
ce.callNativeFunc(testCtx, &wasm.ModuleInstance{}, f)
@@ -470,10 +470,10 @@ func TestInterpreter_CallEngine_callNativeFunc_signExtend(t *testing.T) {
ce := &callEngine{}
f := &function{
moduleInstance: &wasm.ModuleInstance{Engine: &moduleEngine{}},
parent: &code{body: []*interpreterOp{
{kind: wazeroir.OperationKindConstI64, u1: uint64(tc.in)},
{kind: translateToIROperationKind(tc.opcode)},
{kind: wazeroir.OperationKindBr, u1: uint64(math.MaxUint64)},
parent: &code{body: []*wazeroir.UnionOperation{
{OpKind: wazeroir.OperationKindConstI64, U1: uint64(tc.in)},
{OpKind: translateToIROperationKind(tc.opcode)},
{OpKind: wazeroir.OperationKindBr, U1: uint64(math.MaxUint64)},
}},
}
ce.callNativeFunc(testCtx, &wasm.ModuleInstance{}, f)
@@ -543,8 +543,8 @@ func TestInterpreter_Compile(t *testing.T) {
func TestEngine_CachedcodesPerModule(t *testing.T) {
e := et.NewEngine(api.CoreFeaturesV1).(*engine)
exp := []*code{
{body: []*interpreterOp{}},
{body: []*interpreterOp{}},
{body: []*wazeroir.UnionOperation{}},
{body: []*wazeroir.UnionOperation{}},
}
m := &wasm.Module{}

View File

@@ -37,7 +37,7 @@ type (
func (c *controlFrame) ensureContinuation() {
// Make sure that if the frame is block and doesn't have continuation,
// change the kind so we can emit the continuation block
// change the OpKind so we can emit the continuation block
// later when we reach the end instruction of this frame.
if c.kind == controlFrameKindBlockWithoutContinuationLabel {
c.kind = controlFrameKindBlockWithContinuationLabel
@@ -425,7 +425,7 @@ func (c *compiler) handleInstruction() error {
operatorSwitch:
switch op {
case wasm.OpcodeUnreachable:
c.emit(OperationUnreachable{})
c.emit(NewOperationUnreachable())
c.markUnreachable()
case wasm.OpcodeNop:
// Nop is noop!
@@ -497,7 +497,7 @@ operatorSwitch:
// exist. However, in reality, that shouldn't be an issue since such "noop" loop header will highly likely be
// optimized out by almost all guest language compilers which have the control flow optimization passes.
if c.ensureTermination {
c.emit(OperationBuiltinFunctionCheckExitCode{})
c.emit(NewOperationBuiltinFunctionCheckExitCode())
}
case wasm.OpcodeIf:
c.br.Reset(c.body[c.pc+1:])
@@ -569,7 +569,7 @@ operatorSwitch:
break operatorSwitch
}
// Change the kind of this If block, indicating that
// Change the OpKind of this If block, indicating that
// the if has else block.
frame.kind = controlFrameKindIfWithElse
@@ -647,7 +647,7 @@ operatorSwitch:
c.stackPush(wasmValueTypeToUnsignedType(t))
}
// Emit the instructions according to the kind of the current control frame.
// Emit the instructions according to the OpKind of the current control frame.
switch frame.kind {
case controlFrameKindFunction:
if !c.controlFrames.empty() {
@@ -688,7 +688,7 @@ operatorSwitch:
)
default:
// Should never happen. If so, there's a bug in the translation.
panic(fmt.Errorf("bug: invalid control frame kind: 0x%x", frame.kind))
panic(fmt.Errorf("bug: invalid control frame OpKind: 0x%x", frame.kind))
}
case wasm.OpcodeBr:
@@ -1093,13 +1093,13 @@ operatorSwitch:
c.result.UsesMemory = true
c.pc++ // Skip the reserved one byte.
c.emit(
OperationMemorySize{},
NewOperationMemorySize(),
)
case wasm.OpcodeMemoryGrow:
c.result.UsesMemory = true
c.pc++ // Skip the reserved one byte.
c.emit(
OperationMemoryGrow{},
NewOperationMemoryGrow(),
)
case wasm.OpcodeI32Const:
val, num, err := leb128.LoadInt32(c.body[c.pc+1:])
@@ -1525,7 +1525,7 @@ operatorSwitch:
)
case wasm.OpcodeI32WrapI64:
c.emit(
OperationI32WrapFromI64{},
NewOperationI32WrapFromI64(),
)
case wasm.OpcodeI32TruncF32S:
c.emit(
@@ -1585,7 +1585,7 @@ operatorSwitch:
)
case wasm.OpcodeF32DemoteF64:
c.emit(
OperationF32DemoteFromF64{},
NewOperationF32DemoteFromF64(),
)
case wasm.OpcodeF64ConvertI32S:
c.emit(
@@ -1605,43 +1605,43 @@ operatorSwitch:
)
case wasm.OpcodeF64PromoteF32:
c.emit(
OperationF64PromoteFromF32{},
NewOperationF64PromoteFromF32(),
)
case wasm.OpcodeI32ReinterpretF32:
c.emit(
OperationI32ReinterpretFromF32{},
NewOperationI32ReinterpretFromF32(),
)
case wasm.OpcodeI64ReinterpretF64:
c.emit(
OperationI64ReinterpretFromF64{},
NewOperationI64ReinterpretFromF64(),
)
case wasm.OpcodeF32ReinterpretI32:
c.emit(
OperationF32ReinterpretFromI32{},
NewOperationF32ReinterpretFromI32(),
)
case wasm.OpcodeF64ReinterpretI64:
c.emit(
OperationF64ReinterpretFromI64{},
NewOperationF64ReinterpretFromI64(),
)
case wasm.OpcodeI32Extend8S:
c.emit(
OperationSignExtend32From8{},
NewOperationSignExtend32From8(),
)
case wasm.OpcodeI32Extend16S:
c.emit(
OperationSignExtend32From16{},
NewOperationSignExtend32From16(),
)
case wasm.OpcodeI64Extend8S:
c.emit(
OperationSignExtend64From8{},
NewOperationSignExtend64From8(),
)
case wasm.OpcodeI64Extend16S:
c.emit(
OperationSignExtend64From16{},
NewOperationSignExtend64From16(),
)
case wasm.OpcodeI64Extend32S:
c.emit(
OperationSignExtend64From32{},
NewOperationSignExtend64From32(),
)
case wasm.OpcodeRefFunc:
c.pc++
@@ -1747,13 +1747,13 @@ operatorSwitch:
c.result.UsesMemory = true
c.pc += 2 // +2 to skip two memory indexes which are fixed to zero.
c.emit(
OperationMemoryCopy{},
NewOperationMemoryCopy(),
)
case wasm.OpcodeMiscMemoryFill:
c.result.UsesMemory = true
c.pc += 1 // +1 to skip the memory index which is fixed to zero.
c.emit(
OperationMemoryFill{},
NewOperationMemoryFill(),
)
case wasm.OpcodeMiscTableInit:
elemIndex, num, err := leb128.LoadUint32(c.body[c.pc+1:])

View File

@@ -189,8 +189,8 @@ func TestCompile(t *testing.T) {
},
expected: &CompilationResult{
Operations: []Operation{ // begin with params: [$delta]
OperationPick{Depth: 0}, // [$delta, $delta]
OperationMemoryGrow{}, // [$delta, $old_size]
OperationPick{Depth: 0}, // [$delta, $delta]
NewOperationMemoryGrow(), // [$delta, $old_size]
OperationDrop{Depth: &InclusiveRange{Start: 1, End: 1}}, // [$old_size]
OperationBr{Target: Label{Kind: LabelKindReturn}}, // return!
},
@@ -711,7 +711,7 @@ func TestCompile_SignExtensionOps(t *testing.T) {
expected := &CompilationResult{
Operations: []Operation{ // begin with params: [$0]
OperationPick{Depth: 0}, // [$0, $0]
OperationSignExtend32From8{}, // [$0, i32.extend8_s($0)]
NewOperationSignExtend32From8(), // [$0, i32.extend8_s($0)]
OperationDrop{Depth: &InclusiveRange{Start: 1, End: 1}}, // [i32.extend8_s($0)]
OperationBr{Target: Label{Kind: LabelKindReturn}}, // return!
},

View File

@@ -132,12 +132,12 @@ func (s SignedType) String() (ret string) {
// Operation is the interface implemented by each individual operation.
type Operation interface {
// Kind returns the kind of the implementation.
// Kind returns the OpKind of the implementation.
Kind() OperationKind
fmt.Stringer
}
// OperationKind is the kind of each implementation of Operation interface.
// OperationKind is the OpKind of each implementation of Operation interface.
type OperationKind uint16
// String implements fmt.Stringer.
@@ -428,287 +428,287 @@ func (o OperationKind) String() (ret string) {
}
const (
// OperationKindUnreachable is the kind for OperationUnreachable.
// OperationKindUnreachable is the OpKind for OperationUnreachable.
OperationKindUnreachable OperationKind = iota
// OperationKindLabel is the kind for OperationLabel.
// OperationKindLabel is the OpKind for OperationLabel.
OperationKindLabel
// OperationKindBr is the kind for OperationBr.
// OperationKindBr is the OpKind for OperationBr.
OperationKindBr
// OperationKindBrIf is the kind for OperationBrIf.
// OperationKindBrIf is the OpKind for OperationBrIf.
OperationKindBrIf
// OperationKindBrTable is the kind for OperationBrTable.
// OperationKindBrTable is the OpKind for OperationBrTable.
OperationKindBrTable
// OperationKindCall is the kind for OperationCall.
// OperationKindCall is the OpKind for OperationCall.
OperationKindCall
// OperationKindCallIndirect is the kind for OperationCallIndirect.
// OperationKindCallIndirect is the OpKind for OperationCallIndirect.
OperationKindCallIndirect
// OperationKindDrop is the kind for OperationDrop.
// OperationKindDrop is the OpKind for OperationDrop.
OperationKindDrop
// OperationKindSelect is the kind for OperationSelect.
// OperationKindSelect is the OpKind for OperationSelect.
OperationKindSelect
// OperationKindPick is the kind for OperationPick.
// OperationKindPick is the OpKind for OperationPick.
OperationKindPick
// OperationKindSet is the kind for OperationSet.
// OperationKindSet is the OpKind for OperationSet.
OperationKindSet
// OperationKindGlobalGet is the kind for OperationGlobalGet.
// OperationKindGlobalGet is the OpKind for OperationGlobalGet.
OperationKindGlobalGet
// OperationKindGlobalSet is the kind for OperationGlobalSet.
// OperationKindGlobalSet is the OpKind for OperationGlobalSet.
OperationKindGlobalSet
// OperationKindLoad is the kind for OperationLoad.
// OperationKindLoad is the OpKind for OperationLoad.
OperationKindLoad
// OperationKindLoad8 is the kind for OperationLoad8.
// OperationKindLoad8 is the OpKind for OperationLoad8.
OperationKindLoad8
// OperationKindLoad16 is the kind for OperationLoad16.
// OperationKindLoad16 is the OpKind for OperationLoad16.
OperationKindLoad16
// OperationKindLoad32 is the kind for OperationLoad32.
// OperationKindLoad32 is the OpKind for OperationLoad32.
OperationKindLoad32
// OperationKindStore is the kind for OperationStore.
// OperationKindStore is the OpKind for OperationStore.
OperationKindStore
// OperationKindStore8 is the kind for OperationStore8.
// OperationKindStore8 is the OpKind for OperationStore8.
OperationKindStore8
// OperationKindStore16 is the kind for OperationStore16.
// OperationKindStore16 is the OpKind for OperationStore16.
OperationKindStore16
// OperationKindStore32 is the kind for OperationStore32.
// OperationKindStore32 is the OpKind for OperationStore32.
OperationKindStore32
// OperationKindMemorySize is the kind for OperationMemorySize.
// OperationKindMemorySize is the OpKind for OperationMemorySize.
OperationKindMemorySize
// OperationKindMemoryGrow is the kind for OperationMemoryGrow.
// OperationKindMemoryGrow is the OpKind for OperationMemoryGrow.
OperationKindMemoryGrow
// OperationKindConstI32 is the kind for OperationConstI32.
// OperationKindConstI32 is the OpKind for OperationConstI32.
OperationKindConstI32
// OperationKindConstI64 is the kind for OperationConstI64.
// OperationKindConstI64 is the OpKind for OperationConstI64.
OperationKindConstI64
// OperationKindConstF32 is the kind for OperationConstF32.
// OperationKindConstF32 is the OpKind for OperationConstF32.
OperationKindConstF32
// OperationKindConstF64 is the kind for OperationConstF64.
// OperationKindConstF64 is the OpKind for OperationConstF64.
OperationKindConstF64
// OperationKindEq is the kind for OperationEq.
// OperationKindEq is the OpKind for OperationEq.
OperationKindEq
// OperationKindNe is the kind for OperationNe.
// OperationKindNe is the OpKind for OperationNe.
OperationKindNe
// OperationKindEqz is the kind for OperationEqz.
// OperationKindEqz is the OpKind for OperationEqz.
OperationKindEqz
// OperationKindLt is the kind for OperationLt.
// OperationKindLt is the OpKind for OperationLt.
OperationKindLt
// OperationKindGt is the kind for OperationGt.
// OperationKindGt is the OpKind for OperationGt.
OperationKindGt
// OperationKindLe is the kind for OperationLe.
// OperationKindLe is the OpKind for OperationLe.
OperationKindLe
// OperationKindGe is the kind for OperationGe.
// OperationKindGe is the OpKind for OperationGe.
OperationKindGe
// OperationKindAdd is the kind for OperationAdd.
// OperationKindAdd is the OpKind for OperationAdd.
OperationKindAdd
// OperationKindSub is the kind for OperationSub.
// OperationKindSub is the OpKind for OperationSub.
OperationKindSub
// OperationKindMul is the kind for OperationMul.
// OperationKindMul is the OpKind for OperationMul.
OperationKindMul
// OperationKindClz is the kind for OperationClz.
// OperationKindClz is the OpKind for OperationClz.
OperationKindClz
// OperationKindCtz is the kind for OperationCtz.
// OperationKindCtz is the OpKind for OperationCtz.
OperationKindCtz
// OperationKindPopcnt is the kind for OperationPopcnt.
// OperationKindPopcnt is the OpKind for OperationPopcnt.
OperationKindPopcnt
// OperationKindDiv is the kind for OperationDiv.
// OperationKindDiv is the OpKind for OperationDiv.
OperationKindDiv
// OperationKindRem is the kind for OperationRem.
// OperationKindRem is the OpKind for OperationRem.
OperationKindRem
// OperationKindAnd is the kind for OperationAnd.
// OperationKindAnd is the OpKind for OperationAnd.
OperationKindAnd
// OperationKindOr is the kind for OperationOr.
// OperationKindOr is the OpKind for OperationOr.
OperationKindOr
// OperationKindXor is the kind for OperationXor.
// OperationKindXor is the OpKind for OperationXor.
OperationKindXor
// OperationKindShl is the kind for OperationShl.
// OperationKindShl is the OpKind for OperationShl.
OperationKindShl
// OperationKindShr is the kind for OperationShr.
// OperationKindShr is the OpKind for OperationShr.
OperationKindShr
// OperationKindRotl is the kind for OperationRotl.
// OperationKindRotl is the OpKind for OperationRotl.
OperationKindRotl
// OperationKindRotr is the kind for OperationRotr.
// OperationKindRotr is the OpKind for OperationRotr.
OperationKindRotr
// OperationKindAbs is the kind for OperationAbs.
// OperationKindAbs is the OpKind for OperationAbs.
OperationKindAbs
// OperationKindNeg is the kind for OperationNeg.
// OperationKindNeg is the OpKind for OperationNeg.
OperationKindNeg
// OperationKindCeil is the kind for OperationCeil.
// OperationKindCeil is the OpKind for OperationCeil.
OperationKindCeil
// OperationKindFloor is the kind for OperationFloor.
// OperationKindFloor is the OpKind for OperationFloor.
OperationKindFloor
// OperationKindTrunc is the kind for OperationTrunc.
// OperationKindTrunc is the OpKind for OperationTrunc.
OperationKindTrunc
// OperationKindNearest is the kind for OperationNearest.
// OperationKindNearest is the OpKind for OperationNearest.
OperationKindNearest
// OperationKindSqrt is the kind for OperationSqrt.
// OperationKindSqrt is the OpKind for OperationSqrt.
OperationKindSqrt
// OperationKindMin is the kind for OperationMin.
// OperationKindMin is the OpKind for OperationMin.
OperationKindMin
// OperationKindMax is the kind for OperationMax.
// OperationKindMax is the OpKind for OperationMax.
OperationKindMax
// OperationKindCopysign is the kind for OperationCopysign.
// OperationKindCopysign is the OpKind for OperationCopysign.
OperationKindCopysign
// OperationKindI32WrapFromI64 is the kind for OperationI32WrapFromI64.
// OperationKindI32WrapFromI64 is the OpKind for OperationI32WrapFromI64.
OperationKindI32WrapFromI64
// OperationKindITruncFromF is the kind for OperationITruncFromF.
// OperationKindITruncFromF is the OpKind for OperationITruncFromF.
OperationKindITruncFromF
// OperationKindFConvertFromI is the kind for OperationFConvertFromI.
// OperationKindFConvertFromI is the OpKind for OperationFConvertFromI.
OperationKindFConvertFromI
// OperationKindF32DemoteFromF64 is the kind for OperationF32DemoteFromF64.
// OperationKindF32DemoteFromF64 is the OpKind for OperationF32DemoteFromF64.
OperationKindF32DemoteFromF64
// OperationKindF64PromoteFromF32 is the kind for OperationF64PromoteFromF32.
// OperationKindF64PromoteFromF32 is the OpKind for OperationF64PromoteFromF32.
OperationKindF64PromoteFromF32
// OperationKindI32ReinterpretFromF32 is the kind for OperationI32ReinterpretFromF32.
// OperationKindI32ReinterpretFromF32 is the OpKind for OperationI32ReinterpretFromF32.
OperationKindI32ReinterpretFromF32
// OperationKindI64ReinterpretFromF64 is the kind for OperationI64ReinterpretFromF64.
// OperationKindI64ReinterpretFromF64 is the OpKind for OperationI64ReinterpretFromF64.
OperationKindI64ReinterpretFromF64
// OperationKindF32ReinterpretFromI32 is the kind for OperationF32ReinterpretFromI32.
// OperationKindF32ReinterpretFromI32 is the OpKind for OperationF32ReinterpretFromI32.
OperationKindF32ReinterpretFromI32
// OperationKindF64ReinterpretFromI64 is the kind for OperationF64ReinterpretFromI64.
// OperationKindF64ReinterpretFromI64 is the OpKind for OperationF64ReinterpretFromI64.
OperationKindF64ReinterpretFromI64
// OperationKindExtend is the kind for OperationExtend.
// OperationKindExtend is the OpKind for OperationExtend.
OperationKindExtend
// OperationKindSignExtend32From8 is the kind for OperationSignExtend32From8.
// OperationKindSignExtend32From8 is the OpKind for OperationSignExtend32From8.
OperationKindSignExtend32From8
// OperationKindSignExtend32From16 is the kind for OperationSignExtend32From16.
// OperationKindSignExtend32From16 is the OpKind for OperationSignExtend32From16.
OperationKindSignExtend32From16
// OperationKindSignExtend64From8 is the kind for OperationSignExtend64From8.
// OperationKindSignExtend64From8 is the OpKind for OperationSignExtend64From8.
OperationKindSignExtend64From8
// OperationKindSignExtend64From16 is the kind for OperationSignExtend64From16.
// OperationKindSignExtend64From16 is the OpKind for OperationSignExtend64From16.
OperationKindSignExtend64From16
// OperationKindSignExtend64From32 is the kind for OperationSignExtend64From32.
// OperationKindSignExtend64From32 is the OpKind for OperationSignExtend64From32.
OperationKindSignExtend64From32
// OperationKindMemoryInit is the kind for OperationMemoryInit.
// OperationKindMemoryInit is the OpKind for OperationMemoryInit.
OperationKindMemoryInit
// OperationKindDataDrop is the kind for OperationDataDrop.
// OperationKindDataDrop is the OpKind for OperationDataDrop.
OperationKindDataDrop
// OperationKindMemoryCopy is the kind for OperationMemoryCopy.
// OperationKindMemoryCopy is the OpKind for OperationMemoryCopy.
OperationKindMemoryCopy
// OperationKindMemoryFill is the kind for OperationMemoryFill.
// OperationKindMemoryFill is the OpKind for OperationMemoryFill.
OperationKindMemoryFill
// OperationKindTableInit is the kind for OperationTableInit.
// OperationKindTableInit is the OpKind for OperationTableInit.
OperationKindTableInit
// OperationKindElemDrop is the kind for OperationElemDrop.
// OperationKindElemDrop is the OpKind for OperationElemDrop.
OperationKindElemDrop
// OperationKindTableCopy is the kind for OperationTableCopy.
// OperationKindTableCopy is the OpKind for OperationTableCopy.
OperationKindTableCopy
// OperationKindRefFunc is the kind for OperationRefFunc.
// OperationKindRefFunc is the OpKind for OperationRefFunc.
OperationKindRefFunc
// OperationKindTableGet is the kind for OperationTableGet.
// OperationKindTableGet is the OpKind for OperationTableGet.
OperationKindTableGet
// OperationKindTableSet is the kind for OperationTableSet.
// OperationKindTableSet is the OpKind for OperationTableSet.
OperationKindTableSet
// OperationKindTableSize is the kind for OperationTableSize.
// OperationKindTableSize is the OpKind for OperationTableSize.
OperationKindTableSize
// OperationKindTableGrow is the kind for OperationTableGrow.
// OperationKindTableGrow is the OpKind for OperationTableGrow.
OperationKindTableGrow
// OperationKindTableFill is the kind for OperationTableFill.
// OperationKindTableFill is the OpKind for OperationTableFill.
OperationKindTableFill
// Vector value related instructions are prefixed by V128.
// OperationKindV128Const is the kind for OperationV128Const.
// OperationKindV128Const is the OpKind for OperationV128Const.
OperationKindV128Const
// OperationKindV128Add is the kind for OperationV128Add.
// OperationKindV128Add is the OpKind for OperationV128Add.
OperationKindV128Add
// OperationKindV128Sub is the kind for OperationV128Sub.
// OperationKindV128Sub is the OpKind for OperationV128Sub.
OperationKindV128Sub
// OperationKindV128Load is the kind for OperationV128Load.
// OperationKindV128Load is the OpKind for OperationV128Load.
OperationKindV128Load
// OperationKindV128LoadLane is the kind for OperationV128LoadLane.
// OperationKindV128LoadLane is the OpKind for OperationV128LoadLane.
OperationKindV128LoadLane
// OperationKindV128Store is the kind for OperationV128Store.
// OperationKindV128Store is the OpKind for OperationV128Store.
OperationKindV128Store
// OperationKindV128StoreLane is the kind for OperationV128StoreLane.
// OperationKindV128StoreLane is the OpKind for OperationV128StoreLane.
OperationKindV128StoreLane
// OperationKindV128ExtractLane is the kind for OperationV128ExtractLane.
// OperationKindV128ExtractLane is the OpKind for OperationV128ExtractLane.
OperationKindV128ExtractLane
// OperationKindV128ReplaceLane is the kind for OperationV128ReplaceLane.
// OperationKindV128ReplaceLane is the OpKind for OperationV128ReplaceLane.
OperationKindV128ReplaceLane
// OperationKindV128Splat is the kind for OperationV128Splat.
// OperationKindV128Splat is the OpKind for OperationV128Splat.
OperationKindV128Splat
// OperationKindV128Shuffle is the kind for OperationV128Shuffle.
// OperationKindV128Shuffle is the OpKind for OperationV128Shuffle.
OperationKindV128Shuffle
// OperationKindV128Swizzle is the kind for OperationV128Swizzle.
// OperationKindV128Swizzle is the OpKind for OperationV128Swizzle.
OperationKindV128Swizzle
// OperationKindV128AnyTrue is the kind for OperationV128AnyTrue.
// OperationKindV128AnyTrue is the OpKind for OperationV128AnyTrue.
OperationKindV128AnyTrue
// OperationKindV128AllTrue is the kind for OperationV128AllTrue.
// OperationKindV128AllTrue is the OpKind for OperationV128AllTrue.
OperationKindV128AllTrue
// OperationKindV128BitMask is the kind for OperationV128BitMask.
// OperationKindV128BitMask is the OpKind for OperationV128BitMask.
OperationKindV128BitMask
// OperationKindV128And is the kind for OperationV128And.
// OperationKindV128And is the OpKind for OperationV128And.
OperationKindV128And
// OperationKindV128Not is the kind for OperationV128Not.
// OperationKindV128Not is the OpKind for OperationV128Not.
OperationKindV128Not
// OperationKindV128Or is the kind for OperationV128Or.
// OperationKindV128Or is the OpKind for OperationV128Or.
OperationKindV128Or
// OperationKindV128Xor is the kind for OperationV128Xor.
// OperationKindV128Xor is the OpKind for OperationV128Xor.
OperationKindV128Xor
// OperationKindV128Bitselect is the kind for OperationV128Bitselect.
// OperationKindV128Bitselect is the OpKind for OperationV128Bitselect.
OperationKindV128Bitselect
// OperationKindV128AndNot is the kind for OperationV128AndNot.
// OperationKindV128AndNot is the OpKind for OperationV128AndNot.
OperationKindV128AndNot
// OperationKindV128Shl is the kind for OperationV128Shl.
// OperationKindV128Shl is the OpKind for OperationV128Shl.
OperationKindV128Shl
// OperationKindV128Shr is the kind for OperationV128Shr.
// OperationKindV128Shr is the OpKind for OperationV128Shr.
OperationKindV128Shr
// OperationKindV128Cmp is the kind for OperationV128Cmp.
// OperationKindV128Cmp is the OpKind for OperationV128Cmp.
OperationKindV128Cmp
// OperationKindV128AddSat is the kind for OperationV128AddSat.
// OperationKindV128AddSat is the OpKind for OperationV128AddSat.
OperationKindV128AddSat
// OperationKindV128SubSat is the kind for OperationV128SubSat.
// OperationKindV128SubSat is the OpKind for OperationV128SubSat.
OperationKindV128SubSat
// OperationKindV128Mul is the kind for OperationV128Mul.
// OperationKindV128Mul is the OpKind for OperationV128Mul.
OperationKindV128Mul
// OperationKindV128Div is the kind for OperationV128Div.
// OperationKindV128Div is the OpKind for OperationV128Div.
OperationKindV128Div
// OperationKindV128Neg is the kind for OperationV128Neg.
// OperationKindV128Neg is the OpKind for OperationV128Neg.
OperationKindV128Neg
// OperationKindV128Sqrt is the kind for OperationV128Sqrt.
// OperationKindV128Sqrt is the OpKind for OperationV128Sqrt.
OperationKindV128Sqrt
// OperationKindV128Abs is the kind for OperationV128Abs.
// OperationKindV128Abs is the OpKind for OperationV128Abs.
OperationKindV128Abs
// OperationKindV128Popcnt is the kind for OperationV128Popcnt.
// OperationKindV128Popcnt is the OpKind for OperationV128Popcnt.
OperationKindV128Popcnt
// OperationKindV128Min is the kind for OperationV128Min.
// OperationKindV128Min is the OpKind for OperationV128Min.
OperationKindV128Min
// OperationKindV128Max is the kind for OperationV128Max.
// OperationKindV128Max is the OpKind for OperationV128Max.
OperationKindV128Max
// OperationKindV128AvgrU is the kind for OperationV128AvgrU.
// OperationKindV128AvgrU is the OpKind for OperationV128AvgrU.
OperationKindV128AvgrU
// OperationKindV128Pmin is the kind for OperationV128Pmin.
// OperationKindV128Pmin is the OpKind for OperationV128Pmin.
OperationKindV128Pmin
// OperationKindV128Pmax is the kind for OperationV128Pmax.
// OperationKindV128Pmax is the OpKind for OperationV128Pmax.
OperationKindV128Pmax
// OperationKindV128Ceil is the kind for OperationV128Ceil.
// OperationKindV128Ceil is the OpKind for OperationV128Ceil.
OperationKindV128Ceil
// OperationKindV128Floor is the kind for OperationV128Floor.
// OperationKindV128Floor is the OpKind for OperationV128Floor.
OperationKindV128Floor
// OperationKindV128Trunc is the kind for OperationV128Trunc.
// OperationKindV128Trunc is the OpKind for OperationV128Trunc.
OperationKindV128Trunc
// OperationKindV128Nearest is the kind for OperationV128Nearest.
// OperationKindV128Nearest is the OpKind for OperationV128Nearest.
OperationKindV128Nearest
// OperationKindV128Extend is the kind for OperationV128Extend.
// OperationKindV128Extend is the OpKind for OperationV128Extend.
OperationKindV128Extend
// OperationKindV128ExtMul is the kind for OperationV128ExtMul.
// OperationKindV128ExtMul is the OpKind for OperationV128ExtMul.
OperationKindV128ExtMul
// OperationKindV128Q15mulrSatS is the kind for OperationV128Q15mulrSatS.
// OperationKindV128Q15mulrSatS is the OpKind for OperationV128Q15mulrSatS.
OperationKindV128Q15mulrSatS
// OperationKindV128ExtAddPairwise is the kind for OperationV128ExtAddPairwise.
// OperationKindV128ExtAddPairwise is the OpKind for OperationV128ExtAddPairwise.
OperationKindV128ExtAddPairwise
// OperationKindV128FloatPromote is the kind for OperationV128FloatPromote.
// OperationKindV128FloatPromote is the OpKind for OperationV128FloatPromote.
OperationKindV128FloatPromote
// OperationKindV128FloatDemote is the kind for OperationV128FloatDemote.
// OperationKindV128FloatDemote is the OpKind for OperationV128FloatDemote.
OperationKindV128FloatDemote
// OperationKindV128FConvertFromI is the kind for OperationV128FConvertFromI.
// OperationKindV128FConvertFromI is the OpKind for OperationV128FConvertFromI.
OperationKindV128FConvertFromI
// OperationKindV128Dot is the kind for OperationV128Dot.
// OperationKindV128Dot is the OpKind for OperationV128Dot.
OperationKindV128Dot
// OperationKindV128Narrow is the kind for OperationV128Narrow.
// OperationKindV128Narrow is the OpKind for OperationV128Narrow.
OperationKindV128Narrow
// OperationKindV128ITruncSatFromF is the kind for OperationV128ITruncSatFromF.
// OperationKindV128ITruncSatFromF is the OpKind for OperationV128ITruncSatFromF.
OperationKindV128ITruncSatFromF
// OperationKindBuiltinFunctionCheckExitCode is the kind for OperationBuiltinFunctionCheckExitCode.
// OperationKindBuiltinFunctionCheckExitCode is the OpKind for OperationBuiltinFunctionCheckExitCode.
OperationKindBuiltinFunctionCheckExitCode
// operationKindEnd is always placed at the bottom of this iota definition to be used in the test.
@@ -716,7 +716,6 @@ const (
)
var (
_ Operation = OperationUnreachable{}
_ Operation = OperationLabel{}
_ Operation = OperationBr{}
_ Operation = OperationBrIf{}
@@ -737,8 +736,6 @@ var (
_ Operation = OperationStore8{}
_ Operation = OperationStore16{}
_ Operation = OperationStore32{}
_ Operation = OperationMemorySize{}
_ Operation = OperationMemoryGrow{}
_ Operation = OperationConstI32{}
_ Operation = OperationConstI64{}
_ Operation = OperationConstF32{}
@@ -775,25 +772,11 @@ var (
_ Operation = OperationMin{}
_ Operation = OperationMax{}
_ Operation = OperationCopysign{}
_ Operation = OperationI32WrapFromI64{}
_ Operation = OperationITruncFromF{}
_ Operation = OperationFConvertFromI{}
_ Operation = OperationF32DemoteFromF64{}
_ Operation = OperationF64PromoteFromF32{}
_ Operation = OperationI32ReinterpretFromF32{}
_ Operation = OperationI64ReinterpretFromF64{}
_ Operation = OperationF32ReinterpretFromI32{}
_ Operation = OperationF64ReinterpretFromI64{}
_ Operation = OperationExtend{}
_ Operation = OperationSignExtend32From8{}
_ Operation = OperationSignExtend32From16{}
_ Operation = OperationSignExtend64From8{}
_ Operation = OperationSignExtend64From16{}
_ Operation = OperationSignExtend64From32{}
_ Operation = OperationMemoryInit{}
_ Operation = OperationDataDrop{}
_ Operation = OperationMemoryCopy{}
_ Operation = OperationMemoryFill{}
_ Operation = OperationTableInit{}
_ Operation = OperationElemDrop{}
_ Operation = OperationTableCopy{}
@@ -854,21 +837,14 @@ var (
_ Operation = OperationV128Dot{}
_ Operation = OperationV128Narrow{}
_ Operation = OperationV128ITruncSatFromF{}
_ Operation = OperationBuiltinFunctionCheckExitCode{}
)
// OperationBuiltinFunctionCheckExitCode implements Operation.
// 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.
type OperationBuiltinFunctionCheckExitCode struct{}
// String implements fmt.Stringer.
func (o OperationBuiltinFunctionCheckExitCode) String() string { return o.Kind().String() }
// Kind implements Operation.Kind
func (OperationBuiltinFunctionCheckExitCode) Kind() OperationKind {
return OperationKindBuiltinFunctionCheckExitCode
func NewOperationBuiltinFunctionCheckExitCode() UnionOperation {
return UnionOperation{OpKind: OperationKindBuiltinFunctionCheckExitCode}
}
// Label is the label of each block in wazeroir where "block" consists of multiple operations,
@@ -906,16 +882,16 @@ func (l Label) IsReturnTarget() bool {
return l.Kind == LabelKindReturn
}
// LabelKind is the kind of the label.
// LabelKind is the OpKind of the label.
type LabelKind = byte
const (
// LabelKindHeader is the header for various blocks. For example, the "then" block of
// wasm.OpcodeIfName in Wasm has the label of this kind.
// wasm.OpcodeIfName in Wasm has the label of this OpKind.
LabelKindHeader LabelKind = iota
// LabelKindElse is the kind of label for "else" block of wasm.OpcodeIfName in Wasm.
// LabelKindElse is the OpKind of label for "else" block of wasm.OpcodeIfName in Wasm.
LabelKindElse
// LabelKindContinuation is the kind of label which is the continuation of blocks.
// LabelKindContinuation is the OpKind of label which is the continuation of blocks.
// For example, for wasm text like
// (func
// ....
@@ -948,19 +924,39 @@ func (b BranchTargetDrop) String() (ret string) {
return
}
// OperationUnreachable implements Operation.
// 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.OperationBrTable.
//
// 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.
type UnionOperation struct {
// OpKind determines how to interpret the other fields in this struct.
OpKind OperationKind
B1, B2 byte
B3 bool
U1, U2 uint64
Us []uint64
Rs []*InclusiveRange
SourcePC uint64
}
// String implements fmt.Stringer.
func (o UnionOperation) String() string { return o.Kind().String() }
// Kind implements Operation.Kind
func (o UnionOperation) Kind() OperationKind {
return o.OpKind
}
// NewOperationUnreachable is a constructor for UnionOperation with Kind OperationKindUnreachable
//
// This corresponds to wasm.OpcodeUnreachable.
//
// The engines are expected to exit the execution with wasmruntime.ErrRuntimeUnreachable error.
type OperationUnreachable struct{}
// String implements fmt.Stringer.
func (o OperationUnreachable) String() string { return o.Kind().String() }
// Kind implements Operation.Kind
func (OperationUnreachable) Kind() OperationKind {
return OperationKindUnreachable
func NewOperationUnreachable() UnionOperation {
return UnionOperation{OpKind: OperationKindUnreachable}
}
// OperationLabel implements Operation.
@@ -1393,36 +1389,24 @@ func (OperationStore32) Kind() OperationKind {
return OperationKindStore32
}
// OperationMemorySize implements Operation.
// NewOperationMemorySize is a constructor for UnionOperation with Kind OperationKindMemorySize.
//
// This corresponds to wasm.OpcodeMemorySize.
//
// The engines are expected to push the current page size of the memory onto the stack.
type OperationMemorySize struct{}
// String implements fmt.Stringer.
func (o OperationMemorySize) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationMemorySize) Kind() OperationKind {
return OperationKindMemorySize
func NewOperationMemorySize() UnionOperation {
return UnionOperation{OpKind: OperationKindMemorySize}
}
// OperationMemoryGrow implements Operation.
type OperationMemoryGrow struct{ Alignment uint64 }
// String implements fmt.Stringer.
func (o OperationMemoryGrow) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
// NewOperationMemoryGrow is a constructor for UnionOperation with Kind 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 (OperationMemoryGrow) Kind() OperationKind {
return OperationKindMemoryGrow
func NewOperationMemoryGrow() UnionOperation {
return UnionOperation{OpKind: OperationKindMemoryGrow}
}
// OperationConstI32 implements Operation.
@@ -2026,20 +2010,14 @@ func (OperationCopysign) Kind() OperationKind {
return OperationKindCopysign
}
// OperationI32WrapFromI64 implements Operation.
// NewOperationI32WrapFromI64 is a constructor for UnionOperation with Kind 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.
type OperationI32WrapFromI64 struct{}
// String implements fmt.Stringer.
func (o OperationI32WrapFromI64) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationI32WrapFromI64) Kind() OperationKind {
return OperationKindI32WrapFromI64
func NewOperationI32WrapFromI64() UnionOperation {
return UnionOperation{OpKind: OperationKindI32WrapFromI64}
}
// OperationITruncFromF implements Operation.
@@ -2100,81 +2078,46 @@ func (OperationFConvertFromI) Kind() OperationKind {
return OperationKindFConvertFromI
}
// OperationF32DemoteFromF64 implements Operation.
// NewOperationF32DemoteFromF64 is a constructor for UnionOperation with Kind OperationKindF32DemoteFromF64.
//
// This corresponds to wasm.OpcodeF32DemoteF64 and is equivalent float32(float64(v)).
type OperationF32DemoteFromF64 struct{}
// String implements fmt.Stringer.
func (o OperationF32DemoteFromF64) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationF32DemoteFromF64) Kind() OperationKind {
return OperationKindF32DemoteFromF64
func NewOperationF32DemoteFromF64() UnionOperation {
return UnionOperation{OpKind: OperationKindF32DemoteFromF64}
}
// OperationF64PromoteFromF32 implements Operation.
// NewOperationF64PromoteFromF32 is a constructor for UnionOperation with Kind OperationKindF64PromoteFromF32.
//
// This corresponds to wasm.OpcodeF64PromoteF32 and is equivalent float64(float32(v)).
type OperationF64PromoteFromF32 struct{}
// String implements fmt.Stringer.
func (o OperationF64PromoteFromF32) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationF64PromoteFromF32) Kind() OperationKind {
return OperationKindF64PromoteFromF32
func NewOperationF64PromoteFromF32() UnionOperation {
return UnionOperation{OpKind: OperationKindF64PromoteFromF32}
}
// OperationI32ReinterpretFromF32 implements Operation.
// NewOperationI32ReinterpretFromF32 is a constructor for UnionOperation with Kind OperationKindI32ReinterpretFromF32.
//
// This corresponds to wasm.OpcodeI32ReinterpretF32Name.
type OperationI32ReinterpretFromF32 struct{}
// String implements fmt.Stringer.
func (o OperationI32ReinterpretFromF32) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationI32ReinterpretFromF32) Kind() OperationKind {
return OperationKindI32ReinterpretFromF32
func NewOperationI32ReinterpretFromF32() UnionOperation {
return UnionOperation{OpKind: OperationKindI32ReinterpretFromF32}
}
// OperationI64ReinterpretFromF64 implements Operation.
// NewOperationI64ReinterpretFromF64 is a constructor for UnionOperation with Kind OperationKindI64ReinterpretFromF64.
//
// This corresponds to wasm.OpcodeI64ReinterpretF64Name.
type OperationI64ReinterpretFromF64 struct{}
// String implements fmt.Stringer.
func (o OperationI64ReinterpretFromF64) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationI64ReinterpretFromF64) Kind() OperationKind {
return OperationKindI64ReinterpretFromF64
func NewOperationI64ReinterpretFromF64() UnionOperation {
return UnionOperation{OpKind: OperationKindI64ReinterpretFromF64}
}
// OperationF32ReinterpretFromI32 implements Operation.
// NewOperationF32ReinterpretFromI32 is a constructor for UnionOperation with Kind OperationKindF32ReinterpretFromI32.
//
// This corresponds to wasm.OpcodeF32ReinterpretI32Name.
type OperationF32ReinterpretFromI32 struct{}
func (o OperationF32ReinterpretFromI32) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationF32ReinterpretFromI32) Kind() OperationKind {
return OperationKindF32ReinterpretFromI32
func NewOperationF32ReinterpretFromI32() UnionOperation {
return UnionOperation{OpKind: OperationKindF32ReinterpretFromI32}
}
// OperationF64ReinterpretFromI64 implements Operation.
// NewOperationF64ReinterpretFromI64 is a constructor for UnionOperation with Kind OperationKindF64ReinterpretFromI64.
//
// This corresponds to wasm.OpcodeF64ReinterpretI64Name.
type OperationF64ReinterpretFromI64 struct{}
// String implements fmt.Stringer.
func (o OperationF64ReinterpretFromI64) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationF64ReinterpretFromI64) Kind() OperationKind {
return OperationKindF64ReinterpretFromI64
func NewOperationF64ReinterpretFromI64() UnionOperation {
return UnionOperation{OpKind: OperationKindF64ReinterpretFromI64}
}
// OperationExtend implements Operation.
@@ -2205,79 +2148,49 @@ func (OperationExtend) Kind() OperationKind {
return OperationKindExtend
}
// OperationSignExtend32From8 implements Operation.
// NewOperationSignExtend32From8 is a constructor for UnionOperation with Kind 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.
type OperationSignExtend32From8 struct{}
// String implements fmt.Stringer.
func (o OperationSignExtend32From8) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationSignExtend32From8) Kind() OperationKind {
return OperationKindSignExtend32From8
func NewOperationSignExtend32From8() UnionOperation {
return UnionOperation{OpKind: OperationKindSignExtend32From8}
}
// OperationSignExtend32From16 implements Operation.
// NewOperationSignExtend32From16 is a constructor for UnionOperation with Kind 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.
type OperationSignExtend32From16 struct{}
// String implements fmt.Stringer.
func (o OperationSignExtend32From16) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationSignExtend32From16) Kind() OperationKind {
return OperationKindSignExtend32From16
func NewOperationSignExtend32From16() UnionOperation {
return UnionOperation{OpKind: OperationKindSignExtend32From16}
}
// OperationSignExtend64From8 implements Operation.
// NewOperationSignExtend64From8 is a constructor for UnionOperation with Kind 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.
type OperationSignExtend64From8 struct{}
// String implements fmt.Stringer.
func (o OperationSignExtend64From8) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationSignExtend64From8) Kind() OperationKind {
return OperationKindSignExtend64From8
func NewOperationSignExtend64From8() UnionOperation {
return UnionOperation{OpKind: OperationKindSignExtend64From8}
}
// OperationSignExtend64From16 implements Operation.
// NewOperationSignExtend64From16 is a constructor for UnionOperation with Kind 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.
type OperationSignExtend64From16 struct{}
// String implements fmt.Stringer.
func (o OperationSignExtend64From16) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationSignExtend64From16) Kind() OperationKind {
return OperationKindSignExtend64From16
func NewOperationSignExtend64From16() UnionOperation {
return UnionOperation{OpKind: OperationKindSignExtend64From16}
}
// OperationSignExtend64From32 implements Operation.
// NewOperationSignExtend64From32 is a constructor for UnionOperation with Kind 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.
type OperationSignExtend64From32 struct{}
// String implements fmt.Stringer.
func (o OperationSignExtend64From32) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationSignExtend64From32) Kind() OperationKind {
return OperationKindSignExtend64From32
func NewOperationSignExtend64From32() UnionOperation {
return UnionOperation{OpKind: OperationKindSignExtend64From32}
}
// OperationMemoryInit implements Operation.
@@ -2314,30 +2227,16 @@ func (OperationDataDrop) Kind() OperationKind {
return OperationKindDataDrop
}
// OperationMemoryCopy implements Operation.
// NewOperationMemoryCopy is a consuctor for UnionOperation with Kind OperationKindMemoryCopy.
//
// This corresponds to wasm.OpcodeMemoryCopyName.
type OperationMemoryCopy struct{}
// String implements fmt.Stringer.
func (o OperationMemoryCopy) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationMemoryCopy) Kind() OperationKind {
return OperationKindMemoryCopy
func NewOperationMemoryCopy() UnionOperation {
return UnionOperation{OpKind: OperationKindMemoryCopy}
}
// OperationMemoryFill implements Operation.
//
// This corresponds to wasm.OpcodeMemoryFillName.
type OperationMemoryFill struct{}
// String implements fmt.Stringer.
func (o OperationMemoryFill) String() string { return o.Kind().String() }
// Kind implements Operation.Kind.
func (OperationMemoryFill) Kind() OperationKind {
return OperationKindMemoryFill
// NewOperationMemoryFill is a consuctor for UnionOperation with Kind OperationKindMemoryFill.
func NewOperationMemoryFill() UnionOperation {
return UnionOperation{OpKind: OperationKindMemoryFill}
}
// OperationTableInit implements Operation.

View File

@@ -6,7 +6,7 @@ import (
"github.com/tetratelabs/wazero/internal/testing/require"
)
// TestInstructionName ensures that all the operation kind's stringer is well-defined.
// TestInstructionName ensures that all the operation OpKind's stringer is well-defined.
func TestOperationKind_String(t *testing.T) {
for k := OperationKind(0); k < operationKindEnd; k++ {
require.NotEqual(t, "", k.String())