Skip to content

Commit 4a31fa4

Browse files
Translator: Follow-up fix of 8419670
1 parent 4e74318 commit 4a31fa4

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
Binary file not shown.

Sources/WasmKit/Translator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,7 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
11541154
// Pop condition value
11551155
let condition = try popVRegOperand(.i32)
11561156
let blockType = try module.resolveBlockType(blockType)
1157+
self.preserveLocalsOnStack(depth: self.valueStack.height)
11571158
preserveOnStack(depth: blockType.parameters.count)
11581159
let endLabel = iseqBuilder.allocLabel()
11591160
let elseLabel = iseqBuilder.allocLabel()

Tests/WasmKitTests/ExtraSuite/local_cow.wast

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,22 @@
6767
)
6868

6969
(assert_return (invoke "check") (i32.const 0))
70+
71+
(module
72+
(global (mut i32) (i32.const 4))
73+
(func (export "check") (result i32)
74+
(local i32)
75+
global.get 0
76+
drop
77+
local.get 0
78+
i32.const 1
79+
if
80+
i32.const 1
81+
br_if 0
82+
i32.const 0
83+
local.set 0
84+
end
85+
)
86+
)
87+
88+
(assert_return (invoke "check") (i32.const 0))

0 commit comments

Comments
 (0)