Skip to content

Commit

Permalink
More robust way to get index of first stack value in optimizer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lrytz committed Apr 16, 2024
1 parent 41ba962 commit f2a771a
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -469,7 +469,9 @@ class InitialProducerSourceInterpreter extends SourceInterpreter(scala.tools.asm
}

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

0 comments on commit f2a771a

Please sign in to comment.