diff --git a/Examples/Sources/WASI-Hello/Hello.swift b/Examples/Sources/WASI-Hello/Hello.swift index 9f79e586..7b0f75f0 100644 --- a/Examples/Sources/WASI-Hello/Hello.swift +++ b/Examples/Sources/WASI-Hello/Hello.swift @@ -2,7 +2,6 @@ import WasmKit import WasmKitWASI -import WAT import Foundation @main diff --git a/Sources/WasmKit/CMakeLists.txt b/Sources/WasmKit/CMakeLists.txt index ada7ad80..957e6bad 100644 --- a/Sources/WasmKit/CMakeLists.txt +++ b/Sources/WasmKit/CMakeLists.txt @@ -8,16 +8,12 @@ add_wasmkit_library(WasmKit Component/CanonicalCall.swift Component/CanonicalOptions.swift Component/ComponentTypes.swift - Execution/Instructions/Reference.swift Execution/Instructions/Control.swift - Execution/Instructions/Expression.swift Execution/Instructions/Instruction.swift - Execution/Instructions/Parametric.swift Execution/Instructions/Table.swift Execution/Instructions/Memory.swift + Execution/Instructions/Misc.swift Execution/Instructions/InstructionSupport.swift - Execution/Instructions/Numeric.swift - Execution/Instructions/Variable.swift Execution/DispatchInstruction.swift Execution/Errors.swift Execution/Execution.swift diff --git a/Sources/WasmKit/Execution/DispatchInstruction.swift b/Sources/WasmKit/Execution/DispatchInstruction.swift index d021c3ab..8324a3aa 100644 --- a/Sources/WasmKit/Execution/DispatchInstruction.swift +++ b/Sources/WasmKit/Execution/DispatchInstruction.swift @@ -1,10 +1,17 @@ //// Automatically generated by Utilities/Sources/VMGen.swift //// DO NOT EDIT DIRECTLY +// Include the C inline code to codegen together with the Swift code. +import _CWasmKit.InlineCode + +// MARK: - Token Threaded Code extension Execution { + + /// Execute an instruction identified by the opcode. + /// Note: This function is only used when using token threading model. @inline(__always) - mutating func doExecute(_ instruction: UInt64, sp: inout Sp, pc: inout Pc, md: inout Md, ms: inout Ms) throws -> CodeSlot { - switch instruction { + mutating func doExecute(_ opcode: OpcodeID, sp: inout Sp, pc: inout Pc, md: inout Md, ms: inout Ms) throws -> CodeSlot { + switch opcode { case 0: return self.execute_copyStack(sp: &sp, pc: &pc, md: &md, ms: &ms) case 1: return self.execute_globalGet(sp: &sp, pc: &pc, md: &md, ms: &ms) case 2: return self.execute_globalSet(sp: &sp, pc: &pc, md: &md, ms: &ms) @@ -207,487 +214,7 @@ extension Execution { } } -extension Execution { - @inline(__always) mutating func i32Add(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].add(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Add(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].add(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Sub(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].sub(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Sub(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].sub(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Mul(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].mul(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Mul(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].mul(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32And(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].and(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64And(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].and(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Or(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].or(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Or(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].or(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Xor(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].xor(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Xor(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].xor(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Shl(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].shl(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Shl(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].shl(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32ShrS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].shrS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64ShrS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].shrS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32ShrU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].shrU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64ShrU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].shrU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Rotl(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].rotl(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Rotl(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].rotl(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Rotr(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].rotr(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Rotr(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.lhs].rotr(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32DivS(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i32: immediate.result] = try sp[i32: immediate.lhs].divS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64DivS(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i64: immediate.result] = try sp[i64: immediate.lhs].divS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32DivU(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i32: immediate.result] = try sp[i32: immediate.lhs].divU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64DivU(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i64: immediate.result] = try sp[i64: immediate.lhs].divU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32RemS(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i32: immediate.result] = try sp[i32: immediate.lhs].remS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64RemS(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i64: immediate.result] = try sp[i64: immediate.lhs].remS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32RemU(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i32: immediate.result] = try sp[i32: immediate.lhs].remU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64RemU(sp: Sp, immediate: Instruction.BinaryOperand) throws { - sp[i64: immediate.result] = try sp[i64: immediate.lhs].remU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Eq(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].eq(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Eq(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].eq(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32Ne(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].ne(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64Ne(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].ne(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32LtS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].ltS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64LtS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].ltS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32LtU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].ltU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64LtU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].ltU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32GtS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].gtS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64GtS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].gtS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32GtU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].gtU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64GtU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].gtU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32LeS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].leS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64LeS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].leS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32LeU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].leU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64LeU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].leU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32GeS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].geS(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64GeS(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].geS(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func i32GeU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.lhs].geU(sp[i32: immediate.rhs]) - } - @inline(__always) mutating func i64GeU(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.lhs].geU(sp[i64: immediate.rhs]) - } - @inline(__always) mutating func f32Add(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].add(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Add(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].add(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Sub(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].sub(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Sub(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].sub(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Mul(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].mul(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Mul(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].mul(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Div(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].div(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Div(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].div(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Min(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].min(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Min(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].min(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Max(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].max(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Max(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].max(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32CopySign(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.lhs].copySign(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64CopySign(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.lhs].copySign(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Eq(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.lhs].eq(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Eq(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f64: immediate.lhs].eq(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Ne(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.lhs].ne(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Ne(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f64: immediate.lhs].ne(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Lt(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.lhs].lt(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Lt(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f64: immediate.lhs].lt(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Gt(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.lhs].gt(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Gt(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f64: immediate.lhs].gt(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Le(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.lhs].le(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Le(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f64: immediate.lhs].le(sp[f64: immediate.rhs]) - } - @inline(__always) mutating func f32Ge(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.lhs].ge(sp[f32: immediate.rhs]) - } - @inline(__always) mutating func f64Ge(sp: Sp, immediate: Instruction.BinaryOperand) { - sp[i32: immediate.result] = sp[f64: immediate.lhs].ge(sp[f64: immediate.rhs]) - } - mutating func i32Clz(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.input].clz - } - mutating func i64Clz(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.input].clz - } - mutating func i32Ctz(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.input].ctz - } - mutating func i64Ctz(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.input].ctz - } - mutating func i32Popcnt(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.input].popcnt - } - mutating func i64Popcnt(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.input].popcnt - } - mutating func i32Eqz(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.input].eqz - } - mutating func i64Eqz(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.input].eqz - } - mutating func i32WrapI64(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i64: immediate.input].wrap - } - mutating func i64ExtendI32S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i32: immediate.input].extendI32S - } - mutating func i64ExtendI32U(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i32: immediate.input].extendI32U - } - mutating func i32Extend8S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.input].extend8S - } - mutating func i64Extend8S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.input].extend8S - } - mutating func i32Extend16S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[i32: immediate.input].extend16S - } - mutating func i64Extend16S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.input].extend16S - } - mutating func i64Extend32S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[i64: immediate.input].extend32S - } - mutating func i32TruncF32S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f32: immediate.input].truncToI32S - } - mutating func i32TruncF32U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f32: immediate.input].truncToI32U - } - mutating func i32TruncSatF32S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f32: immediate.input].truncSatToI32S - } - mutating func i32TruncSatF32U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f32: immediate.input].truncSatToI32U - } - mutating func i32TruncF64S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f64: immediate.input].truncToI32S - } - mutating func i32TruncF64U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f64: immediate.input].truncToI32U - } - mutating func i32TruncSatF64S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f64: immediate.input].truncSatToI32S - } - mutating func i32TruncSatF64U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i32: immediate.result] = try sp[f64: immediate.input].truncSatToI32U - } - mutating func i64TruncF32S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f32: immediate.input].truncToI64S - } - mutating func i64TruncF32U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f32: immediate.input].truncToI64U - } - mutating func i64TruncSatF32S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f32: immediate.input].truncSatToI64S - } - mutating func i64TruncSatF32U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f32: immediate.input].truncSatToI64U - } - mutating func i64TruncF64S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f64: immediate.input].truncToI64S - } - mutating func i64TruncF64U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f64: immediate.input].truncToI64U - } - mutating func i64TruncSatF64S(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f64: immediate.input].truncSatToI64S - } - mutating func i64TruncSatF64U(sp: Sp, immediate: Instruction.UnaryOperand) throws { - sp[i64: immediate.result] = try sp[f64: immediate.input].truncSatToI64U - } - mutating func f32ConvertI32S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[i32: immediate.input].convertToF32S - } - mutating func f32ConvertI32U(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[i32: immediate.input].convertToF32U - } - mutating func f32ConvertI64S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[i64: immediate.input].convertToF32S - } - mutating func f32ConvertI64U(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[i64: immediate.input].convertToF32U - } - mutating func f64ConvertI32S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[i32: immediate.input].convertToF64S - } - mutating func f64ConvertI32U(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[i32: immediate.input].convertToF64U - } - mutating func f64ConvertI64S(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[i64: immediate.input].convertToF64S - } - mutating func f64ConvertI64U(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[i64: immediate.input].convertToF64U - } - mutating func f32ReinterpretI32(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[i32: immediate.input].reinterpretToF32 - } - mutating func f64ReinterpretI64(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[i64: immediate.input].reinterpretToF64 - } - mutating func i32ReinterpretF32(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i32: immediate.result] = sp[f32: immediate.input].reinterpretToI32 - } - mutating func i64ReinterpretF64(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[i64: immediate.result] = sp[f64: immediate.input].reinterpretToI64 - } - mutating func f32Abs(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].abs - } - mutating func f64Abs(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].abs - } - mutating func f32Neg(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].neg - } - mutating func f64Neg(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].neg - } - mutating func f32Ceil(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].ceil - } - mutating func f64Ceil(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].ceil - } - mutating func f32Floor(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].floor - } - mutating func f64Floor(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].floor - } - mutating func f32Trunc(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].trunc - } - mutating func f64Trunc(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].trunc - } - mutating func f32Nearest(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].nearest - } - mutating func f64Nearest(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].nearest - } - mutating func f32Sqrt(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f32: immediate.input].sqrt - } - mutating func f64Sqrt(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f64: immediate.input].sqrt - } - mutating func f64PromoteF32(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f64: immediate.result] = sp[f32: immediate.input].promoteF32 - } - mutating func f32DemoteF64(sp: Sp, immediate: Instruction.UnaryOperand) { - sp[f32: immediate.result] = sp[f64: immediate.input].demoteF64 - } - @inline(__always) mutating func i32Load(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt32.self, castToValue: { .i32($0) }) - } - @inline(__always) mutating func i64Load(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt64.self, castToValue: { .i64($0) }) - } - @inline(__always) mutating func f32Load(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt32.self, castToValue: { .rawF32($0) }) - } - @inline(__always) mutating func f64Load(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt64.self, castToValue: { .rawF64($0) }) - } - @inline(__always) mutating func i32Load8S(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: Int8.self, castToValue: { .init(signed: Int32($0)) }) - } - @inline(__always) mutating func i32Load8U(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt8.self, castToValue: { .i32(UInt32($0)) }) - } - @inline(__always) mutating func i32Load16S(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: Int16.self, castToValue: { .init(signed: Int32($0)) }) - } - @inline(__always) mutating func i32Load16U(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt16.self, castToValue: { .i32(UInt32($0)) }) - } - @inline(__always) mutating func i64Load8S(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: Int8.self, castToValue: { .init(signed: Int64($0)) }) - } - @inline(__always) mutating func i64Load8U(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt8.self, castToValue: { .i64(UInt64($0)) }) - } - @inline(__always) mutating func i64Load16S(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: Int16.self, castToValue: { .init(signed: Int64($0)) }) - } - @inline(__always) mutating func i64Load16U(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt16.self, castToValue: { .i64(UInt64($0)) }) - } - @inline(__always) mutating func i64Load32S(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: Int32.self, castToValue: { .init(signed: Int64($0)) }) - } - @inline(__always) mutating func i64Load32U(sp: Sp, md: Md, ms: Ms, immediate: Instruction.LoadOperand) throws { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: UInt32.self, castToValue: { .i64(UInt64($0)) }) - } - @inline(__always) mutating func i32Store(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { $0.i32 }) - } - @inline(__always) mutating func i64Store(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { $0.i64 }) - } - @inline(__always) mutating func f32Store(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { $0.rawF32 }) - } - @inline(__always) mutating func f64Store(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { $0.rawF64 }) - } - @inline(__always) mutating func i32Store8(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { UInt8(truncatingIfNeeded: $0.i32) }) - } - @inline(__always) mutating func i32Store16(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { UInt16(truncatingIfNeeded: $0.i32) }) - } - @inline(__always) mutating func i64Store8(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { UInt8(truncatingIfNeeded: $0.i64) }) - } - @inline(__always) mutating func i64Store16(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { UInt16(truncatingIfNeeded: $0.i64) }) - } - @inline(__always) mutating func i64Store32(sp: Sp, md: Md, ms: Ms, immediate: Instruction.StoreOperand) throws { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { UInt32(truncatingIfNeeded: $0.i64) }) - } -} - - +// MARK: - Direct Threaded Code extension Execution { @_silgen_name("wasmkit_execute_copyStack") @inline(__always) mutating func execute_copyStack(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { @@ -797,7 +324,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Load") @inline(__always) mutating func execute_i32Load(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i32Load(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt32.self, castToValue: { .i32($0) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -805,7 +332,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load") @inline(__always) mutating func execute_i64Load(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt64.self, castToValue: { .i64($0) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -813,7 +340,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Load") @inline(__always) mutating func execute_f32Load(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.f32Load(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt32.self, castToValue: { .rawF32($0) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -821,7 +348,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Load") @inline(__always) mutating func execute_f64Load(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.f64Load(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt64.self, castToValue: { .rawF64($0) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -829,7 +356,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Load8S") @inline(__always) mutating func execute_i32Load8S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i32Load8S(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: Int8.self, castToValue: { .init(signed: Int32($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -837,7 +364,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Load8U") @inline(__always) mutating func execute_i32Load8U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i32Load8U(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt8.self, castToValue: { .i32(UInt32($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -845,7 +372,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Load16S") @inline(__always) mutating func execute_i32Load16S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i32Load16S(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: Int16.self, castToValue: { .init(signed: Int32($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -853,7 +380,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Load16U") @inline(__always) mutating func execute_i32Load16U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i32Load16U(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt16.self, castToValue: { .i32(UInt32($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -861,7 +388,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load8S") @inline(__always) mutating func execute_i64Load8S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load8S(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: Int8.self, castToValue: { .init(signed: Int64($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -869,7 +396,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load8U") @inline(__always) mutating func execute_i64Load8U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load8U(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt8.self, castToValue: { .i64(UInt64($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -877,7 +404,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load16S") @inline(__always) mutating func execute_i64Load16S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load16S(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: Int16.self, castToValue: { .init(signed: Int64($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -885,7 +412,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load16U") @inline(__always) mutating func execute_i64Load16U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load16U(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt16.self, castToValue: { .i64(UInt64($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -893,7 +420,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load32S") @inline(__always) mutating func execute_i64Load32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load32S(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: Int32.self, castToValue: { .init(signed: Int64($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -901,7 +428,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Load32U") @inline(__always) mutating func execute_i64Load32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.LoadOperand.load(from: &pc.pointee) - try self.i64Load32U(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: UInt32.self, castToValue: { .i64(UInt64($0)) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -909,7 +436,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Store") @inline(__always) mutating func execute_i32Store(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i32Store(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { $0.i32 }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -917,7 +444,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Store") @inline(__always) mutating func execute_i64Store(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i64Store(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { $0.i64 }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -925,7 +452,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Store") @inline(__always) mutating func execute_f32Store(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.f32Store(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { $0.rawF32 }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -933,7 +460,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Store") @inline(__always) mutating func execute_f64Store(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.f64Store(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { $0.rawF64 }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -941,7 +468,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Store8") @inline(__always) mutating func execute_i32Store8(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i32Store8(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { UInt8(truncatingIfNeeded: $0.i32) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -949,7 +476,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Store16") @inline(__always) mutating func execute_i32Store16(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i32Store16(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { UInt16(truncatingIfNeeded: $0.i32) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -957,7 +484,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Store8") @inline(__always) mutating func execute_i64Store8(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i64Store8(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { UInt8(truncatingIfNeeded: $0.i64) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -965,7 +492,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Store16") @inline(__always) mutating func execute_i64Store16(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i64Store16(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { UInt16(truncatingIfNeeded: $0.i64) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -973,7 +500,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Store32") @inline(__always) mutating func execute_i64Store32(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.StoreOperand.load(from: &pc.pointee) - try self.i64Store32(sp: sp.pointee, md: md.pointee, ms: ms.pointee, immediate: immediate) + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { UInt32(truncatingIfNeeded: $0.i64) }) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1045,7 +572,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Add") @inline(__always) mutating func execute_i32Add(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Add(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].add(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1053,7 +580,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Add") @inline(__always) mutating func execute_i64Add(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Add(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].add(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1061,7 +588,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Sub") @inline(__always) mutating func execute_i32Sub(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Sub(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].sub(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1069,7 +596,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Sub") @inline(__always) mutating func execute_i64Sub(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Sub(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].sub(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1077,7 +604,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Mul") @inline(__always) mutating func execute_i32Mul(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Mul(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].mul(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1085,7 +612,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Mul") @inline(__always) mutating func execute_i64Mul(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Mul(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].mul(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1093,7 +620,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32And") @inline(__always) mutating func execute_i32And(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32And(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].and(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1101,7 +628,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64And") @inline(__always) mutating func execute_i64And(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64And(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].and(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1109,7 +636,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Or") @inline(__always) mutating func execute_i32Or(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Or(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].or(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1117,7 +644,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Or") @inline(__always) mutating func execute_i64Or(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Or(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].or(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1125,7 +652,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Xor") @inline(__always) mutating func execute_i32Xor(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Xor(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].xor(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1133,7 +660,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Xor") @inline(__always) mutating func execute_i64Xor(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Xor(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].xor(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1141,7 +668,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Shl") @inline(__always) mutating func execute_i32Shl(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Shl(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].shl(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1149,7 +676,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Shl") @inline(__always) mutating func execute_i64Shl(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Shl(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].shl(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1157,7 +684,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32ShrS") @inline(__always) mutating func execute_i32ShrS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32ShrS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].shrS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1165,7 +692,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64ShrS") @inline(__always) mutating func execute_i64ShrS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64ShrS(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].shrS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1173,7 +700,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32ShrU") @inline(__always) mutating func execute_i32ShrU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32ShrU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].shrU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1181,7 +708,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64ShrU") @inline(__always) mutating func execute_i64ShrU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64ShrU(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].shrU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1189,7 +716,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Rotl") @inline(__always) mutating func execute_i32Rotl(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Rotl(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].rotl(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1197,7 +724,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Rotl") @inline(__always) mutating func execute_i64Rotl(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Rotl(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].rotl(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1205,7 +732,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Rotr") @inline(__always) mutating func execute_i32Rotr(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Rotr(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].rotr(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1213,7 +740,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Rotr") @inline(__always) mutating func execute_i64Rotr(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Rotr(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.lhs].rotr(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1221,7 +748,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32DivS") @inline(__always) mutating func execute_i32DivS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i32DivS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[i32: immediate.lhs].divS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1229,7 +756,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64DivS") @inline(__always) mutating func execute_i64DivS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i64DivS(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[i64: immediate.lhs].divS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1237,7 +764,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32DivU") @inline(__always) mutating func execute_i32DivU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i32DivU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[i32: immediate.lhs].divU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1245,7 +772,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64DivU") @inline(__always) mutating func execute_i64DivU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i64DivU(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[i64: immediate.lhs].divU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1253,7 +780,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32RemS") @inline(__always) mutating func execute_i32RemS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i32RemS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[i32: immediate.lhs].remS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1261,7 +788,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64RemS") @inline(__always) mutating func execute_i64RemS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i64RemS(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[i64: immediate.lhs].remS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1269,7 +796,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32RemU") @inline(__always) mutating func execute_i32RemU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i32RemU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[i32: immediate.lhs].remU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1277,7 +804,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64RemU") @inline(__always) mutating func execute_i64RemU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - try self.i64RemU(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[i64: immediate.lhs].remU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1285,7 +812,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Eq") @inline(__always) mutating func execute_i32Eq(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Eq(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].eq(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1293,7 +820,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Eq") @inline(__always) mutating func execute_i64Eq(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Eq(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].eq(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1301,7 +828,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Ne") @inline(__always) mutating func execute_i32Ne(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32Ne(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].ne(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1309,7 +836,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Ne") @inline(__always) mutating func execute_i64Ne(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64Ne(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].ne(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1317,7 +844,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32LtS") @inline(__always) mutating func execute_i32LtS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32LtS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].ltS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1325,7 +852,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64LtS") @inline(__always) mutating func execute_i64LtS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64LtS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].ltS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1333,7 +860,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32LtU") @inline(__always) mutating func execute_i32LtU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32LtU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].ltU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1341,7 +868,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64LtU") @inline(__always) mutating func execute_i64LtU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64LtU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].ltU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1349,7 +876,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32GtS") @inline(__always) mutating func execute_i32GtS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32GtS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].gtS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1357,7 +884,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64GtS") @inline(__always) mutating func execute_i64GtS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64GtS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].gtS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1365,7 +892,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32GtU") @inline(__always) mutating func execute_i32GtU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32GtU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].gtU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1373,7 +900,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64GtU") @inline(__always) mutating func execute_i64GtU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64GtU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].gtU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1381,7 +908,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32LeS") @inline(__always) mutating func execute_i32LeS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32LeS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].leS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1389,7 +916,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64LeS") @inline(__always) mutating func execute_i64LeS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64LeS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].leS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1397,7 +924,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32LeU") @inline(__always) mutating func execute_i32LeU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32LeU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].leU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1405,7 +932,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64LeU") @inline(__always) mutating func execute_i64LeU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64LeU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].leU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1413,7 +940,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32GeS") @inline(__always) mutating func execute_i32GeS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32GeS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].geS(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1421,7 +948,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64GeS") @inline(__always) mutating func execute_i64GeS(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64GeS(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].geS(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1429,7 +956,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32GeU") @inline(__always) mutating func execute_i32GeU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i32GeU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.lhs].geU(sp.pointee[i32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1437,7 +964,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64GeU") @inline(__always) mutating func execute_i64GeU(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.i64GeU(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.lhs].geU(sp.pointee[i64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1445,7 +972,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Clz") @inline(__always) mutating func execute_i32Clz(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32Clz(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.input].clz let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1453,7 +980,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Clz") @inline(__always) mutating func execute_i64Clz(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Clz(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.input].clz let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1461,7 +988,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Ctz") @inline(__always) mutating func execute_i32Ctz(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32Ctz(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.input].ctz let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1469,7 +996,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Ctz") @inline(__always) mutating func execute_i64Ctz(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Ctz(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.input].ctz let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1477,7 +1004,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Popcnt") @inline(__always) mutating func execute_i32Popcnt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32Popcnt(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.input].popcnt let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1485,7 +1012,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Popcnt") @inline(__always) mutating func execute_i64Popcnt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Popcnt(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.input].popcnt let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1493,7 +1020,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Eqz") @inline(__always) mutating func execute_i32Eqz(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32Eqz(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.input].eqz let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1501,7 +1028,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Eqz") @inline(__always) mutating func execute_i64Eqz(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Eqz(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.input].eqz let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1509,7 +1036,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32WrapI64") @inline(__always) mutating func execute_i32WrapI64(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32WrapI64(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i64: immediate.input].wrap let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1517,7 +1044,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64ExtendI32S") @inline(__always) mutating func execute_i64ExtendI32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64ExtendI32S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i32: immediate.input].extendI32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1525,7 +1052,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64ExtendI32U") @inline(__always) mutating func execute_i64ExtendI32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64ExtendI32U(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i32: immediate.input].extendI32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1533,7 +1060,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Extend8S") @inline(__always) mutating func execute_i32Extend8S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32Extend8S(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.input].extend8S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1541,7 +1068,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Extend8S") @inline(__always) mutating func execute_i64Extend8S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Extend8S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.input].extend8S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1549,7 +1076,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32Extend16S") @inline(__always) mutating func execute_i32Extend16S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32Extend16S(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[i32: immediate.input].extend16S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1557,7 +1084,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Extend16S") @inline(__always) mutating func execute_i64Extend16S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Extend16S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.input].extend16S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1565,7 +1092,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64Extend32S") @inline(__always) mutating func execute_i64Extend32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64Extend32S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[i64: immediate.input].extend32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1573,7 +1100,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncF32S") @inline(__always) mutating func execute_i32TruncF32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncF32S(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f32: immediate.input].truncToI32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1581,7 +1108,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncF32U") @inline(__always) mutating func execute_i32TruncF32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncF32U(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f32: immediate.input].truncToI32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1589,7 +1116,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncSatF32S") @inline(__always) mutating func execute_i32TruncSatF32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncSatF32S(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f32: immediate.input].truncSatToI32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1597,7 +1124,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncSatF32U") @inline(__always) mutating func execute_i32TruncSatF32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncSatF32U(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f32: immediate.input].truncSatToI32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1605,7 +1132,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncF64S") @inline(__always) mutating func execute_i32TruncF64S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncF64S(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f64: immediate.input].truncToI32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1613,7 +1140,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncF64U") @inline(__always) mutating func execute_i32TruncF64U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncF64U(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f64: immediate.input].truncToI32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1621,7 +1148,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncSatF64S") @inline(__always) mutating func execute_i32TruncSatF64S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncSatF64S(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f64: immediate.input].truncSatToI32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1629,7 +1156,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32TruncSatF64U") @inline(__always) mutating func execute_i32TruncSatF64U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i32TruncSatF64U(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = try sp.pointee[f64: immediate.input].truncSatToI32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1637,7 +1164,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncF32S") @inline(__always) mutating func execute_i64TruncF32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncF32S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f32: immediate.input].truncToI64S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1645,7 +1172,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncF32U") @inline(__always) mutating func execute_i64TruncF32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncF32U(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f32: immediate.input].truncToI64U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1653,7 +1180,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncSatF32S") @inline(__always) mutating func execute_i64TruncSatF32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncSatF32S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f32: immediate.input].truncSatToI64S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1661,7 +1188,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncSatF32U") @inline(__always) mutating func execute_i64TruncSatF32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncSatF32U(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f32: immediate.input].truncSatToI64U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1669,7 +1196,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncF64S") @inline(__always) mutating func execute_i64TruncF64S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncF64S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f64: immediate.input].truncToI64S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1677,7 +1204,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncF64U") @inline(__always) mutating func execute_i64TruncF64U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncF64U(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f64: immediate.input].truncToI64U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1685,7 +1212,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncSatF64S") @inline(__always) mutating func execute_i64TruncSatF64S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncSatF64S(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f64: immediate.input].truncSatToI64S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1693,7 +1220,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64TruncSatF64U") @inline(__always) mutating func execute_i64TruncSatF64U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) throws -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - try self.i64TruncSatF64U(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = try sp.pointee[f64: immediate.input].truncSatToI64U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1701,7 +1228,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32ConvertI32S") @inline(__always) mutating func execute_f32ConvertI32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32ConvertI32S(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[i32: immediate.input].convertToF32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1709,7 +1236,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32ConvertI32U") @inline(__always) mutating func execute_f32ConvertI32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32ConvertI32U(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[i32: immediate.input].convertToF32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1717,7 +1244,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32ConvertI64S") @inline(__always) mutating func execute_f32ConvertI64S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32ConvertI64S(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[i64: immediate.input].convertToF32S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1725,7 +1252,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32ConvertI64U") @inline(__always) mutating func execute_f32ConvertI64U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32ConvertI64U(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[i64: immediate.input].convertToF32U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1733,7 +1260,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64ConvertI32S") @inline(__always) mutating func execute_f64ConvertI32S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64ConvertI32S(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[i32: immediate.input].convertToF64S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1741,7 +1268,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64ConvertI32U") @inline(__always) mutating func execute_f64ConvertI32U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64ConvertI32U(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[i32: immediate.input].convertToF64U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1749,7 +1276,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64ConvertI64S") @inline(__always) mutating func execute_f64ConvertI64S(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64ConvertI64S(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[i64: immediate.input].convertToF64S let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1757,7 +1284,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64ConvertI64U") @inline(__always) mutating func execute_f64ConvertI64U(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64ConvertI64U(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[i64: immediate.input].convertToF64U let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1765,7 +1292,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32ReinterpretI32") @inline(__always) mutating func execute_f32ReinterpretI32(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32ReinterpretI32(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[i32: immediate.input].reinterpretToF32 let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1773,7 +1300,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64ReinterpretI64") @inline(__always) mutating func execute_f64ReinterpretI64(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64ReinterpretI64(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[i64: immediate.input].reinterpretToF64 let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1781,7 +1308,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i32ReinterpretF32") @inline(__always) mutating func execute_i32ReinterpretF32(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i32ReinterpretF32(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.input].reinterpretToI32 let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1789,7 +1316,7 @@ extension Execution { @_silgen_name("wasmkit_execute_i64ReinterpretF64") @inline(__always) mutating func execute_i64ReinterpretF64(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.i64ReinterpretF64(sp: sp.pointee, immediate: immediate) + sp.pointee[i64: immediate.result] = sp.pointee[f64: immediate.input].reinterpretToI64 let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1797,7 +1324,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Add") @inline(__always) mutating func execute_f32Add(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Add(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].add(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1805,7 +1332,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Add") @inline(__always) mutating func execute_f64Add(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Add(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].add(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1813,7 +1340,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Sub") @inline(__always) mutating func execute_f32Sub(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Sub(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].sub(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1821,7 +1348,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Sub") @inline(__always) mutating func execute_f64Sub(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Sub(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].sub(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1829,7 +1356,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Mul") @inline(__always) mutating func execute_f32Mul(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Mul(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].mul(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1837,7 +1364,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Mul") @inline(__always) mutating func execute_f64Mul(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Mul(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].mul(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1845,7 +1372,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Div") @inline(__always) mutating func execute_f32Div(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Div(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].div(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1853,7 +1380,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Div") @inline(__always) mutating func execute_f64Div(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Div(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].div(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1861,7 +1388,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Min") @inline(__always) mutating func execute_f32Min(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Min(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].min(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1869,7 +1396,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Min") @inline(__always) mutating func execute_f64Min(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Min(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].min(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1877,7 +1404,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Max") @inline(__always) mutating func execute_f32Max(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Max(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].max(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1885,7 +1412,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Max") @inline(__always) mutating func execute_f64Max(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Max(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].max(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1893,7 +1420,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32CopySign") @inline(__always) mutating func execute_f32CopySign(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32CopySign(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.lhs].copySign(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1901,7 +1428,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64CopySign") @inline(__always) mutating func execute_f64CopySign(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64CopySign(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.lhs].copySign(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1909,7 +1436,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Eq") @inline(__always) mutating func execute_f32Eq(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Eq(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.lhs].eq(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1917,7 +1444,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Eq") @inline(__always) mutating func execute_f64Eq(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Eq(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f64: immediate.lhs].eq(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1925,7 +1452,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Ne") @inline(__always) mutating func execute_f32Ne(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Ne(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.lhs].ne(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1933,7 +1460,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Ne") @inline(__always) mutating func execute_f64Ne(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Ne(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f64: immediate.lhs].ne(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1941,7 +1468,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Lt") @inline(__always) mutating func execute_f32Lt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Lt(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.lhs].lt(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1949,7 +1476,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Lt") @inline(__always) mutating func execute_f64Lt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Lt(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f64: immediate.lhs].lt(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1957,7 +1484,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Gt") @inline(__always) mutating func execute_f32Gt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Gt(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.lhs].gt(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1965,7 +1492,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Gt") @inline(__always) mutating func execute_f64Gt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Gt(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f64: immediate.lhs].gt(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1973,7 +1500,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Le") @inline(__always) mutating func execute_f32Le(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Le(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.lhs].le(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1981,7 +1508,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Le") @inline(__always) mutating func execute_f64Le(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Le(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f64: immediate.lhs].le(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1989,7 +1516,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Ge") @inline(__always) mutating func execute_f32Ge(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f32Ge(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f32: immediate.lhs].ge(sp.pointee[f32: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -1997,7 +1524,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Ge") @inline(__always) mutating func execute_f64Ge(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.BinaryOperand.load(from: &pc.pointee) - self.f64Ge(sp: sp.pointee, immediate: immediate) + sp.pointee[i32: immediate.result] = sp.pointee[f64: immediate.lhs].ge(sp.pointee[f64: immediate.rhs]) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2005,7 +1532,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Abs") @inline(__always) mutating func execute_f32Abs(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Abs(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].abs let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2013,7 +1540,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Abs") @inline(__always) mutating func execute_f64Abs(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Abs(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].abs let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2021,7 +1548,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Neg") @inline(__always) mutating func execute_f32Neg(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Neg(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].neg let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2029,7 +1556,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Neg") @inline(__always) mutating func execute_f64Neg(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Neg(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].neg let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2037,7 +1564,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Ceil") @inline(__always) mutating func execute_f32Ceil(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Ceil(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].ceil let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2045,7 +1572,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Ceil") @inline(__always) mutating func execute_f64Ceil(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Ceil(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].ceil let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2053,7 +1580,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Floor") @inline(__always) mutating func execute_f32Floor(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Floor(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].floor let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2061,7 +1588,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Floor") @inline(__always) mutating func execute_f64Floor(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Floor(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].floor let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2069,7 +1596,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Trunc") @inline(__always) mutating func execute_f32Trunc(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Trunc(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].trunc let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2077,7 +1604,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Trunc") @inline(__always) mutating func execute_f64Trunc(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Trunc(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].trunc let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2085,7 +1612,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Nearest") @inline(__always) mutating func execute_f32Nearest(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Nearest(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].nearest let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2093,7 +1620,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Nearest") @inline(__always) mutating func execute_f64Nearest(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Nearest(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].nearest let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2101,7 +1628,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32Sqrt") @inline(__always) mutating func execute_f32Sqrt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32Sqrt(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f32: immediate.input].sqrt let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2109,7 +1636,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64Sqrt") @inline(__always) mutating func execute_f64Sqrt(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64Sqrt(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f64: immediate.input].sqrt let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2117,7 +1644,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f64PromoteF32") @inline(__always) mutating func execute_f64PromoteF32(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f64PromoteF32(sp: sp.pointee, immediate: immediate) + sp.pointee[f64: immediate.result] = sp.pointee[f32: immediate.input].promoteF32 let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2125,7 +1652,7 @@ extension Execution { @_silgen_name("wasmkit_execute_f32DemoteF64") @inline(__always) mutating func execute_f32DemoteF64(sp: UnsafeMutablePointer, pc: UnsafeMutablePointer, md: UnsafeMutablePointer, ms: UnsafeMutablePointer) -> CodeSlot { let immediate = Instruction.UnaryOperand.load(from: &pc.pointee) - self.f32DemoteF64(sp: sp.pointee, immediate: immediate) + sp.pointee[f32: immediate.result] = sp.pointee[f64: immediate.input].demoteF64 let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) return next @@ -2244,19 +1771,14 @@ extension Execution { } } - -import _CWasmKit.InlineCode - extension Instruction { - private static let handlers: [UInt64] = withUnsafePointer(to: wasmkit_tc_exec_handlers) { - let count = MemoryLayout.size(ofValue: wasmkit_tc_exec_handlers) / MemoryLayout.size - return $0.withMemoryRebound(to: UInt64.self, capacity: count) { - Array(UnsafeBufferPointer(start: $0, count: count)) + /// The tail-calling execution handler for the instruction. + var handler: UInt { + return withUnsafePointer(to: wasmkit_tc_exec_handlers) { + let count = MemoryLayout.size(ofValue: wasmkit_tc_exec_handlers) / MemoryLayout.size + return $0.withMemoryRebound(to: UInt.self, capacity: count) { + $0[Int(self.opcodeID)] + } } } - - @inline(never) - var handler: UInt64 { - return Self.handlers[rawIndex] - } } diff --git a/Sources/WasmKit/Execution/Execution.swift b/Sources/WasmKit/Execution/Execution.swift index 29cda0fa..099dd13e 100644 --- a/Sources/WasmKit/Execution/Execution.swift +++ b/Sources/WasmKit/Execution/Execution.swift @@ -234,12 +234,9 @@ func executeWasm( } try withUnsafeTemporaryAllocation(of: CodeSlot.self, capacity: 2) { rootISeq in - switch runtime.value.configuration.threadingModel { - case .direct: - rootISeq[0] = Instruction.endOfExecution.handler - case .token: - rootISeq[0] = UInt64(Instruction.endOfExecution.rawIndex) - } + rootISeq[0] = Instruction.endOfExecution.headSlot( + threadingModel: runtime.value.configuration.threadingModel + ) try stack.execute( sp: sp, pc: rootISeq.baseAddress!, @@ -381,8 +378,8 @@ extension Execution { private var buffer = CircularBuffer(capacity: 3) /// Tracks the given instruction index. This function is called for each instruction execution. - mutating func track(_ rawIndex: UInt64) { - buffer.append(rawIndex) + mutating func track(_ opcode: UInt64) { + buffer.append(opcode) if let a = buffer[0], let b = buffer[1], let c = buffer[2] { let trigram = Trigram(a: a, b: b, c: c) countByTrigram[trigram, default: 0] += 1 @@ -392,7 +389,7 @@ extension Execution { func dump(target: inout TargetStream, limit: Int) { print("Instruction statistics:", to: &target) for (trigram, count) in countByTrigram.sorted(by: { $0.value > $1.value }).prefix(limit) { - print(" \(Instruction.name(rawIndex: trigram.a)) -> \(Instruction.name(rawIndex: trigram.b)) -> \(Instruction.name(rawIndex: trigram.c)) = \(count)", to: &target) + print(" \(Instruction.name(opcode: trigram.a)) -> \(Instruction.name(opcode: trigram.b)) -> \(Instruction.name(opcode: trigram.c)) = \(count)", to: &target) } } @@ -412,12 +409,12 @@ extension Execution { var stats = StatsCollector() defer { stats.dump() } #endif - var inst = pc.read(UInt64.self) + var opcode = pc.read(OpcodeID.self) while true { #if EngineStats stats.track(inst) #endif - inst = try doExecute(inst, sp: &sp, pc: &pc, md: &md, ms: &ms) + opcode = try doExecute(opcode, sp: &sp, pc: &pc, md: &md, ms: &ms) } } diff --git a/Sources/WasmKit/Execution/Function.swift b/Sources/WasmKit/Execution/Function.swift index 0bbeafb9..9635cd57 100644 --- a/Sources/WasmKit/Execution/Function.swift +++ b/Sources/WasmKit/Execution/Function.swift @@ -202,6 +202,28 @@ struct WasmFunctionEntity { typealias InternalUncompiledCode = EntityHandle +/// A compiled instruction sequence. +struct InstructionSequence { + let instructions: UnsafeMutableBufferPointer + /// The maximum height of the value stack during execution of this function. + /// This height does not count the locals. + let maxStackHeight: Int + + /// The constant value pool associated with this instruction sequence. + /// See ``FrameHeaderLayout`` for how they are laid out on the stack. + let constants: UnsafeBufferPointer + + init(instructions: UnsafeMutableBufferPointer, maxStackHeight: Int, constants: UnsafeBufferPointer) { + self.instructions = instructions + self.maxStackHeight = maxStackHeight + self.constants = constants + } + + var baseAddress: UnsafeMutablePointer { + self.instructions.baseAddress! + } +} + enum CodeBody { case uncompiled(InternalUncompiledCode) case compiled(InstructionSequence) diff --git a/Sources/WasmKit/Execution/Instructions/Control.swift b/Sources/WasmKit/Execution/Instructions/Control.swift index 8869a767..a0af1f85 100644 --- a/Sources/WasmKit/Execution/Instructions/Control.swift +++ b/Sources/WasmKit/Execution/Instructions/Control.swift @@ -100,16 +100,11 @@ extension Execution { mutating func compilingCall(sp: inout Sp, pc: Pc, immediate: Instruction.CallOperand) throws -> (Pc, CodeSlot) { var pc = pc // NOTE: `CompilingCallOperand` consumes 2 slots, discriminator is at -3 - let discriminatorPc = pc.advanced(by: -3) + let headSlotPc = pc.advanced(by: -3) let callee = immediate.callee try callee.ensureCompiled(runtime: runtime) let replaced = Instruction.internalCall(immediate) - switch runtime.value.configuration.threadingModel { - case .direct: - discriminatorPc.pointee = replaced.handler - case .token: - discriminatorPc.pointee = UInt64(replaced.rawIndex) - } + headSlotPc.pointee = replaced.headSlot(threadingModel: runtime.value.configuration.threadingModel) try _internalCall(sp: &sp, pc: &pc, callee: callee, internalCallOperand: immediate) return pc.next() } diff --git a/Sources/WasmKit/Execution/Instructions/Expression.swift b/Sources/WasmKit/Execution/Instructions/Expression.swift deleted file mode 100644 index 3d860651..00000000 --- a/Sources/WasmKit/Execution/Instructions/Expression.swift +++ /dev/null @@ -1,47 +0,0 @@ -import WasmParser - -struct InstructionSequence: Equatable { - let instructions: UnsafeMutableBufferPointer - /// The maximum height of the value stack during execution of this function. - /// This height does not count the locals. - let maxStackHeight: Int - - let constants: UnsafeBufferPointer - - init(instructions: UnsafeMutableBufferPointer, maxStackHeight: Int, constants: UnsafeBufferPointer) { - self.instructions = instructions - self.maxStackHeight = maxStackHeight - self.constants = constants - } - - var baseAddress: UnsafeMutablePointer { - self.instructions.baseAddress! - } - - static func == (lhs: InstructionSequence, rhs: InstructionSequence) -> Bool { - lhs.instructions.baseAddress == rhs.instructions.baseAddress - } -} - -extension InstructionSequence { - func write(to target: inout Target, context: inout InstructionPrintingContext) where Target : TextOutputStream { - var hexOffsetWidth = String(instructions.count - 1, radix: 16).count - hexOffsetWidth = (hexOffsetWidth + 1) & ~1 - - guard let cursorStart = instructions.baseAddress else { return } - let cursorEnd = cursorStart.advanced(by: instructions.count) - - var cursor = cursorStart - while cursor < cursorEnd { - let index = cursor - cursorStart - var hexOffset = String(index, radix: 16) - while hexOffset.count < hexOffsetWidth { - hexOffset = "0" + hexOffset - } - target.write("0x\(hexOffset): ") - let instruction = Instruction.load(from: &cursor) - context.print(instruction: instruction, to: &target) - target.write("\n") - } - } -} diff --git a/Sources/WasmKit/Execution/Instructions/Instruction.swift b/Sources/WasmKit/Execution/Instructions/Instruction.swift index 137da2c2..6b57ff6e 100644 --- a/Sources/WasmKit/Execution/Instructions/Instruction.swift +++ b/Sources/WasmKit/Execution/Instructions/Instruction.swift @@ -1020,7 +1020,8 @@ extension Instruction { extension Instruction { - var rawIndex: Int { + /// The opcode ID of the instruction. + var opcodeID: OpcodeID { switch self { case .copyStack: return 0 case .globalGet: return 1 @@ -1227,8 +1228,8 @@ extension Instruction { /// - Returns: The instruction read from the program counter. /// - Precondition: The instruction sequence must be compiled with token threading model. static func load(from pc: inout Pc) -> Instruction { - let rawIndex = pc.read(UInt64.self) - switch rawIndex { + let opcode = pc.read(UInt64.self) + switch opcode { case 0: return .copyStack(Instruction.CopyStackOperand.load(from: &pc)) case 1: return .globalGet(Instruction.GlobalAndVRegOperand.load(from: &pc)) case 2: return .globalSet(Instruction.GlobalAndVRegOperand.load(from: &pc)) @@ -1425,7 +1426,7 @@ extension Instruction { case 193: return .tableElementDrop(Instruction.TableElementDropOperand.load(from: &pc)) case 194: return .onEnter(Instruction.OnEnterOperand.load(from: &pc)) case 195: return .onExit(Instruction.OnExitOperand.load(from: &pc)) - default: fatalError("Unknown instruction index: \(rawIndex)") + default: fatalError("Unknown instruction opcode: \(opcode)") } } } @@ -1433,12 +1434,12 @@ extension Instruction { #if EngineStats extension Instruction { /// The name of the instruction. - /// - Parameter rawIndex: The raw index of the instruction. + /// - Parameter opcode: The opcode ID of the instruction. /// - Returns: The name of the instruction. /// /// NOTE: This function is used for debugging purposes. - static func name(rawIndex: UInt64) -> String { - switch rawIndex { + static func name(opcode: OpcodeID) -> String { + switch opcode { case 0: return "copyStack" case 1: return "globalGet" case 2: return "globalSet" @@ -1635,7 +1636,7 @@ extension Instruction { case 193: return "tableElementDrop" case 194: return "onEnter" case 195: return "onExit" - default: fatalError("Unknown instruction index: \(rawIndex)") + default: fatalError("Unknown instruction index: \(opcode)") } } } diff --git a/Sources/WasmKit/Execution/Instructions/InstructionSupport.swift b/Sources/WasmKit/Execution/Instructions/InstructionSupport.swift index fa2b139d..0741a48e 100644 --- a/Sources/WasmKit/Execution/Instructions/InstructionSupport.swift +++ b/Sources/WasmKit/Execution/Instructions/InstructionSupport.swift @@ -44,92 +44,35 @@ struct LLVReg: Equatable, ShiftedVReg { } } -extension RawUnsignedInteger { - init(_ slot: CodeSlot, shiftWidth: Int) { - let mask = CodeSlot(Self.max) - let bitPattern = (slot >> shiftWidth) & mask - self = Self(bitPattern) - } - - func bits(shiftWidth: Int) -> CodeSlot { - CodeSlot(self) << shiftWidth - } -} - -extension RawSignedInteger { - init(_ slot: CodeSlot, shiftWidth: Int) { - self.init(bitPattern: Unsigned(slot, shiftWidth: shiftWidth)) - } - - func bits(shiftWidth: Int) -> CodeSlot { - Unsigned(bitPattern: self).bits(shiftWidth: shiftWidth) - } -} - -extension UntypedValue { - init(_ slot: CodeSlot, shiftWidth: Int) { - self.init(storage: slot) - } - - func bits(shiftWidth: Int) -> CodeSlot { storage } -} +// MARK: - Immediate load/emit support +/// A protocol that represents an immediate associated with an instruction. protocol InstructionImmediate { + /// Loads an immediate from the instruction sequence. + /// + /// - Parameter pc: The program counter to read from. + /// - Returns: The loaded immediate. static func load(from pc: inout Pc) -> Self + + /// Emits the layout of the immediate to be emitted. + /// + /// - Parameter emitSlot: The closure to schedule a slot emission. + /// This closure receives a builder closure that builds the slot. + /// + /// - Note: This method is intended to work at meta-level to allow + /// knowing the size of slots without actual immediate values. static func emit(to emitSlot: @escaping ((Self) -> CodeSlot) -> Void) } extension InstructionImmediate { + /// Emits the immediate value + /// + /// - Parameter emitSlot: The closure to emit a slot. func emit(to emitSlot: @escaping (CodeSlot) -> Void) { Self.emit { buildCodeSlot in emitSlot(buildCodeSlot(self)) } } - static func emit(to emitParent: @escaping ((Parent) -> CodeSlot) -> Void, _ child: KeyPath) { - Self.emit { emitChild in - emitParent { emitChild($0[keyPath: child]) } - } - } -} - -extension InstructionImmediate { - static func load(from pc: inout Pc) -> Self { - pc.read() - } - static func emit(to emitSlot: ((Self) -> CodeSlot) -> Void) { - assert(MemoryLayout.size == 8) - emitSlot { unsafeBitCast($0, to: CodeSlot.self) } - } -} - -extension VReg: InstructionImmediate { - static func load(from pc: inout Pc) -> Self { - VReg(bitPattern: UInt16(pc.read(UInt64.self))) - } - static func emit(to emitSlot: @escaping ((Self) -> CodeSlot) -> Void) { - emitSlot { CodeSlot(UInt16(bitPattern: $0)) } - } - - typealias Slot2 = (VReg, VReg, pad: UInt32) - static func load2(from pc: inout Pc) -> (Self, Self) { - let (x, y, _) = pc.read(Slot2.self) - return (x, y) - } - static func emit2(to emitSlot: @escaping ((Self, Self) -> CodeSlot) -> Void) { - emitSlot { x, y in - let slot: Slot2 = (x, y, 0) - return unsafeBitCast(slot, to: CodeSlot.self) - } - } -} - -extension LLVReg: InstructionImmediate { - static func load(from pc: inout Pc) -> Self { - Self(storage: Int64(bitPattern: pc.read())) - } - static func emit(to emitSlot: ((Self) -> CodeSlot) -> Void) { - emitSlot { UInt64(bitPattern: $0.value) } - } } extension UInt32: InstructionImmediate { @@ -150,6 +93,8 @@ extension Int32: InstructionImmediate { } } +// MARK: - Immediate type extensions + extension Instruction.RefNullOperand { init(result: VReg, type: ReferenceType) { self.init(result: result, rawType: type.rawValue) @@ -210,6 +155,75 @@ extension Instruction { typealias OnExitOperand = FunctionIndex } +extension RawUnsignedInteger { + init(_ slot: CodeSlot, shiftWidth: Int) { + let mask = CodeSlot(Self.max) + let bitPattern = (slot >> shiftWidth) & mask + self = Self(bitPattern) + } + + func bits(shiftWidth: Int) -> CodeSlot { + CodeSlot(self) << shiftWidth + } +} + +extension RawSignedInteger { + init(_ slot: CodeSlot, shiftWidth: Int) { + self.init(bitPattern: Unsigned(slot, shiftWidth: shiftWidth)) + } + + func bits(shiftWidth: Int) -> CodeSlot { + Unsigned(bitPattern: self).bits(shiftWidth: shiftWidth) + } +} + +extension UntypedValue { + init(_ slot: CodeSlot, shiftWidth: Int) { + self.init(storage: slot) + } + + func bits(shiftWidth: Int) -> CodeSlot { storage } +} + +/// The type of an opcode identifier. +typealias OpcodeID = UInt64 + +extension Instruction { + func headSlot(threadingModel: RuntimeConfiguration.ThreadingModel) -> CodeSlot { + switch threadingModel { + case .direct: + return CodeSlot(handler) + case .token: + return opcodeID + } + } +} + +// MARK: - Instruction printing support + +extension InstructionSequence { + func write(to target: inout Target, context: inout InstructionPrintingContext) where Target : TextOutputStream { + var hexOffsetWidth = String(instructions.count - 1, radix: 16).count + hexOffsetWidth = (hexOffsetWidth + 1) & ~1 + + guard let cursorStart = instructions.baseAddress else { return } + let cursorEnd = cursorStart.advanced(by: instructions.count) + + var cursor = cursorStart + while cursor < cursorEnd { + let index = cursor - cursorStart + var hexOffset = String(index, radix: 16) + while hexOffset.count < hexOffsetWidth { + hexOffset = "0" + hexOffset + } + target.write("0x\(hexOffset): ") + let instruction = Instruction.load(from: &cursor) + context.print(instruction: instruction, to: &target) + target.write("\n") + } + } +} + struct InstructionPrintingContext { let shouldColor: Bool let function: Function diff --git a/Sources/WasmKit/Execution/Instructions/Misc.swift b/Sources/WasmKit/Execution/Instructions/Misc.swift new file mode 100644 index 00000000..3d8ef324 --- /dev/null +++ b/Sources/WasmKit/Execution/Instructions/Misc.swift @@ -0,0 +1,71 @@ +/// > Note: +/// +extension Execution { + mutating func globalGet(sp: Sp, immediate: Instruction.GlobalAndVRegOperand) { + immediate.global.withValue{ + sp[immediate.reg] = $0.rawValue + } + } + mutating func globalSet(sp: Sp, immediate: Instruction.GlobalAndVRegOperand) { + let value = sp[immediate.reg] + immediate.global.withValue{ $0.rawValue = value } + } + + mutating func copyStack(sp: Sp, immediate: Instruction.CopyStackOperand) { + sp[immediate.dest] = sp[immediate.source] + } +} + +/// > Note: +/// +extension Execution { + mutating func refNull(sp: Sp, immediate: Instruction.RefNullOperand) { + let value: Value + switch immediate.type { + case .externRef: + value = .ref(.extern(nil)) + case .funcRef: + value = .ref(.function(nil)) + } + sp[immediate.result] = UntypedValue(value) + } + mutating func refIsNull(sp: Sp, immediate: Instruction.RefIsNullOperand) { + let value = sp[immediate.value] + + let result: Value + if value.isNullRef { + result = .i32(1) + } else { + result = .i32(0) + } + sp[immediate.result] = UntypedValue(result) + } + mutating func refFunc(sp: Sp, immediate: Instruction.RefFuncOperand) { + let function = currentInstance(sp: sp).functions[Int(immediate.index)] + sp[immediate.result] = UntypedValue(.ref(.function(from: function))) + } +} + +/// > Note: +/// +extension Execution { + @inline(__always) + mutating func const32(sp: Sp, immediate: Instruction.Const32Operand) { + sp[immediate.result] = UntypedValue(storage32: immediate.value) + } + @inline(__always) + mutating func const64(sp: Sp, immediate: Instruction.Const64Operand) { + sp[immediate.result] = immediate.value + } +} + +/// > Note: +/// +extension Execution { + mutating func select(sp: Sp, immediate: Instruction.SelectOperand) { + let flag = sp[i32: immediate.condition] + let selected = flag != 0 ? immediate.onTrue : immediate.onFalse + let value = sp[selected] + sp[immediate.result] = value + } +} diff --git a/Sources/WasmKit/Execution/Instructions/Numeric.swift b/Sources/WasmKit/Execution/Instructions/Numeric.swift deleted file mode 100644 index 352b778b..00000000 --- a/Sources/WasmKit/Execution/Instructions/Numeric.swift +++ /dev/null @@ -1,12 +0,0 @@ -/// > Note: -/// -extension Execution { - @inline(__always) - mutating func const32(sp: Sp, immediate: Instruction.Const32Operand) { - sp[immediate.result] = UntypedValue(storage32: immediate.value) - } - @inline(__always) - mutating func const64(sp: Sp, immediate: Instruction.Const64Operand) { - sp[immediate.result] = immediate.value - } -} diff --git a/Sources/WasmKit/Execution/Instructions/Parametric.swift b/Sources/WasmKit/Execution/Instructions/Parametric.swift deleted file mode 100644 index bbea5caf..00000000 --- a/Sources/WasmKit/Execution/Instructions/Parametric.swift +++ /dev/null @@ -1,10 +0,0 @@ -/// > Note: -/// -extension Execution { - mutating func select(sp: Sp, immediate: Instruction.SelectOperand) { - let flag = sp[i32: immediate.condition] - let selected = flag != 0 ? immediate.onTrue : immediate.onFalse - let value = sp[selected] - sp[immediate.result] = value - } -} diff --git a/Sources/WasmKit/Execution/Instructions/Reference.swift b/Sources/WasmKit/Execution/Instructions/Reference.swift deleted file mode 100644 index fc023288..00000000 --- a/Sources/WasmKit/Execution/Instructions/Reference.swift +++ /dev/null @@ -1,29 +0,0 @@ -/// > Note: -/// -extension Execution { - mutating func refNull(sp: Sp, immediate: Instruction.RefNullOperand) { - let value: Value - switch immediate.type { - case .externRef: - value = .ref(.extern(nil)) - case .funcRef: - value = .ref(.function(nil)) - } - sp[immediate.result] = UntypedValue(value) - } - mutating func refIsNull(sp: Sp, immediate: Instruction.RefIsNullOperand) { - let value = sp[immediate.value] - - let result: Value - if value.isNullRef { - result = .i32(1) - } else { - result = .i32(0) - } - sp[immediate.result] = UntypedValue(result) - } - mutating func refFunc(sp: Sp, immediate: Instruction.RefFuncOperand) { - let function = currentInstance(sp: sp).functions[Int(immediate.index)] - sp[immediate.result] = UntypedValue(.ref(.function(from: function))) - } -} diff --git a/Sources/WasmKit/Execution/Instructions/Variable.swift b/Sources/WasmKit/Execution/Instructions/Variable.swift deleted file mode 100644 index 3dee3432..00000000 --- a/Sources/WasmKit/Execution/Instructions/Variable.swift +++ /dev/null @@ -1,17 +0,0 @@ -/// > Note: -/// -extension Execution { - mutating func globalGet(sp: Sp, immediate: Instruction.GlobalAndVRegOperand) { - immediate.global.withValue{ - sp[immediate.reg] = $0.rawValue - } - } - mutating func globalSet(sp: Sp, immediate: Instruction.GlobalAndVRegOperand) { - let value = sp[immediate.reg] - immediate.global.withValue{ $0.rawValue = value } - } - - mutating func copyStack(sp: Sp, immediate: Instruction.CopyStackOperand) { - sp[immediate.dest] = sp[immediate.source] - } -} diff --git a/Sources/WasmKit/Translator.swift b/Sources/WasmKit/Translator.swift index e0d525c5..dc81c7b7 100644 --- a/Sources/WasmKit/Translator.swift +++ b/Sources/WasmKit/Translator.swift @@ -585,13 +585,7 @@ struct InstructionTranslator: InstructionVisitor { private mutating func assign(at index: Int, _ instruction: Instruction) { trace("assign: \(instruction)") - let headSlot: CodeSlot - switch runtimeConfiguration.threadingModel { - case .direct: - headSlot = instruction.handler - case .token: - headSlot = UInt64(instruction.rawIndex) - } + let headSlot = instruction.headSlot(threadingModel: runtimeConfiguration.threadingModel) trace(" [\(index)] = 0x\(String(headSlot, radix: 16))") self.instructions[index] = headSlot if let immediate = instruction.rawImmediate { @@ -636,12 +630,7 @@ struct InstructionTranslator: InstructionVisitor { mutating func emit(_ instruction: Instruction, resultRelink: ResultRelink? = nil) { self.lastEmission = LastEmission(position: insertingPC, resultRelink: resultRelink) trace("emitInstruction: \(instruction)") - switch runtimeConfiguration.threadingModel { - case .direct: - emitSlot(instruction.handler) - case .token: - emitSlot(UInt64(instruction.rawIndex)) - } + emitSlot(instruction.headSlot(threadingModel: runtimeConfiguration.threadingModel)) if let immediate = instruction.rawImmediate { var slots: [CodeSlot] = [] immediate.emit(to: { slots.append($0) }) @@ -696,13 +685,30 @@ struct InstructionTranslator: InstructionVisitor { /// - Parameters: /// - ref: Label reference to be resolved /// - make: Factory closure to make an inserting instruction - mutating func emitWithLabel(_ ref: LabelRef, line: UInt = #line, make: @escaping InstructionFactoryWithLabel) { + mutating func emitWithLabel( + _ makeInstruction: @escaping (Immediate) -> Instruction, + _ ref: LabelRef, + line: UInt = #line, + make: @escaping ( + ISeqBuilder, + // The position of the next slot of the creating instruction + _ source: MetaProgramCounter, + // The position of the resolved label + _ target: MetaProgramCounter + ) -> (Immediate) + ) { let insertAt = insertingPC - // TODO: Skip emitting nop if the label is already pinned - // FIXME: ****THIS IS ABSOLUTELY WRONG. JUST FOR PERF EVALUATION** - // Please change placeholder size based on whether the instruction has any immediate - emit(.br(0)) // Emit dummy instruction to be replaced later - emitWithLabel(ref, insertAt: insertAt, line: line, make: make) + + // Emit dummy instruction to be replaced later + emitSlot(0) // dummy opcode + var immediateSlots = 0 + Immediate.emit(to: { _ in immediateSlots += 1 }) + for _ in 0..: InstructionVisitor { ) ) guard let condition = condition else { return } - iseqBuilder.emitWithLabel(endLabel) { iseqBuilder, selfPC, endPC in + iseqBuilder.emitWithLabel(Instruction.brIfNot, endLabel) { iseqBuilder, selfPC, endPC in let targetPC: MetaProgramCounter if let elsePC = iseqBuilder.resolveLabel(elseLabel) { targetPC = elsePC @@ -1105,7 +1111,7 @@ struct InstructionTranslator: InstructionVisitor { targetPC = endPC } let elseOrEnd = UInt32(targetPC.offsetFromHead - selfPC.offsetFromHead) - return .brIfNot(Instruction.BrIfOperand(condition: LVReg(condition), offset: Int32(elseOrEnd))) + return Instruction.BrIfOperand(condition: LVReg(condition), offset: Int32(elseOrEnd)) } } @@ -1117,9 +1123,9 @@ struct InstructionTranslator: InstructionVisitor { preserveOnStack(depth: valueStack.height - frame.stackHeight) try controlStack.resetReachability() iseqBuilder.resetLastEmission() - iseqBuilder.emitWithLabel(endLabel) { _, selfPC, endPC in + iseqBuilder.emitWithLabel(Instruction.br, endLabel) { _, selfPC, endPC in let offset = endPC.offsetFromHead - selfPC.offsetFromHead - return .br(Int32(offset)) + return Int32(offset) } try valueStack.truncate(height: frame.stackHeight) // Re-push parameters @@ -1191,9 +1197,10 @@ struct InstructionTranslator: InstructionVisitor { return popCount } - private mutating func emitBranch( + private mutating func emitBranch( + _ makeInstruction: @escaping (Immediate) -> Instruction, relativeDepth: UInt32, - make: @escaping (_ offset: Int32, _ copyCount: UInt32, _ popCount: UInt32) -> Instruction + make: @escaping (_ offset: Int32, _ copyCount: UInt32, _ popCount: UInt32) -> Immediate ) throws { let frame = try controlStack.branchTarget(relativeDepth: relativeDepth) let copyCount = frame.copyCount @@ -1202,7 +1209,7 @@ struct InstructionTranslator: InstructionVisitor { currentFrame: try controlStack.currentFrame(), currentHeight: valueStack.height ) - iseqBuilder.emitWithLabel(frame.continuation) { _, selfPC, continuation in + iseqBuilder.emitWithLabel(makeInstruction, frame.continuation) { _, selfPC, continuation in let relativeOffset = continuation.offsetFromHead - selfPC.offsetFromHead return make(Int32(relativeOffset), UInt32(copyCount), popCount) } @@ -1219,8 +1226,8 @@ struct InstructionTranslator: InstructionVisitor { // +---[ i32 ]<--+ copy [2] // [ i64 ]---+ try copyOnBranch(targetFrame: frame) - try emitBranch(relativeDepth: relativeDepth) { offset, copyCount, popCount in - return .br(offset) + try emitBranch(Instruction.br, relativeDepth: relativeDepth) { offset, copyCount, popCount in + return offset } try markUnreachable() } @@ -1231,11 +1238,11 @@ struct InstructionTranslator: InstructionVisitor { let frame = try controlStack.branchTarget(relativeDepth: relativeDepth) if frame.copyCount == 0 { // Optimization where we don't need copying values when the branch taken - iseqBuilder.emitWithLabel(frame.continuation) { _, selfPC, continuation in + iseqBuilder.emitWithLabel(Instruction.brIf, frame.continuation) { _, selfPC, continuation in let relativeOffset = continuation.offsetFromHead - selfPC.offsetFromHead - return .brIf(Instruction.BrIfOperand( + return Instruction.BrIfOperand( condition: LVReg(condition), offset: Int32(relativeOffset) - )) + ) } return } @@ -1262,13 +1269,13 @@ struct InstructionTranslator: InstructionVisitor { // [0x06] (local.get 1 reg:2) <----|---------+ // [0x07] ... <-------+ let onBranchNotTaken = iseqBuilder.allocLabel() - iseqBuilder.emitWithLabel(onBranchNotTaken) { _, conditionCheckAt, continuation in + iseqBuilder.emitWithLabel(Instruction.brIfNot, onBranchNotTaken) { _, conditionCheckAt, continuation in let relativeOffset = continuation.offsetFromHead - conditionCheckAt.offsetFromHead - return .brIfNot(Instruction.BrIfOperand(condition: LVReg(condition), offset: Int32(relativeOffset))) + return Instruction.BrIfOperand(condition: LVReg(condition), offset: Int32(relativeOffset)) } try copyOnBranch(targetFrame: frame) - try emitBranch(relativeDepth: relativeDepth) { offset, copyCount, popCount in - return .br(offset) + try emitBranch(Instruction.br, relativeDepth: relativeDepth) { offset, copyCount, popCount in + return offset } try iseqBuilder.pinLabelHere(onBranchNotTaken) } @@ -1328,9 +1335,9 @@ struct InstructionTranslator: InstructionVisitor { } let emittedCopy = try copyOnBranch(targetFrame: frame) if emittedCopy { - iseqBuilder.emitWithLabel(frame.continuation) { _, brAt, continuation in + iseqBuilder.emitWithLabel(Instruction.br, frame.continuation) { _, brAt, continuation in let relativeOffset = continuation.offsetFromHead - brAt.offsetFromHead - return .br(Int32(relativeOffset)) + return Int32(relativeOffset) } } else { // Optimization: If no value is copied, we can directly jump to the target diff --git a/Utilities/Sources/VMGen.swift b/Utilities/Sources/VMGen.swift index 79eecf38..25f3efda 100644 --- a/Utilities/Sources/VMGen.swift +++ b/Utilities/Sources/VMGen.swift @@ -30,21 +30,24 @@ enum VMGen { static func generateDispatcher(instructions: [Instruction]) -> String { let doExecuteParams: [Instruction.Parameter] = - [("instruction", "UInt64", false)] + [("opcode", "OpcodeID", false)] + ExecutionParameter.allCases.map { ($0.label, $0.type, true) } var output = """ extension Execution { + + /// Execute an instruction identified by the opcode. + /// Note: This function is only used when using token threading model. @inline(__always) mutating func doExecute(_ \(doExecuteParams.map { "\($0.label): \($0.isInout ? "inout " : "")\($0.type)" }.joined(separator: ", "))) throws -> CodeSlot { - switch instruction { + switch opcode { """ - for (index, inst) in instructions.enumerated() { + for (opcode, inst) in instructions.enumerated() { let tryPrefix = inst.mayThrow ? "try " : "" let args = ExecutionParameter.allCases.map { "\($0.label): &\($0.label)" } output += """ - case \(index): return \(tryPrefix)self.execute_\(inst.name)(\(args.joined(separator: ", "))) + case \(opcode): return \(tryPrefix)self.execute_\(inst.name)(\(args.joined(separator: ", "))) """ } output += """ @@ -58,51 +61,31 @@ enum VMGen { return output } - static func generateBasicInstImplementations() -> String { - var output = """ - extension Execution { - """ - + static func generateBasicInstImplementations() -> [String: String] { + var inlineImpls: [String: String] = [:] for op in intBinOps + floatBinOps { - output += """ - - @inline(__always) mutating \(instMethodDecl(op.instruction)) { - sp[\(op.resultType): immediate.result] = \(op.mayThrow ? "try " : "")sp[\(op.lhsType): immediate.lhs].\(camelCase(pascalCase: op.op))(sp[\(op.rhsType): immediate.rhs]) - } + inlineImpls[op.instruction.name] = """ + sp.pointee[\(op.resultType): immediate.result] = \(op.mayThrow ? "try " : "")sp.pointee[\(op.lhsType): immediate.lhs].\(camelCase(pascalCase: op.op))(sp.pointee[\(op.rhsType): immediate.rhs]) """ } for op in intUnaryInsts + floatUnaryOps { - output += """ - - mutating \(instMethodDecl(op.instruction)) { - sp[\(op.resultType): immediate.result] = \(op.mayThrow ? "try " : "")sp[\(op.inputType): immediate.input].\(camelCase(pascalCase: op.op)) - } + inlineImpls[op.instruction.name] = """ + sp.pointee[\(op.resultType): immediate.result] = \(op.mayThrow ? "try " : "")sp.pointee[\(op.inputType): immediate.input].\(camelCase(pascalCase: op.op)) """ } for op in memoryLoadOps { - output += """ - - @inline(__always) mutating \(instMethodDecl(op.instruction)) { - return try memoryLoad(sp: sp, md: md, ms: ms, loadOperand: immediate, loadAs: \(op.loadAs).self, castToValue: { \(op.castToValue) }) - } + inlineImpls[op.instruction.name] = """ + try memoryLoad(sp: sp.pointee, md: md.pointee, ms: ms.pointee, loadOperand: immediate, loadAs: \(op.loadAs).self, castToValue: { \(op.castToValue) }) """ } for op in memoryStoreOps { - output += """ - - @inline(__always) mutating \(instMethodDecl(op.instruction)) { - return try memoryStore(sp: sp, md: md, ms: ms, storeOperand: immediate, castFromValue: { \(op.castFromValue) }) - } + inlineImpls[op.instruction.name] = """ + try memoryStore(sp: sp.pointee, md: md.pointee, ms: ms.pointee, storeOperand: immediate, castFromValue: { \(op.castFromValue) }) """ } - output += """ - - } - - """ - return output + return inlineImpls } static func instMethodDecl(_ inst: Instruction) -> String { @@ -226,7 +209,8 @@ enum VMGen { output += "\n\n" output += """ extension Instruction { - var rawIndex: Int { + /// The opcode ID of the instruction. + var opcodeID: OpcodeID { switch self { """ @@ -247,8 +231,8 @@ enum VMGen { /// - Returns: The instruction read from the program counter. /// - Precondition: The instruction sequence must be compiled with token threading model. static func load(from pc: inout Pc) -> Instruction { - let rawIndex = pc.read(UInt64.self) - switch rawIndex { + let opcode = pc.read(UInt64.self) + switch opcode { """ for (i, inst) in instructions.enumerated() { @@ -260,7 +244,7 @@ enum VMGen { } } output += """ - default: fatalError("Unknown instruction index: \\(rawIndex)") + default: fatalError("Unknown instruction opcode: \\(opcode)") } } } @@ -271,12 +255,12 @@ enum VMGen { #if EngineStats extension Instruction { /// The name of the instruction. - /// - Parameter rawIndex: The raw index of the instruction. + /// - Parameter opcode: The opcode ID of the instruction. /// - Returns: The name of the instruction. /// /// NOTE: This function is used for debugging purposes. - static func name(rawIndex: UInt64) -> String { - switch rawIndex { + static func name(opcode: OpcodeID) -> String { + switch opcode { """ for (i, inst) in instructions.enumerated() { output += """ @@ -286,7 +270,7 @@ enum VMGen { } output += """ - default: fatalError("Unknown instruction index: \\(rawIndex)") + default: fatalError("Unknown instruction index: \\(opcode)") } } } @@ -323,7 +307,7 @@ enum VMGen { return output } - static func generateDirectThreadedCode(instructions: [Instruction]) -> String { + static func generateDirectThreadedCode(instructions: [Instruction], inlineImpls: [String: String]) -> String { var output = """ extension Execution { """ @@ -359,7 +343,7 @@ enum VMGen { """ } else { output += """ - \(call) + \(inlineImpls[inst.name] ?? call) let next = pc.pointee.pointee pc.pointee = pc.pointee.advanced(by: 1) @@ -441,31 +425,39 @@ enum VMGen { let projectSources = ["Sources"] + let inlineImpls = generateBasicInstImplementations() + let generatedFiles = [ GeneratedFile( projectSources + ["WasmKit", "Execution", "DispatchInstruction.swift"], - header + generateDispatcher(instructions: instructions) - + "\n\n" - + generateBasicInstImplementations() - + "\n\n" - + generateDirectThreadedCode(instructions: instructions) + header + """ + // Include the C inline code to codegen together with the Swift code. + import _CWasmKit.InlineCode + // MARK: - Token Threaded Code - import _CWasmKit.InlineCode + """ + + generateDispatcher(instructions: instructions) + + """ + + + // MARK: - Direct Threaded Code + + """ + + generateDirectThreadedCode(instructions: instructions, inlineImpls: inlineImpls) + + """ extension Instruction { - private static let handlers: [UInt64] = withUnsafePointer(to: wasmkit_tc_exec_handlers) { - let count = MemoryLayout.size(ofValue: wasmkit_tc_exec_handlers) / MemoryLayout.size - return $0.withMemoryRebound(to: UInt64.self, capacity: count) { - Array(UnsafeBufferPointer(start: $0, count: count)) + /// The tail-calling execution handler for the instruction. + var handler: UInt { + return withUnsafePointer(to: wasmkit_tc_exec_handlers) { + let count = MemoryLayout.size(ofValue: wasmkit_tc_exec_handlers) / MemoryLayout.size + return $0.withMemoryRebound(to: UInt.self, capacity: count) { + $0[Int(self.opcodeID)] + } } } - - @inline(never) - var handler: UInt64 { - return Self.handlers[rawIndex] - } } """