Skip to content

Commit

Permalink
[CLI] Include klib generation into IR translation time measurements
Browse files Browse the repository at this point in the history
#KT-67473

(cherry picked from commit 2816d55)
  • Loading branch information
ivandev0 authored and qodana-bot committed Apr 30, 2024
1 parent cc379a8 commit 05373c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
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")

Expand Down Expand Up @@ -329,6 +332,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
messageCollector.report(INFO, "IC module builder rebuilt JS for module [${File(module).name}]")
}

performanceManager?.notifyIRTranslationFinished()
return OK
}

Expand Down Expand Up @@ -573,6 +577,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}

// FIR2IR
performanceManager?.notifyIRTranslationStarted()
val fir2IrActualizedResult = transformFirToIr(moduleStructure, analyzedOutput.output, diagnosticsReporter)

if (configuration.getBoolean(CommonConfigurationKeys.INCREMENTAL_COMPILATION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +60,9 @@ fun generateIrForKlibSerialization(
verifySignatures: Boolean = true,
getDescriptorByLibrary: (KotlinLibrary) -> ModuleDescriptor,
): Pair<IrModuleFragment, IrPluginContext> {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ fun compile(
filesToLower: Set<String>? = 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 05373c4

Please sign in to comment.