[JVM] Extend boxing/unboxing optimizations to coroutine boxing.

This commit is contained in:
Mads Ager
2021-05-06 11:21:26 +02:00
committed by Ilmir Usmanov
parent 4994cb3774
commit afa1b8bfdc
5 changed files with 102 additions and 1 deletions
@@ -0,0 +1,66 @@
inline fun fInt(g: (Int) -> Unit) {
g(1)
}
inline fun fBoolean(g: (Boolean) -> Unit) {
g(true)
}
inline fun fChar(g: (Char) -> Unit) {
g('a')
}
inline fun fByte(g: (Byte) -> Unit) {
g(1)
}
inline fun fShort(g: (Short) -> Unit) {
g(1)
}
inline fun fFloat(g: (Float) -> Unit) {
g(1.0f)
}
inline fun fLong(g: (Long) -> Unit) {
g(1L)
}
inline fun fDouble(g: (Double) -> Unit) {
g(1.0)
}
fun bar() {
fInt { }
fBoolean { }
fChar { }
fByte { }
fShort { }
fFloat { }
fLong { }
fDouble { }
}
suspend fun baz() {
fInt { }
fBoolean { }
fChar { }
fByte { }
fShort { }
fFloat { }
fLong { }
fDouble { }
}
// The inline functions will contain boxing for the value passed to the lambda.
// 8 valueOf
// After inlining there will be boxing and unboxing that is not needed. That should be optimized out.
// 0 intValue
// 0 booleanValue
// 0 charValue
// 0 byteValue
// 0 shortValue
// 0 floatValue
// 0 longValue
// 0 doubleValue