[JS_IR] Forbid to inline constants during const lowering

This commit is contained in:
Ivan Kylchik
2023-06-16 20:44:44 +02:00
committed by Space Team
parent d3d28783c5
commit 31e75cc603
5 changed files with 30 additions and 21 deletions
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.backend.common.lower.inline.LocalClassesInInlineLamb
import org.jetbrains.kotlin.backend.common.lower.loops.ForLoopsLowering
import org.jetbrains.kotlin.backend.common.lower.optimizations.FoldConstantLowering
import org.jetbrains.kotlin.backend.common.phaser.*
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.ir.backend.js.lower.*
import org.jetbrains.kotlin.ir.backend.js.lower.calls.CallsLowering
import org.jetbrains.kotlin.ir.backend.js.lower.cleanup.CleanupLowering
@@ -836,11 +837,16 @@ private val jsSuspendArityStorePhase = makeDeclarationTransformerPhase(
)
val constEvaluationPhase = makeJsModulePhase(
{
ConstEvaluationLowering(
it,
configuration = IrInterpreterConfiguration(printOnlyExceptionMessage = true, platform = JsPlatforms.defaultJsPlatform)
{ context ->
// We can't inline `const val`s because this lowering can mess up incremental compilation.
// For example, if we inline some constant located in `lib` module then we are not going to track and update its value on change.
// The only usages of `const val`s that we allow to inline are the ones that are located at the same file as declaration.
val configuration = IrInterpreterConfiguration(
printOnlyExceptionMessage = true,
platform = JsPlatforms.defaultJsPlatform,
inlineConstVal = false
)
ConstEvaluationLowering(context, configuration = configuration)
},
name = "ConstEvaluationLowering",
description = "Evaluate functions that are marked as `IntrinsicConstEvaluation`",