[K2] Create and add EvaluatedConstTracker in configuration

This commit is contained in:
Ivan Kylchik
2023-04-06 11:06:21 +02:00
committed by Space Team
parent 37c3dff0c5
commit 0b70b7904d
13 changed files with 73 additions and 22 deletions
@@ -10,9 +10,20 @@ import java.util.concurrent.ConcurrentHashMap
abstract class EvaluatedConstTracker {
abstract fun save(start: Int, end: Int, constant: ConstantValue<*>)
abstract fun load(start: Int, end: Int): ConstantValue<*>?
companion object {
/**
* Right now there are two places where we want to create this tracker.
* 1. Right before `fir2ir` phase. We need to store evaluated values to use them later in const value serialization.
* 2. In interpreter's tests for all IR backends. This is needed ONLY for tests and cover case when we run K1 IR compiler.
*/
fun create(): EvaluatedConstTracker {
return DefaultEvaluatedConstTracker()
}
}
}
class DefaultEvaluatedConstTracker : EvaluatedConstTracker() {
private class DefaultEvaluatedConstTracker : EvaluatedConstTracker() {
private val storage = ConcurrentHashMap<Pair<Int, Int>, ConstantValue<*>>()
override fun save(start: Int, end: Int, constant: ConstantValue<*>) {