@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
30
30
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
31
31
import org.jetbrains.kotlin.cli.common.messages.MessageUtil
32
32
import org.jetbrains.kotlin.cli.js.klib.*
33
- import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.K2JVMCompilerPerformanceManager
34
33
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
35
34
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
36
35
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
@@ -316,15 +315,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
316
315
val outputKlibPath =
317
316
if (arguments.irProduceKlibFile) outputDir.resolve(" $outputName .klib" ).normalize().absolutePath
318
317
else outputDirPath
319
- if (configuration.get(CommonConfigurationKeys .USE_FIR ) == true ) {
320
- sourceModule = processSourceModuleWithK2(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
321
- } else {
322
- sourceModule = processSourceModule(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
323
-
324
- if (! sourceModule.jsFrontEndResult.jsAnalysisResult.shouldGenerateCode)
325
- return OK
326
- }
318
+ sourceModule = produceSourceModule(configuration, environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
327
319
320
+ if (configuration.get(CommonConfigurationKeys .USE_FIR ) != true && ! sourceModule.jsFrontEndResult.jsAnalysisResult.shouldGenerateCode)
321
+ return OK
328
322
}
329
323
330
324
if (! arguments.irProduceJs) return OK
@@ -461,13 +455,34 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
461
455
return OK
462
456
}
463
457
464
- private fun processSourceModule (
458
+ private fun produceSourceModule (
459
+ configuration : CompilerConfiguration ,
460
+ environmentForJS : KotlinCoreEnvironment ,
461
+ libraries : List <String >,
462
+ friendLibraries : List <String >,
463
+ arguments : K2JSCompilerArguments ,
464
+ outputKlibPath : String ,
465
+ ): ModulesStructure {
466
+ val performanceManager = configuration.get(CLIConfigurationKeys .PERF_MANAGER )
467
+ performanceManager?.notifyAnalysisStarted()
468
+
469
+ val sourceModule = if (configuration.get(CommonConfigurationKeys .USE_FIR ) == true ) {
470
+ processSourceModuleWithK2(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
471
+ } else {
472
+ processSourceModuleWithK1(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
473
+ }
474
+
475
+ return sourceModule
476
+ }
477
+
478
+ private fun processSourceModuleWithK1 (
465
479
environmentForJS : KotlinCoreEnvironment ,
466
480
libraries : List <String >,
467
481
friendLibraries : List <String >,
468
482
arguments : K2JSCompilerArguments ,
469
483
outputKlibPath : String
470
484
): ModulesStructure {
485
+ val performanceManager = environmentForJS.configuration.get(CLIConfigurationKeys .PERF_MANAGER )
471
486
lateinit var sourceModule: ModulesStructure
472
487
do {
473
488
val analyzerFacade = when (arguments.wasm) {
@@ -488,6 +503,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
488
503
environmentForJS.addKotlinSourceRoots(result.additionalKotlinRoots)
489
504
}
490
505
} while (result is JsAnalysisResult .RetryWithAdditionalRoots )
506
+ performanceManager?.notifyAnalysisFinished()
491
507
492
508
if (sourceModule.jsFrontEndResult.jsAnalysisResult.shouldGenerateCode && (arguments.irProduceKlibDir || arguments.irProduceKlibFile)) {
493
509
val moduleSourceFiles = (sourceModule.mainModule as MainModule .SourceFiles ).files
@@ -536,6 +552,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
536
552
outputKlibPath : String
537
553
): ModulesStructure {
538
554
val configuration = environmentForJS.configuration
555
+ val performanceManager = configuration.get(CLIConfigurationKeys .PERF_MANAGER )
539
556
val messageCollector = configuration.getNotNull(CLIConfigurationKeys .MESSAGE_COLLECTOR_KEY )
540
557
val diagnosticsReporter = DiagnosticReporterFactory .createPendingReporter()
541
558
@@ -576,6 +593,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
576
593
)
577
594
}
578
595
596
+ performanceManager?.notifyAnalysisFinished()
579
597
if (analyzedOutput.reportCompilationErrors(moduleStructure, diagnosticsReporter, messageCollector)) {
580
598
throw CompilationErrorException ()
581
599
}
0 commit comments