[WASM] Add ConstEvaluationLowering to the lowering list

This commit is contained in:
Ivan Kylchik
2023-11-16 17:16:15 +01:00
committed by Space Team
parent 427c067cd8
commit c82bc8f0ce
50 changed files with 560 additions and 130 deletions
@@ -21,7 +21,10 @@ import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendFunctionsLow
import org.jetbrains.kotlin.ir.backend.js.lower.inline.RemoveInlineDeclarationsWithReifiedTypeParametersLowering
import org.jetbrains.kotlin.ir.backend.wasm.lower.generateMainFunctionCalls
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.interpreter.IrInterpreterConfiguration
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
import org.jetbrains.kotlin.platform.WasmPlatform
import org.jetbrains.kotlin.platform.toTargetPlatform
private fun List<CompilerPhase<WasmBackendContext, IrModuleFragment, IrModuleFragment>>.toCompilerPhase() =
reduce { acc, lowering -> acc.then(lowering) }
@@ -590,6 +593,19 @@ private val inlineObjectsWithPureInitializationLoweringPhase = makeIrModulePhase
prerequisite = setOf(purifyObjectInstanceGettersLoweringPhase)
)
val constEvaluationPhase = makeIrModulePhase(
{ context ->
val configuration = IrInterpreterConfiguration(
printOnlyExceptionMessage = true,
platform = WasmPlatform.toTargetPlatform(),
)
ConstEvaluationLowering(context, configuration = configuration)
},
name = "ConstEvaluationLowering",
description = "Evaluate functions that are marked as `IntrinsicConstEvaluation`",
prerequisite = setOf(functionInliningPhase)
)
val loweringList = listOf(
validateIrBeforeLowering,
jsCodeCallsLowering,
@@ -611,6 +627,7 @@ val loweringList = listOf(
wrapInlineDeclarationsWithReifiedTypeParametersPhase,
functionInliningPhase,
constEvaluationPhase,
removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase,
tailrecLoweringPhase,