From fae003866bb3449c349521c1d1180beb5e6afade Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Thu, 21 Mar 2019 17:18:07 +0300 Subject: [PATCH] Use CLI compiler arguments directly in PhaseConfig creation --- .../arguments/CommonCompilerArguments.kt | 24 +++++++ .../cli/common/CLIConfigurationKeys.java | 4 ++ .../jetbrains/kotlin/cli/common/arguments.kt | 16 ----- .../kotlin/cli/common/createPhaseConfig.kt | 67 ++++++++++--------- .../jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 3 + .../compiler/KotlinToJVMBytecodeCompiler.kt | 8 ++- .../kotlin/config/CommonConfigurationKeys.kt | 39 ----------- .../backend/common/phaser/CompilerPhase.kt | 6 +- .../backend/common/phaser/DumperVerifier.kt | 17 +++-- .../backend/common/phaser/PhaseConfig.kt | 3 +- .../kotlin/backend/jvm/JvmBackendContext.kt | 6 -- compiler/testData/cli/js/jsExtraHelp.out | 4 ++ compiler/testData/cli/jvm/extraHelp.out | 4 ++ .../kotlin/codegen/GenerationUtils.kt | 6 +- .../generators/tests/GenerateIrRuntime.kt | 5 +- .../kotlin/js/test/BasicIrBoxTest.kt | 5 +- 16 files changed, 105 insertions(+), 112 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 8810ad00e92..ba494948e33 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -232,6 +232,30 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) var phasesToDump: Array? by FreezableVar(null) + @Argument( + value = "-Xexclude-from-dumping", + description = "Names of elements that should not be dumped" + ) + var namesExcludedFromDumping: Array? by FreezableVar(null) + + @Argument( + value = "-Xphases-to-validate-before", + description = "Validate backend state before these phases" + ) + var phasesToValidateBefore: Array? by FreezableVar(null) + + @Argument( + value = "-Xphases-to-validate-after", + description = "Validate backend state after these phases" + ) + var phasesToValidateAfter: Array? by FreezableVar(null) + + @Argument( + value = "-Xphases-to-validate", + description = "Validate backend state both before and after these phases" + ) + var phasesToValidate: Array? by FreezableVar(null) + @Argument( value = "-Xprofile-phases", description = "Profile backend phases" diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java index 49ec52faf84..a27d7681e97 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.cli.common; +import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig; import org.jetbrains.kotlin.cli.common.config.ContentRoot; import org.jetbrains.kotlin.cli.common.messages.MessageCollector; import org.jetbrains.kotlin.config.CompilerConfigurationKey; @@ -44,6 +45,9 @@ public class CLIConfigurationKeys { public static final CompilerConfigurationKey METADATA_DESTINATION_DIRECTORY = CompilerConfigurationKey.create("metadata destination directory"); + public static final CompilerConfigurationKey PHASE_CONFIG = + CompilerConfigurationKey.create("phase configuration"); + private CLIConfigurationKeys() { } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt index 8b63db07a10..7621128d6a2 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt @@ -39,22 +39,6 @@ fun CompilerConfiguration.setupCommonArguments( } setupLanguageVersionSettings(arguments) - - put(CommonConfigurationKeys.LIST_PHASES, arguments.listPhases) - - listOf( - CommonConfigurationKeys.DISABLED_PHASES to arguments.disablePhases, - CommonConfigurationKeys.VERBOSE_PHASES to arguments.verbosePhases, - CommonConfigurationKeys.PHASES_TO_DUMP_STATE_BEFORE to arguments.phasesToDumpBefore, - CommonConfigurationKeys.PHASES_TO_DUMP_STATE_AFTER to arguments.phasesToDumpAfter, - CommonConfigurationKeys.PHASES_TO_DUMP_STATE to arguments.phasesToDump - ).forEach { (k, v) -> - if (v != null) put(k, setOf(*v)) - } - - put(CommonConfigurationKeys.PROFILE_PHASES, arguments.profilePhases) - put(CommonConfigurationKeys.CHECK_PHASE_CONDITIONS, arguments.checkPhaseConditions or arguments.checkStickyPhaseConditions) - put(CommonConfigurationKeys.CHECK_STICKY_CONDITIONS, arguments.checkStickyPhaseConditions) } fun CompilerConfiguration.setupLanguageVersionSettings(arguments: A) { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/createPhaseConfig.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/createPhaseConfig.kt index 891cc0b8fa6..eae4f57b8e5 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/createPhaseConfig.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/createPhaseConfig.kt @@ -9,62 +9,69 @@ import org.jetbrains.kotlin.backend.common.phaser.AnyNamedPhase import org.jetbrains.kotlin.backend.common.phaser.CompilerPhase import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig import org.jetbrains.kotlin.backend.common.phaser.toPhaseMap +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.CommonConfigurationKeys -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.config.CompilerConfigurationKey -fun createPhaseConfig(compoundPhase: CompilerPhase<*, *, *>, config: CompilerConfiguration): PhaseConfig { +fun createPhaseConfig( + compoundPhase: CompilerPhase<*, *, *>, + arguments: CommonCompilerArguments, + messageCollector: MessageCollector +): PhaseConfig { + fun warn(message: String) = messageCollector.report(CompilerMessageSeverity.WARNING, message) + val phases = compoundPhase.toPhaseMap() - val enabled = computeEnabled(phases, config).toMutableSet() - val verbose = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.VERBOSE_PHASES) + val enabled = computeEnabled(phases, arguments.disablePhases, ::warn).toMutableSet() + val verbose = phaseSetFromArguments(phases, arguments.verbosePhases, ::warn) - val beforeDumpSet = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.PHASES_TO_DUMP_STATE_BEFORE) - val afterDumpSet = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.PHASES_TO_DUMP_STATE_AFTER) - val bothDumpSet = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.PHASES_TO_DUMP_STATE) + val beforeDumpSet = phaseSetFromArguments(phases, arguments.phasesToDumpBefore, ::warn) + val afterDumpSet = phaseSetFromArguments(phases, arguments.phasesToDumpAfter, ::warn) + val bothDumpSet = phaseSetFromArguments(phases, arguments.phasesToDump, ::warn) val toDumpStateBefore = beforeDumpSet + bothDumpSet val toDumpStateAfter = afterDumpSet + bothDumpSet - val beforeValidateSet = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.PHASES_TO_VALIDATE_BEFORE) - val afterValidateSet = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.PHASES_TO_VALIDATE_AFTER) - val bothValidateSet = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.PHASES_TO_VALIDATE) + val beforeValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateBefore, ::warn) + val afterValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateAfter, ::warn) + val bothValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidate, ::warn) val toValidateStateBefore = beforeValidateSet + bothValidateSet val toValidateStateAfter = afterValidateSet + bothValidateSet - val needProfiling = config.getBoolean(CommonConfigurationKeys.PROFILE_PHASES) - val checkConditions = config.getBoolean(CommonConfigurationKeys.CHECK_PHASE_CONDITIONS) - val checkStickyConditions = config.getBoolean(CommonConfigurationKeys.CHECK_STICKY_CONDITIONS) + val namesOfElementsExcludedFromDumping = arguments.namesExcludedFromDumping?.toSet() ?: emptySet() + + val needProfiling = arguments.profilePhases + val checkConditions = arguments.checkPhaseConditions + val checkStickyConditions = arguments.checkStickyPhaseConditions return PhaseConfig( compoundPhase, phases, enabled, verbose, toDumpStateBefore, toDumpStateAfter, toValidateStateBefore, toValidateStateAfter, + namesOfElementsExcludedFromDumping, needProfiling, checkConditions, checkStickyConditions - ) + ).also { + if (arguments.listPhases) { + it.list() + } + } } private fun computeEnabled( phases: MutableMap, - config: CompilerConfiguration + namesOfDisabled: Array?, + warn: (String) -> Unit ): Set { - val disabledPhases = phaseSetFromConfiguration(phases, config, CommonConfigurationKeys.DISABLED_PHASES) + val disabledPhases = phaseSetFromArguments(phases, namesOfDisabled, warn) return phases.values.toSet() - disabledPhases } -private fun phaseSetFromConfiguration( +private fun phaseSetFromArguments( phases: MutableMap, - config: CompilerConfiguration, - key: CompilerConfigurationKey> + names: Array?, + warn: (String) -> Unit ): Set { - val phaseNames = config.get(key) ?: emptySet() - if ("ALL" in phaseNames) return phases.values.toSet() - return phaseNames.mapNotNull { + if (names == null) return emptySet() + if ("ALL" in names) return phases.values.toSet() + return names.mapNotNull { phases[it] ?: run { - warn(config, "no phase named $it, ignoring") + warn("no phase named $it, ignoring") null } }.toSet() } - -private fun warn(config: CompilerConfiguration, message: String) { - val messageCollector = config.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) ?: MessageCollector.NONE - messageCollector.report(CompilerMessageSeverity.WARNING, message) -} diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 73b405bb1c4..1c665e80c0e 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli.jvm import com.intellij.ide.highlighter.JavaFileType import com.intellij.openapi.Disposable +import org.jetbrains.kotlin.backend.jvm.jvmPhases import org.jetbrains.kotlin.cli.common.* import org.jetbrains.kotlin.cli.common.ExitCode.* import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments @@ -62,6 +63,8 @@ class K2JVMCompiler : CLICompiler() { ): ExitCode { val messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) + configuration.put(CLIConfigurationKeys.PHASE_CONFIG, createPhaseConfig(jvmPhases, arguments, messageCollector)) + if (!configuration.configureJdkHome(arguments)) return COMPILATION_ERROR configuration.put(JVMConfigurationKeys.DISABLE_STANDARD_SCRIPT_DEFINITION, arguments.disableStandardScript) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt index f10a473e020..4ae5a5ac6bd 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt @@ -28,13 +28,13 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.asJava.FilteredJvmDiagnostics import org.jetbrains.kotlin.backend.common.output.OutputFileCollection import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection +import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory import org.jetbrains.kotlin.backend.jvm.jvmPhases import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.checkKotlinPackageUsage import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot -import org.jetbrains.kotlin.cli.common.createPhaseConfig import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.OUTPUT import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.WARNING @@ -441,7 +441,11 @@ object KotlinToJVMBytecodeCompiler { sourceFiles, configuration ) - .codegenFactory(if (isIR) JvmIrCodegenFactory(createPhaseConfig(jvmPhases, configuration)) else DefaultCodegenFactory) + .codegenFactory( + if (isIR) JvmIrCodegenFactory( + configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases) + ) else DefaultCodegenFactory + ) .withModule(module) .onIndependentPartCompilationEnd(createOutputFilesFlushingCallbackIfPossible(configuration)) .build() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt b/compiler/frontend/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt index 2b9db8b581d..d9f39f7a971 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt @@ -41,45 +41,6 @@ object CommonConfigurationKeys { @JvmField val METADATA_VERSION = CompilerConfigurationKey.create("metadata version") - - @JvmField - val LIST_PHASES = CompilerConfigurationKey.create("list names of backend phases") - - @JvmField - val DISABLED_PHASES = CompilerConfigurationKey.create>("disable backend phases") - - @JvmField - val PHASES_TO_DUMP_STATE_BEFORE = CompilerConfigurationKey.create>("backend phases where we dump compiler state before the phase") - - @JvmField - val PHASES_TO_DUMP_STATE_AFTER = CompilerConfigurationKey.create>("backend phases where we dump compiler state after the phase") - - @JvmField - val PHASES_TO_DUMP_STATE = CompilerConfigurationKey.create>("backend phases where we dump compiler state both before and after the phase") - - @JvmField - val PHASES_TO_VALIDATE_BEFORE = CompilerConfigurationKey.create>("backend phases where we validate Ir before the phase") - - @JvmField - val PHASES_TO_VALIDATE_AFTER = CompilerConfigurationKey.create>("backend phases where we validate Ir after the phase") - - @JvmField - val PHASES_TO_VALIDATE = CompilerConfigurationKey.create>("backend phases where we validate Ir both before and after the phase") - - @JvmField - val VERBOSE_PHASES = CompilerConfigurationKey.create>("verbose backend phases") - - @JvmField - val PROFILE_PHASES = CompilerConfigurationKey.create("profile backend phase execution") - - @JvmField - val CHECK_PHASE_CONDITIONS = CompilerConfigurationKey.create("run pre- and postcondition checkers for phases") - - @JvmField - val CHECK_STICKY_CONDITIONS = CompilerConfigurationKey.create("run sticky postcondition checkers on subsequent phases as well") - - @JvmField - val EXCLUDED_ELEMENTS_FROM_DUMPING = CompilerConfigurationKey.create>("lowering elements which shouldn't be dumped at all") } var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt index ecdfbfdd3b9..16fd3d0933d 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt @@ -57,7 +57,7 @@ typealias AnyNamedPhase = NamedCompilerPhase<*, *, *> enum class BeforeOrAfter { BEFORE, AFTER } interface PhaseDumperVerifier { - fun dump(phase: AnyNamedPhase, context: Context, data: Data, beforeOrAfter: BeforeOrAfter) + fun dump(phase: AnyNamedPhase, phaseConfig: PhaseConfig, data: Data, beforeOrAfter: BeforeOrAfter) fun verify(context: Context, data: Data) } @@ -97,7 +97,7 @@ abstract class AbstractNamedPhaseWrapper, context: Context, output: Output) { - checkAndRun(phaseConfig.toDumpStateAfter) { outputDumperVerifier.dump(this, context, output, BeforeOrAfter.AFTER) } + checkAndRun(phaseConfig.toDumpStateAfter) { outputDumperVerifier.dump(this, phaseConfig, output, BeforeOrAfter.AFTER) } checkAndRun(phaseConfig.toValidateStateAfter) { outputDumperVerifier.verify(context, output) } if (phaseConfig.checkConditions) { for (post in postconditions) post(output) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/DumperVerifier.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/DumperVerifier.kt index 977bbe41990..1cdba78d2b2 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/DumperVerifier.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/DumperVerifier.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.backend.common.phaser import org.jetbrains.kotlin.backend.common.CommonBackendContext -import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment @@ -14,15 +13,15 @@ import org.jetbrains.kotlin.ir.declarations.name import org.jetbrains.kotlin.ir.util.dump abstract class IrPhaseDumperVerifier( - val verifier: (Context, Data) -> Unit + val verifier: (Context, Data) -> Unit ) : PhaseDumperVerifier { abstract fun Data.getElementName(): String // TODO: use a proper logger. - override fun dump(phase: AnyNamedPhase, context: Context, data: Data, beforeOrAfter: BeforeOrAfter) { + override fun dump(phase: AnyNamedPhase, phaseConfig: PhaseConfig, data: Data, beforeOrAfter: BeforeOrAfter) { fun separator(title: String) = println("\n\n--- $title ----------------------\n") - if (!shouldBeDumped(context, data)) return + if (!shouldBeDumped(phaseConfig, data)) return val beforeOrAfterStr = beforeOrAfter.name.toLowerCase() val title = "IR for ${data.getElementName()} $beforeOrAfterStr ${phase.description}" @@ -32,22 +31,22 @@ abstract class IrPhaseDumperVerifier(verifier: (Context, IrFile) -> Unit) : - IrPhaseDumperVerifier(verifier) { + IrPhaseDumperVerifier(verifier) { override fun IrFile.getElementName() = name } class IrModuleDumperVerifier(verifier: (Context, IrModuleFragment) -> Unit) : - IrPhaseDumperVerifier(verifier) { + IrPhaseDumperVerifier(verifier) { override fun IrModuleFragment.getElementName() = name.asString() } class EmptyDumperVerifier : PhaseDumperVerifier { - override fun dump(phase: AnyNamedPhase, context: Context, data: Data, beforeOrAfter: BeforeOrAfter) {} + override fun dump(phase: AnyNamedPhase, phaseConfig: PhaseConfig, data: Data, beforeOrAfter: BeforeOrAfter) {} override fun verify(context: Context, data: Data) {} } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt index 889c1b1bfd9..6d64af9d937 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.backend.common.phaser fun CompilerPhase<*, *, *>.toPhaseMap(): MutableMap = getNamedSubphases().fold(mutableMapOf()) { acc, (_, phase) -> - check(phase.name !in acc) { "Duplicate phase name '${phase.name}'"} + check(phase.name !in acc) { "Duplicate phase name '${phase.name}'" } acc[phase.name] = phase acc } @@ -21,6 +21,7 @@ class PhaseConfig( val toDumpStateAfter: Set = emptySet(), val toValidateStateBefore: Set = emptySet(), val toValidateStateAfter: Set = emptySet(), + val namesOfElementsExcludedFromDumping: Set = emptySet(), val needProfiling: Boolean = false, val checkConditions: Boolean = false, val checkStickyConditions: Boolean = false diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index ed02c242ae3..34d25acc994 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -44,12 +44,6 @@ class JvmBackendContext( override val configuration get() = state.configuration - init { - if (state.configuration.get(CommonConfigurationKeys.LIST_PHASES) == true) { - phaseConfig.list() - } - } - private fun getJvmInternalClass(name: String): ClassDescriptor { return getClass(FqName("kotlin.jvm.internal").child(Name.identifier(name))) } diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 0f86c1e3290..579140b19ff 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -21,12 +21,16 @@ where advanced options include: -Xlist-phases List backend phases -Xmetadata-version Change metadata version of the generated binary files -Xmulti-platform Enable experimental language support for multi-platform projects + -Xexclude-from-dumping Names of elements that should not be dumped -Xnew-inference Enable new experimental generic type inference algorithm -Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects -Xno-inline Disable method inlining -Xphases-to-dump Dump backend state both before and after these phases -Xphases-to-dump-after Dump backend state after these phases -Xphases-to-dump-before Dump backend state before these phases + -Xphases-to-validate Validate backend state both before and after these phases + -Xphases-to-validate-after Validate backend state after these phases + -Xphases-to-validate-before Validate backend state before these phases -Xplugin= Load plugins from the given classpath -Xprofile-phases Profile backend phases -Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index f3d850770c0..a481b348762 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -85,12 +85,16 @@ where advanced options include: -Xlist-phases List backend phases -Xmetadata-version Change metadata version of the generated binary files -Xmulti-platform Enable experimental language support for multi-platform projects + -Xexclude-from-dumping Names of elements that should not be dumped -Xnew-inference Enable new experimental generic type inference algorithm -Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects -Xno-inline Disable method inlining -Xphases-to-dump Dump backend state both before and after these phases -Xphases-to-dump-after Dump backend state after these phases -Xphases-to-dump-before Dump backend state before these phases + -Xphases-to-validate Validate backend state both before and after these phases + -Xphases-to-validate-after Validate backend state after these phases + -Xphases-to-validate-before Validate backend state before these phases -Xplugin= Load plugins from the given classpath -Xprofile-phases Profile backend phases -Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt index ec2ef77132d..372be745c55 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt @@ -18,9 +18,10 @@ package org.jetbrains.kotlin.codegen import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.TestsCompiletimeError +import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory import org.jetbrains.kotlin.backend.jvm.jvmPhases -import org.jetbrains.kotlin.cli.common.createPhaseConfig +import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.output.writeAllTo import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.NoScopeRecordCliBindingTrace @@ -76,7 +77,8 @@ object GenerationUtils { files.first().project, classBuilderFactory, analysisResult.moduleDescriptor, analysisResult.bindingContext, files, configuration ).codegenFactory( - if (configuration.getBoolean(JVMConfigurationKeys.IR)) JvmIrCodegenFactory(createPhaseConfig(jvmPhases, configuration)) + if (configuration.getBoolean(JVMConfigurationKeys.IR)) + JvmIrCodegenFactory(configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases)) else DefaultCodegenFactory ).build() if (analysisResult.shouldGenerateCode) { diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateIrRuntime.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateIrRuntime.kt index 0dc978014ef..f54348c5943 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateIrRuntime.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateIrRuntime.kt @@ -9,7 +9,8 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiManager -import org.jetbrains.kotlin.cli.common.createPhaseConfig +import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig +import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.config.* @@ -64,7 +65,7 @@ fun main() { project = environment.project, files = sources.map(::createPsiFile), configuration = configuration, - phaseConfig = createPhaseConfig(jsPhases, configuration), + phaseConfig = configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jsPhases), compileMode = CompilationMode.KLIB, immediateDependencies = emptyList(), allDependencies = emptyList(), diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt index db4b88934bc..63d81352016 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt @@ -5,7 +5,8 @@ package org.jetbrains.kotlin.js.test -import org.jetbrains.kotlin.cli.common.createPhaseConfig +import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig +import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.backend.js.* import org.jetbrains.kotlin.js.config.JSConfigurationKeys @@ -110,7 +111,7 @@ abstract class BasicIrBoxTest( project = config.project, files = filesToCompile, configuration = config.configuration, - phaseConfig = createPhaseConfig(jsPhases, config.configuration), + phaseConfig = config.configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jsPhases), compileMode = if (isMainModule) CompilationMode.JS else CompilationMode.KLIB, immediateDependencies = dependencies, allDependencies = allDependencies,