mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
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
14 lines
245 B
Kotlin
Vendored
14 lines
245 B
Kotlin
Vendored
fun box() {
|
|
lookAtMe {
|
|
12
|
|
}
|
|
}
|
|
|
|
inline fun lookAtMe(f: () -> Int): Int {
|
|
val a = 42
|
|
a + f() // Even this line already has meaningful instraction nop is still generated
|
|
return 13
|
|
}
|
|
|
|
// TODO: Less NOPs is better
|
|
// 1 NOP |