Skip to content

Commit

Permalink
Remove BlockType from ifThen instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Apr 7, 2024
1 parent 2a5d6f9 commit da053f2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/WasmKit/Execution/Instructions/Control.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension ExecutionState {

typealias BlockType = Instruction.BlockType

mutating func ifThen(runtime: Runtime, stack: inout Stack, elseOrEndRef: ExpressionRef, type: BlockType) {
mutating func ifThen(runtime: Runtime, stack: inout Stack, elseOrEndRef: ExpressionRef) {
let isTrue = stack.popValue().i32 != 0
if isTrue {
programCounter += 1
Expand Down
2 changes: 1 addition & 1 deletion Sources/WasmKit/Execution/Instructions/Instruction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enum Instruction: Equatable {
case globalSet(index: GlobalIndex)
case unreachable
case nop
case ifThen(elseOrEndRef: ExpressionRef, type: BlockType)
case ifThen(elseOrEndRef: ExpressionRef)
case end
case `else`(endRef: ExpressionRef)
case br(offset: Int32, copyCount: UInt32, popCount: UInt32)
Expand Down
4 changes: 2 additions & 2 deletions Sources/WasmKit/Execution/Runtime/InstDispatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ extension ExecutionState {
case .nop:
try self.nop(runtime: runtime, stack: &stack)
return true
case .ifThen(let elseOrEndRef, let type):
self.ifThen(runtime: runtime, stack: &stack, elseOrEndRef: elseOrEndRef, type: type)
case .ifThen(let elseOrEndRef):
self.ifThen(runtime: runtime, stack: &stack, elseOrEndRef: elseOrEndRef)
return true
case .end:
self.end(runtime: runtime, stack: &stack)
Expand Down
2 changes: 1 addition & 1 deletion Sources/WasmKit/Translator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ struct InstructionTranslator: InstructionVisitor {
} else {
elseOrEndRef = ExpressionRef(from: selfPC, to: endPC)
}
return .ifThen(elseOrEndRef: elseOrEndRef, type: Instruction.BlockType(blockType))
return .ifThen(elseOrEndRef: elseOrEndRef)
}
}

Expand Down
1 change: 0 additions & 1 deletion Utilities/generate_inst_dispatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ let instructions: [Instruction] = [
Instruction(name: "ifThen", isControl: true, immediates: [
// elseRef for if-then-else-end sequence, endRef for if-then-end sequence
Immediate(name: "elseOrEndRef", type: "ExpressionRef"),
Immediate(name: "type", type: "BlockType")
]),
Instruction(name: "end", isControl: true, immediates: []),
Instruction(name: "`else`", isControl: true, immediates: [
Expand Down

0 comments on commit da053f2

Please sign in to comment.