Skip to content

Commit f759e6a

Browse files
lrytzSethTisue
authored andcommitted
More robust way to get index of first stack value in optimizer
The ASM analyzer changed in 9.7 to no longer call `clearStack()` before `newExceptionValue`. We need to get the index of the exception value, which is always the first slot after all locals.
1 parent a86ae0a commit f759e6a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ class InitialProducerSourceInterpreter extends SourceInterpreter(scala.tools.asm
469469
}
470470

471471
override def newExceptionValue(tryCatchBlockNode: TryCatchBlockNode, handlerFrame: Frame[SourceValue], exceptionType: Type): SourceValue = {
472-
val handlerStackTop = handlerFrame.stackTop + 1 // +1 because this value is about to be pushed onto `handlerFrame`.
472+
// -1 to go from the number of locals to the (0-based) index of the last local
473+
// +1 because this value is about to be pushed onto `handlerFrame`
474+
val handlerStackTop = handlerFrame.getLocals - 1 + 1
473475
new SourceValue(1, ExceptionProducer(tryCatchBlockNode.handler, handlerStackTop))
474476
}
475477
}

0 commit comments

Comments
 (0)