From 05373c433b70e97cd6f9dad474e65b16f5c40202 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Fri, 19 Apr 2024 17:42:42 +0200 Subject: [PATCH] [CLI] Include klib generation into IR translation time measurements #KT-67473 (cherry picked from commit 2816d55d4f9717bf2ca7b76dd8574b62b197dbd7) --- .../src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt | 7 ++++++- .../src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt | 4 ++++ .../src/org/jetbrains/kotlin/ir/backend/js/compiler.kt | 3 --- .../src/org/jetbrains/kotlin/backend/wasm/compiler.kt | 1 - 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index 81beddc11bf1b..6cd675e082c42 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -289,7 +289,10 @@ class K2JsIrCompiler : CLICompiler() { return OK } - if (!arguments.irProduceJs) return OK + if (!arguments.irProduceJs) { + performanceManager?.notifyIRTranslationFinished() + return OK + } val moduleKind = configurationJs[JSConfigurationKeys.MODULE_KIND] ?: error("cannot get 'module kind' from configuration") @@ -329,6 +332,7 @@ class K2JsIrCompiler : CLICompiler() { messageCollector.report(INFO, "IC module builder rebuilt JS for module [${File(module).name}]") } + performanceManager?.notifyIRTranslationFinished() return OK } @@ -573,6 +577,7 @@ class K2JsIrCompiler : CLICompiler() { } // FIR2IR + performanceManager?.notifyIRTranslationStarted() val fir2IrActualizedResult = transformFirToIr(moduleStructure, analyzedOutput.output, diagnosticsReporter) if (configuration.getBoolean(CommonConfigurationKeys.INCREMENTAL_COMPILATION)) { diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt index 8498aee468c18..aa0445681a636 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.backend.common.serialization.ICData import org.jetbrains.kotlin.backend.common.serialization.mangle.ManglerChecker import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.Ir2DescriptorManglerAdapter import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor +import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.languageVersionSettings @@ -59,6 +60,9 @@ fun generateIrForKlibSerialization( verifySignatures: Boolean = true, getDescriptorByLibrary: (KotlinLibrary) -> ModuleDescriptor, ): Pair { + val performanceManager = configuration[CLIConfigurationKeys.PERF_MANAGER] + performanceManager?.notifyIRTranslationStarted() + val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT val messageLogger = configuration.get(IrMessageLogger.IR_MESSAGE_LOGGER) ?: IrMessageLogger.None val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), irFactory) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt index 4a34c6d6cbdfd..cae62d3e91b17 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt @@ -50,9 +50,6 @@ fun compile( filesToLower: Set? = null, granularity: JsGenerationGranularity = JsGenerationGranularity.WHOLE_PROGRAM, ): LoweredIr { - val performanceManager = depsDescriptors.compilerConfiguration[CLIConfigurationKeys.PERF_MANAGER] - performanceManager?.notifyIRTranslationStarted() - val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer, moduleToName) = loadIr(depsDescriptors, irFactory, verifySignatures, filesToLower, loadFunctionInterfacesIntoStdlib = true) diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt index 44cbd148516c7..9cdea949ad94c 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt @@ -53,7 +53,6 @@ fun compileToLoweredIr( val mainModule = depsDescriptors.mainModule val configuration = depsDescriptors.compilerConfiguration val performanceManager = depsDescriptors.compilerConfiguration[CLIConfigurationKeys.PERF_MANAGER] - performanceManager?.notifyIRTranslationStarted() val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, irLinker) = loadIr( depsDescriptors,