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,14 @@
import kotlin.test.assertEquals
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())
}
fun box() : String {
assertEquals("1234567", foo())
return "OK"
}
@@ -0,0 +1,16 @@
import kotlin.test.assertEquals
fun bar() : Boolean = true
fun foobar1(x: Boolean, y: String, z: String) = x.toString() + y + z
fun foobar2(x: Any, y: String, z: String) = x.toString() + y + z
inline fun foo() = "-"
fun box(): String {
val result1 = foobar1(if (1 == 1) true else bar(), foo(), "OK")
val result2 = foobar2(if (1 == 1) "true" else array("false"), foo(), "OK")
assertEquals("true-OK", result1)
assertEquals("true-OK", result2)
return "OK"
}
@@ -0,0 +1,16 @@
import kotlin.test.assertEquals
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)
}
fun box() : String {
assertEquals(6, foo())
return "OK"
}
@@ -0,0 +1,24 @@
import kotlin.test.assertEquals
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"
)
}
fun box() : String {
assertEquals("abcdefghi", foo())
return "OK"
}
@@ -0,0 +1,13 @@
import kotlin.test.assertEquals
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")
}
fun box() : String {
assertEquals("abcdefghijklmno", foo())
return "OK"
}