Skip to content

Commit b8414db

Browse files
NFC: Stop passing ValueStack to instruction closures in popPushEmit
1 parent 9de5ac3 commit b8414db

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Sources/WasmKit/Translator.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,15 +1709,15 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
17091709
private mutating func popPushEmit(
17101710
_ pop: ValueType,
17111711
_ push: ValueType,
1712-
_ instruction: @escaping (_ popped: VReg, _ result: VReg, ValueStack) -> Instruction
1712+
_ instruction: @escaping (_ popped: VReg, _ result: VReg) -> Instruction
17131713
) throws {
17141714
let value = try popVRegOperand(pop)
17151715
let result = valueStack.push(push)
17161716
if let value = value {
17171717
emit(
1718-
instruction(value, result, valueStack),
1719-
resultRelink: { [valueStack] newResult in
1720-
instruction(value, newResult, valueStack)
1718+
instruction(value, result),
1719+
resultRelink: { newResult in
1720+
instruction(value, newResult)
17211721
})
17221722
}
17231723
}
@@ -1776,7 +1776,7 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
17761776
) throws {
17771777
let isMemory64 = try module.isMemory64(memoryIndex: 0)
17781778
try validator.validateMemArg(memarg, naturalAlignment: naturalAlignment)
1779-
try popPushEmit(.address(isMemory64: isMemory64), type) { value, result, stack in
1779+
try popPushEmit(.address(isMemory64: isMemory64), type) { value, result in
17801780
let loadOperand = Instruction.LoadOperand(
17811781
offset: memarg.offset,
17821782
pointer: value,
@@ -1849,7 +1849,7 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
18491849
let isMemory64 = try module.isMemory64(memoryIndex: memory)
18501850
let sizeType = ValueType.address(isMemory64: isMemory64)
18511851
// Just pop/push the same type (i64 or i32) value
1852-
try popPushEmit(sizeType, sizeType) { value, result, stack in
1852+
try popPushEmit(sizeType, sizeType) { value, result in
18531853
.memoryGrow(
18541854
Instruction.MemoryGrowOperand(
18551855
result: result, delta: value, memory: memory
@@ -1893,7 +1893,7 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
18931893
}
18941894

18951895
private mutating func visitUnary(_ operand: ValueType, _ instruction: @escaping (Instruction.UnaryOperand) -> Instruction) throws {
1896-
try popPushEmit(operand, operand) { value, result, stack in
1896+
try popPushEmit(operand, operand) { value, result in
18971897
return instruction(Instruction.UnaryOperand(result: LVReg(result), input: LVReg(value)))
18981898
}
18991899
}
@@ -1917,12 +1917,12 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
19171917
try visitBinary(operand, .i32, instruction)
19181918
}
19191919
private mutating func visitConversion(_ from: ValueType, _ to: ValueType, _ instruction: @escaping (Instruction.UnaryOperand) -> Instruction) throws {
1920-
try popPushEmit(from, to) { value, result, stack in
1920+
try popPushEmit(from, to) { value, result in
19211921
return instruction(Instruction.UnaryOperand(result: LVReg(result), input: LVReg(value)))
19221922
}
19231923
}
19241924
mutating func visitI32Eqz() throws -> Output {
1925-
try popPushEmit(.i32, .i32) { value, result, stack in
1925+
try popPushEmit(.i32, .i32) { value, result in
19261926
.i32Eqz(Instruction.UnaryOperand(result: LVReg(result), input: LVReg(value)))
19271927
}
19281928
}
@@ -2018,7 +2018,7 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
20182018
try visitBinary(operand, result, instruction)
20192019
}
20202020
mutating func visitI64Eqz() throws -> Output {
2021-
try popPushEmit(.i64, .i32) { value, result, stack in
2021+
try popPushEmit(.i64, .i32) { value, result in
20222022
.i64Eqz(Instruction.UnaryOperand(result: LVReg(result), input: LVReg(value)))
20232023
}
20242024
}
@@ -2217,7 +2217,7 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
22172217
try popPushEmit(
22182218
module.addressType(tableIndex: table),
22192219
.ref(type.elementType)
2220-
) { index, result, stack in
2220+
) { index, result in
22212221
return .tableGet(
22222222
Instruction.TableGetOperand(
22232223
index: index,

0 commit comments

Comments
 (0)