From 8b177180869007dd51df500c4229fa66df66c9b3 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 28 Nov 2019 03:46:42 +0900 Subject: [PATCH] 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 --- .../optimization/RedundantNopsCleanupMethodTransformer.kt | 8 ++++---- .../inline/linenumberForOneParametersArgumentCall.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantNopsCleanupMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantNopsCleanupMethodTransformer.kt index 07d3475c7b8..fb564b5425a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantNopsCleanupMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantNopsCleanupMethodTransformer.kt @@ -103,16 +103,16 @@ class RedundantNopsCleanupMethodTransformer : MethodTransformer() { internal fun getRequiredNopInRange(firstInclusive: AbstractInsnNode, lastExclusive: AbstractInsnNode?): AbstractInsnNode? { - var lastNop: AbstractInsnNode? = null + var firstNop: AbstractInsnNode? = null var current: AbstractInsnNode? = firstInclusive while (current != null && current != lastExclusive) { if (current.isMeaningful && current.opcode != Opcodes.NOP) { return null - } else if (current.opcode == Opcodes.NOP) { - lastNop = current + } else if (current.opcode == Opcodes.NOP && firstNop == null) { + firstNop = current } current = current.next } - return lastNop + return firstNop } diff --git a/compiler/testData/codegen/bytecodeText/inline/linenumberForOneParametersArgumentCall.kt b/compiler/testData/codegen/bytecodeText/inline/linenumberForOneParametersArgumentCall.kt index e1ff9ff84ac..be576371b26 100644 --- a/compiler/testData/codegen/bytecodeText/inline/linenumberForOneParametersArgumentCall.kt +++ b/compiler/testData/codegen/bytecodeText/inline/linenumberForOneParametersArgumentCall.kt @@ -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 } -// 3 NOP \ No newline at end of file +// 2 NOP \ No newline at end of file