Spill stack for inline functions only if it's required
Stack should be spilled before inline function call and restored after call only if one of the following conditions is met: - inline function is a suspend function - inline function has try-catch blocks - inline function has loops (backward jumps) Note that there're quite some "simple" inline functions in Kotlin stdlib besides run/let/with/apply. For example, many string operations are implemented as inline wrappers over Java method calls.
This commit is contained in:
+8
-2
@@ -1,4 +1,10 @@
|
||||
inline fun bar(x: String, block: (String) -> String) = "def" + block(x)
|
||||
inline fun <T> runAfterLoop(fn: () -> T): T {
|
||||
for (i in 1..2);
|
||||
return fn()
|
||||
}
|
||||
|
||||
inline fun bar(x: String, block: (String) -> String) = runAfterLoop { "def" + block(x) }
|
||||
|
||||
fun foobar(x: String, y: String, z: String) = x + y + z
|
||||
|
||||
fun foo() : String {
|
||||
@@ -6,6 +12,6 @@ fun foo() : String {
|
||||
}
|
||||
|
||||
// 6 ASTORE
|
||||
// 16 ALOAD
|
||||
// 18 ALOAD
|
||||
// 1 MAXLOCALS = 7
|
||||
// 0 InlineMarker
|
||||
|
||||
Reference in New Issue
Block a user