Debugger: Fix missing NOPs in optimized Unit.INSTANCE calls (KT-31702)

This commit is contained in:
Yan Zhulanow
2019-06-21 16:23:46 +09:00
parent f60bf5cb97
commit d45bbaabcd
4 changed files with 29 additions and 0 deletions
@@ -113,6 +113,7 @@ class RedundantLocalsEliminationMethodTransformer(private val languageVersionSet
val insns = val insns =
findPopPredecessors(methodNode) { it.isUnitInstance() || it.opcode == Opcodes.ACONST_NULL || it.opcode == Opcodes.ALOAD } findPopPredecessors(methodNode) { it.isUnitInstance() || it.opcode == Opcodes.ACONST_NULL || it.opcode == Opcodes.ALOAD }
for ((pred, pop) in insns) { for ((pred, pop) in insns) {
methodNode.instructions.insertBefore(pred, InsnNode(Opcodes.NOP))
methodNode.instructions.removeAll(listOf(pred, pop)) methodNode.instructions.removeAll(listOf(pred, pop))
} }
return insns.isNotEmpty() return insns.isNotEmpty()
@@ -0,0 +1,12 @@
package coroutineUnitElimination
suspend fun main() {
//Breakpoint!
Unit
//Breakpoint!
42
//Breakpoint!
Unit
}
// RESUME: 3
@@ -0,0 +1,11 @@
LineBreakpoint created at coroutineUnitElimination.kt:5
LineBreakpoint created at coroutineUnitElimination.kt:7
LineBreakpoint created at coroutineUnitElimination.kt:9
Run Java
Connected to the target VM
coroutineUnitElimination.kt:5
coroutineUnitElimination.kt:7
coroutineUnitElimination.kt:9
Disconnected from the target VM
Process finished with exit code 0
@@ -1047,6 +1047,11 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/coroutine.kt"); runTest("idea/testData/debugger/tinyApp/src/stepping/custom/coroutine.kt");
} }
@TestMetadata("coroutineUnitElimination.kt")
public void testCoroutineUnitElimination() throws Exception {
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/coroutineUnitElimination.kt");
}
@TestMetadata("crossinlineLiteral.kt") @TestMetadata("crossinlineLiteral.kt")
public void testCrossinlineLiteral() throws Exception { public void testCrossinlineLiteral() throws Exception {
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/crossinlineLiteral.kt"); runTest("idea/testData/debugger/tinyApp/src/stepping/custom/crossinlineLiteral.kt");