Store stack values before inlines. #KT-5634 Fixed

Inlining code violates JIT assumptions for OSR in Java 8 in case of
starting with non-empty and containing cycles.

Fix is to mark each inlined block with markers and then store/restore
stack state before and after inlined body.
This commit is contained in:
Denis Zharkov
2014-08-21 08:04:50 +04:00
committed by Andrey Breslav
parent 469db95662
commit f1d9d11590
15 changed files with 468 additions and 3 deletions
@@ -0,0 +1,16 @@
inline fun bar(x: Int, y: Long, z: Byte, s: String) = x.toString() + y.toString() + z.toString() + s
fun foobar(x: Int, y: Long, s: String, z: Byte) = x.toString() + y.toString() + s + z.toString()
fun foo() : String {
return foobar(1, 2L, bar(3, 4L, 5.toByte(), "6"), 7.toByte())
}
// 3 ISTORE
// 11 ILOAD
// 2 ASTORE
// 8 ALOAD
// 2 LSTORE
// 6 LLOAD
// 1 MAXLOCALS = 9
// 0 InlineMarker
@@ -0,0 +1,16 @@
fun bar() : Boolean = true
fun foobar(x: Boolean, y: String, z: String) = x.toString() + y + z
inline fun foo() = "-"
fun box() {
val result = foobar(if (1 == 1) true else bar(), foo(), "OK")
}
// 1 ISTORE
// 3 ILOAD
// 2 ASTORE
// 7 ALOAD
// 3 MAXLOCALS = 3
// 0 InlineMarker
@@ -0,0 +1,14 @@
inline fun bar(x: Int) : Int {
return x
}
fun foobar(x: Int, y: Int, z: Int) = x + y + z
fun foo() : Int {
return foobar(1, bar(2), 3)
}
// 3 ISTORE
// 11 ILOAD
// 0 InlineMarker
@@ -0,0 +1,21 @@
inline fun bar(block: () -> String) : String {
return block()
}
inline fun bar2() : String {
return bar { return "def" }
}
fun foobar(x: String, y: String, z: String) = x + y + z
fun foo() : String {
return foobar(
"abc",
bar2(),
"ghi"
)
}
// 12 ALOAD
// 0 ASTORE
// 0 InlineMarker
@@ -0,0 +1,11 @@
inline fun bar(x: String, block: (String) -> String) = "def" + block(x)
fun foobar(x: String, y: String, z: String) = x + y + z
fun foo() : String {
return foobar("abc", bar("ghi") { x -> x + "jkl" }, "mno")
}
// 6 ASTORE
// 21 ALOAD
// 1 MAXLOCALS = 5
// 0 InlineMarker