Files
kotlin/compiler/testData/codegen/bytecodeText/nopsInDoWhile.kt
Dmitry Petrov 4dd100122b Explicitly remove NOPs inserted for bytecode analysis in post-conditional loops.
Remove redundant NOPs during bytecode optimization.

NOP instruction is required iff one of the following is true:
(a) it is a first bytecode instruction in a try-catch block (JVM BE assumption);
(b) it is a sole bytecode instruction in a source code line (breakpoints on that line will not work).
All other NOP instructions can be removed.

Note that it doesn't really affect the performance for mature JVM implementations.
However, the perceived quality of the generated code is somewhat improved :).

Related: KT-15609
2017-01-13 10:31:07 +03:00

10 lines
131 B
Kotlin
Vendored

fun test() {
var i = 0
do {
i++
if (i > 5) break
if (i < 3) continue
} while (true)
}
// 0 NOP