[K/N] Rename file initializers to static initializers

This commit is contained in:
Pavel Kunyavskiy
2022-11-16 14:33:53 +01:00
committed by Space Team
parent d09a18c88b
commit 9516094755
5 changed files with 15 additions and 15 deletions
@@ -444,10 +444,10 @@ internal val constantInliningPhase = makeKonanFileLoweringPhase(
description = "Inline const fields reads", description = "Inline const fields reads",
) )
internal val fileInitializersPhase = makeKonanFileLoweringPhase( internal val staticInitializersPhase = makeKonanFileLoweringPhase(
::FileInitializersLowering, ::StaticInitializersLowering,
name = "FileInitializers", name = "StaticInitializers",
description = "Add calls to file initializers", description = "Add calls to static initializers",
prerequisite = setOf(expressionBodyTransformPhase) prerequisite = setOf(expressionBodyTransformPhase)
) )
@@ -293,7 +293,7 @@ internal val allLoweringsPhase = SameTypeNamedCompilerPhase(
typeOperatorPhase, typeOperatorPhase,
expressionBodyTransformPhase, expressionBodyTransformPhase,
constantInliningPhase, constantInliningPhase,
fileInitializersPhase, staticInitializersPhase,
bridgesPhase, bridgesPhase,
exportInternalAbiPhase, exportInternalAbiPhase,
useInternalAbiPhase, useInternalAbiPhase,
@@ -401,7 +401,7 @@ internal val bitcodePhase = SameTypeNamedCompilerPhase(
buildDFGPhase then buildDFGPhase then
devirtualizationAnalysisPhase then devirtualizationAnalysisPhase then
dcePhase then dcePhase then
removeRedundantCallsToFileInitializersPhase then removeRedundantCallsToStaticInitializersPhase then
devirtualizationPhase then devirtualizationPhase then
propertyAccessorInlinePhase then // Have to run after link dependencies phase, because fields propertyAccessorInlinePhase then // Have to run after link dependencies phase, because fields
// from dependencies can be changed during lowerings. // from dependencies can be changed during lowerings.
@@ -568,13 +568,13 @@ internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) {
disable(unboxInlinePhase) disable(unboxInlinePhase)
disable(inlineClassPropertyAccessorsPhase) disable(inlineClassPropertyAccessorsPhase)
disable(dcePhase) disable(dcePhase)
disable(removeRedundantCallsToFileInitializersPhase) disable(removeRedundantCallsToStaticInitializersPhase)
disable(ghaPhase) disable(ghaPhase)
} }
disableUnless(verifyBitcodePhase, config.needCompilerVerification || getBoolean(KonanConfigKeys.VERIFY_BITCODE)) disableUnless(verifyBitcodePhase, config.needCompilerVerification || getBoolean(KonanConfigKeys.VERIFY_BITCODE))
disableUnless(fileInitializersPhase, config.propertyLazyInitialization) disableUnless(staticInitializersPhase, config.propertyLazyInitialization)
disableUnless(removeRedundantCallsToFileInitializersPhase, config.propertyLazyInitialization) disableUnless(removeRedundantCallsToStaticInitializersPhase, config.propertyLazyInitialization)
disableUnless(removeRedundantSafepointsPhase, config.memoryModel == MemoryModel.EXPERIMENTAL) disableUnless(removeRedundantSafepointsPhase, config.memoryModel == MemoryModel.EXPERIMENTAL)
@@ -170,9 +170,9 @@ internal val dcePhase = makeKonanModuleOpPhase(
} }
) )
internal val removeRedundantCallsToFileInitializersPhase = makeKonanModuleOpPhase( internal val removeRedundantCallsToStaticInitializersPhase = makeKonanModuleOpPhase(
name = "RemoveRedundantCallsToFileInitializersPhase", name = "RemoveRedundantCallsToStaticInitializersPhase",
description = "Redundant file initializers calls removal", description = "Redundant static initializers calls removal",
prerequisite = setOf(devirtualizationAnalysisPhase), prerequisite = setOf(devirtualizationAnalysisPhase),
op = { context, _ -> op = { context, _ ->
val moduleDFG = context.moduleDFG!! val moduleDFG = context.moduleDFG!!
@@ -189,7 +189,7 @@ internal val removeRedundantCallsToFileInitializersPhase = makeKonanModuleOpPhas
.mapNotNull { it.irFunction } .mapNotNull { it.irFunction }
.toSet() .toSet()
FileInitializersOptimization.removeRedundantCalls(context, callGraph, rootSet) StaticInitializersOptimization.removeRedundantCalls(context, callGraph, rootSet)
} }
) )
@@ -44,7 +44,7 @@ internal val IrField.shouldBeInitializedEagerly: Boolean
} }
// TODO: ExplicitlyExported for IR proto are not longer needed. // TODO: ExplicitlyExported for IR proto are not longer needed.
internal class FileInitializersLowering(val context: Context) : FileLoweringPass { internal class StaticInitializersLowering(val context: Context) : FileLoweringPass {
override fun lower(irFile: IrFile) { override fun lower(irFile: IrFile) {
var requireGlobalInitializer = false var requireGlobalInitializer = false
var requireThreadLocalInitializer = false var requireThreadLocalInitializer = false
@@ -52,7 +52,7 @@ import java.util.*
* set after evaluating that expression. * set after evaluating that expression.
*/ */
internal object FileInitializersOptimization { internal object StaticInitializersOptimization {
private class AnalysisResult(val functionsRequiringGlobalInitializerCall: Set<IrFunction>, private class AnalysisResult(val functionsRequiringGlobalInitializerCall: Set<IrFunction>,
val functionsRequiringThreadLocalInitializerCall: Set<IrFunction>, val functionsRequiringThreadLocalInitializerCall: Set<IrFunction>,
val callSitesRequiringGlobalInitializerCall: Set<IrFunctionAccessExpression>, val callSitesRequiringGlobalInitializerCall: Set<IrFunctionAccessExpression>,