File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1313,7 +1313,13 @@ struct InstructionTranslator<Context: TranslatorContext>: InstructionVisitor {
13131313
13141314 let defaultFrame = try controlStack. branchTarget ( relativeDepth: targets. defaultIndex)
13151315
1316- preserveOnStack ( depth: Int ( defaultFrame. copyCount) )
1316+ // If this instruction is unreachable, copyCount might be greater than the actual stack height
1317+ try preserveOnStack (
1318+ depth: min (
1319+ Int ( defaultFrame. copyCount) ,
1320+ valueStack. height - controlStack. currentFrame ( ) . stackHeight
1321+ )
1322+ )
13171323 let allLabelIndices = targets. labelIndices + [ targets. defaultIndex]
13181324 let tableBuffer = allocator. allocateBrTable ( capacity: allLabelIndices. count)
13191325 let operand = Instruction . BrTableOperand (
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ final class SpectestTests: XCTestCase {
2222 path: Self . testPaths,
2323 include: [ ] ,
2424 exclude: [
25- " br.wast " ,
2625 " br_if.wast " ,
2726 " call.wast " ,
2827 " call_indirect.wast " ,
You can’t perform that action at this time.
0 commit comments