JVM: Improve line number handling for suspend calls.
Take branching and method calls into account when finding the line number of the continuation. If there is no line number before branching instructions or method calls, the following code is still on the line of the suspend call itself. This fixes a couple of issues with incorrect line numbers for multiple throws on the same line or multipe suspend calls on the same line. In addition, it avoids the need to spam the method node with repeated line number instructions in the IR backend.
This commit is contained in:
+1
-5
@@ -150,11 +150,7 @@ class ExpressionCodegen(
|
||||
if (fileEntry != null) {
|
||||
val lineNumber = fileEntry.getLineNumber(offset) + 1
|
||||
assert(lineNumber > 0)
|
||||
// State-machine builder splits the sequence of instructions into states inside state-machine, adding additional LINENUMBERs
|
||||
// between them for debugger to stop on suspension. Thus, it requires as much LINENUMBER information as possible to be present,
|
||||
// otherwise, any exception will have incorrect line number. See elvisLineNumber.kt test.
|
||||
// TODO: Remove unneeded LINENUMBERs after building the state-machine.
|
||||
if (lastLineNumber != lineNumber || irFunction.isSuspend || irFunction.isInvokeSuspendOfLambda(context)) {
|
||||
if (lastLineNumber != lineNumber) {
|
||||
lastLineNumber = lineNumber
|
||||
mv.visitLineNumber(lineNumber, markNewLabel())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user