[IR] Align debugging of suspend lambdas with old BE
The existing backend restores LVs and parameters from the suspend lambda fields used for spilling between suspension points, hence they are visible in the debugger as local variables, plain and simple. This PR introduces the same pattern to the IR backend, to bring the debugging experience in line with the existing backend. Both backends are still at the mercy of the liveness analysis performed in the coroutine transformer where a liveness analysis minimizes live ranges of entries in the LVT. E.g. an unused parameter will be dropped entirely. Adjusted existing test expectations accounting for the differences in LV behavior.
This commit is contained in:
committed by
Alexander Udalov
parent
2be62c13b0
commit
8a5f260d04
-11
@@ -11,21 +11,10 @@ suspend fun foo(data: Data, body: suspend (Data) -> Unit) {
|
||||
body(data)
|
||||
}
|
||||
|
||||
// Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class.
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
|
||||
// METHOD : DataClassKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// VARIABLE : NAME=$dstr$x_param$y_param TYPE=LData; INDEX=2
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=y_param TYPE=I INDEX=4
|
||||
// VARIABLE : NAME=this TYPE=LDataClassKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=y_param TYPE=I INDEX=3
|
||||
// VARIABLE : NAME=this TYPE=LDataClassKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
Vendored
+1
-4
@@ -22,10 +22,6 @@ suspend fun test() = B.bar()
|
||||
// Local function bodies (i.e., `A<R>.component3()`) are in a separate class (implementing FunctionN) for non-IR, and are static methods
|
||||
// in the enclosing class for IR. Therefore the ordinal in the suspend lambda class name is different for non-IR (`$3`) vs IR (e.g., `$2`).
|
||||
//
|
||||
// Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class.
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// METHOD : ExtensionComponentsKt$bar$3.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
// VARIABLE : NAME=$dstr$x_param$y_param$z_param TYPE=LA; INDEX=2
|
||||
@@ -37,6 +33,7 @@ suspend fun test() = B.bar()
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// METHOD : ExtensionComponentsKt$bar$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
// VARIABLE : NAME=$dstr$x_param$y_param$z_param TYPE=LA; INDEX=2
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=z_param TYPE=I INDEX=4
|
||||
|
||||
+1
-12
@@ -8,21 +8,10 @@ suspend fun test() = foo(A("OK", 1)) { (x_param, y_param) ->
|
||||
x_param + (y_param.toString())
|
||||
}
|
||||
|
||||
// Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class.
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
|
||||
// METHOD : GenericKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// VARIABLE : NAME=$dstr$x_param$y_param TYPE=LA; INDEX=2
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=y_param TYPE=I INDEX=4
|
||||
// VARIABLE : NAME=this TYPE=LGenericKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=y_param TYPE=I INDEX=3
|
||||
// VARIABLE : NAME=this TYPE=LGenericKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
-11
@@ -7,13 +7,8 @@ suspend fun test() = foo(A("O", "K")) { i_param, (x_param, y_param), v_param ->
|
||||
i_param.toString() + x_param + y_param + v_param
|
||||
}
|
||||
|
||||
// Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class.
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
|
||||
// METHOD : OtherParametersKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// VARIABLE : NAME=i_param TYPE=I INDEX=2
|
||||
// VARIABLE : NAME=$dstr$x_param$y_param TYPE=LA; INDEX=3
|
||||
// VARIABLE : NAME=v_param TYPE=Ljava/lang/String; INDEX=4
|
||||
@@ -21,9 +16,3 @@ suspend fun test() = foo(A("O", "K")) { i_param, (x_param, y_param), v_param ->
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=6
|
||||
// VARIABLE : NAME=this TYPE=LOtherParametersKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=this TYPE=LOtherParametersKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
+9
-7
@@ -11,9 +11,7 @@ suspend fun foo(data: Data, body: suspend Long.(String, Data, Int) -> Unit) {
|
||||
1L.body("OK", data, 1)
|
||||
}
|
||||
|
||||
// Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class.
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
// The JVM and IR backend differ in naming scheme of captured receiver paramters in suspend lambdas
|
||||
|
||||
// METHOD : ParametersKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
|
||||
@@ -28,7 +26,11 @@ suspend fun foo(data: Data, body: suspend Long.(String, Data, Int) -> Unit) {
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// VARIABLE : NAME=x TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=z TYPE=I INDEX=3
|
||||
// VARIABLE : NAME=this TYPE=LParametersKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
// VARIABLE : NAME=$dstr$x$_u24__u24$z TYPE=LData; INDEX=*
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=*
|
||||
// VARIABLE : NAME=i TYPE=I INDEX=*
|
||||
// VARIABLE : NAME=p$ TYPE=J INDEX=*
|
||||
// VARIABLE : NAME=str TYPE=Ljava/lang/String; INDEX=*
|
||||
// VARIABLE : NAME=this TYPE=LParametersKt$test$2; INDEX=*
|
||||
// VARIABLE : NAME=x TYPE=Ljava/lang/String; INDEX=*
|
||||
// VARIABLE : NAME=z TYPE=I INDEX=*
|
||||
Reference in New Issue
Block a user