Debugger, BE: Make the NOP instruction optimizer save the first NOP, not the last

This commit fixes the following tests:
 - KotlinSteppingTestGenerated.StepOver#testSoInlineLibFun
 - KotlinSteppingTestGenerated.StepOver#testSoInlineIterableFun
 - KotlinSteppingTestGenerated.StepOver#testSoInlineFunOnOneLineFor
This commit is contained in:
Yan Zhulanow
2019-11-28 03:46:42 +09:00
parent 9cba72d5dd
commit 8b17718086
2 changed files with 5 additions and 5 deletions
@@ -103,16 +103,16 @@ class RedundantNopsCleanupMethodTransformer : MethodTransformer() {
internal fun getRequiredNopInRange(firstInclusive: AbstractInsnNode, lastExclusive: AbstractInsnNode?): AbstractInsnNode? { internal fun getRequiredNopInRange(firstInclusive: AbstractInsnNode, lastExclusive: AbstractInsnNode?): AbstractInsnNode? {
var lastNop: AbstractInsnNode? = null var firstNop: AbstractInsnNode? = null
var current: AbstractInsnNode? = firstInclusive var current: AbstractInsnNode? = firstInclusive
while (current != null && current != lastExclusive) { while (current != null && current != lastExclusive) {
if (current.isMeaningful && current.opcode != Opcodes.NOP) { if (current.isMeaningful && current.opcode != Opcodes.NOP) {
return null return null
} else if (current.opcode == Opcodes.NOP) { } else if (current.opcode == Opcodes.NOP && firstNop == null) {
lastNop = current firstNop = current
} }
current = current.next current = current.next
} }
return lastNop return firstNop
} }
@@ -10,4 +10,4 @@ inline fun lookAtMe(f: (String) -> Unit) {
f(a) // Should be no unneeded nops on this line, that might be generated for zero-parameters lambda f(a) // Should be no unneeded nops on this line, that might be generated for zero-parameters lambda
} }
// 3 NOP // 2 NOP