Limit stack allocation only for array read operations with connection between return value and array (#3728)
This commit is contained in:
+4
-2
@@ -134,8 +134,10 @@ internal object LocalEscapeAnalysis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is DataFlowIR.Node.ArrayRead -> {
|
is DataFlowIR.Node.ArrayRead -> {
|
||||||
// If element of array escapes then array also should escape.
|
// If element of array(return value) points to array(this value) and escapes then array also should escape.
|
||||||
connectObjects(node, node.array.node)
|
if (((node.callee.pointsTo?.elementAtOrNull(node.callee.parameters.size) ?: 0) and (1 shl 0)) != 0) {
|
||||||
|
connectObjects(node, node.array.node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1789,6 +1789,11 @@ task BitSet(type: KonanLocalTest) {
|
|||||||
source = "runtime/collections/BitSet.kt"
|
source = "runtime/collections/BitSet.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task stack_array(type: KonanLocalTest) {
|
||||||
|
goldValue = "true\n3\n"
|
||||||
|
source = "runtime/collections/stack_array.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task array0(type: KonanLocalTest) {
|
task array0(type: KonanLocalTest) {
|
||||||
goldValue = "5\n6\n7\n8\n9\n10\n11\n12\n13\n"
|
goldValue = "5\n6\n7\n8\n9\n10\n11\n12\n13\n"
|
||||||
source = "runtime/collections/array0.kt"
|
source = "runtime/collections/array0.kt"
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package runtime.collections.stack_array
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
val array = IntArray(2)
|
||||||
|
array[0] = 1
|
||||||
|
array[1] = 2
|
||||||
|
val check = array is IntArray
|
||||||
|
println(check)
|
||||||
|
println(array[0] + array[1])
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user