@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
29
29
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
30
30
import org.jetbrains.kotlin.cli.common.messages.MessageUtil
31
31
import org.jetbrains.kotlin.cli.js.klib.*
32
- import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.K2JVMCompilerPerformanceManager
33
32
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
34
33
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
35
34
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
@@ -275,15 +274,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
275
274
val outputKlibPath =
276
275
if (arguments.irProduceKlibFile) outputDir.resolve(" $outputName .klib" ).normalize().absolutePath
277
276
else outputDirPath
278
- if (configuration.get(CommonConfigurationKeys .USE_FIR ) == true ) {
279
- sourceModule = processSourceModuleWithK2(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
280
- } else {
281
- sourceModule = processSourceModule(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
282
-
283
- if (! sourceModule.jsFrontEndResult.jsAnalysisResult.shouldGenerateCode)
284
- return OK
285
- }
277
+ sourceModule = produceSourceModule(configuration, environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
286
278
279
+ if (configuration.get(CommonConfigurationKeys .USE_FIR ) != true && ! sourceModule.jsFrontEndResult.jsAnalysisResult.shouldGenerateCode)
280
+ return OK
287
281
}
288
282
289
283
if (! arguments.irProduceJs) return OK
@@ -419,13 +413,34 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
419
413
return OK
420
414
}
421
415
422
- private fun processSourceModule (
416
+ private fun produceSourceModule (
417
+ configuration : CompilerConfiguration ,
418
+ environmentForJS : KotlinCoreEnvironment ,
419
+ libraries : List <String >,
420
+ friendLibraries : List <String >,
421
+ arguments : K2JSCompilerArguments ,
422
+ outputKlibPath : String ,
423
+ ): ModulesStructure {
424
+ val performanceManager = configuration.get(CLIConfigurationKeys .PERF_MANAGER )
425
+ performanceManager?.notifyAnalysisStarted()
426
+
427
+ val sourceModule = if (configuration.get(CommonConfigurationKeys .USE_FIR ) == true ) {
428
+ processSourceModuleWithK2(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
429
+ } else {
430
+ processSourceModuleWithK1(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
431
+ }
432
+
433
+ return sourceModule
434
+ }
435
+
436
+ private fun processSourceModuleWithK1 (
423
437
environmentForJS : KotlinCoreEnvironment ,
424
438
libraries : List <String >,
425
439
friendLibraries : List <String >,
426
440
arguments : K2JSCompilerArguments ,
427
441
outputKlibPath : String
428
442
): ModulesStructure {
443
+ val performanceManager = environmentForJS.configuration.get(CLIConfigurationKeys .PERF_MANAGER )
429
444
lateinit var sourceModule: ModulesStructure
430
445
do {
431
446
val analyzerFacade = when (arguments.wasm) {
@@ -446,6 +461,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
446
461
environmentForJS.addKotlinSourceRoots(result.additionalKotlinRoots)
447
462
}
448
463
} while (result is JsAnalysisResult .RetryWithAdditionalRoots )
464
+ performanceManager?.notifyAnalysisFinished()
449
465
450
466
if (sourceModule.jsFrontEndResult.jsAnalysisResult.shouldGenerateCode && (arguments.irProduceKlibDir || arguments.irProduceKlibFile)) {
451
467
val moduleSourceFiles = (sourceModule.mainModule as MainModule .SourceFiles ).files
@@ -497,6 +513,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
497
513
outputKlibPath : String
498
514
): ModulesStructure {
499
515
val configuration = environmentForJS.configuration
516
+ val performanceManager = configuration.get(CLIConfigurationKeys .PERF_MANAGER )
500
517
val messageCollector = configuration.getNotNull(CLIConfigurationKeys .MESSAGE_COLLECTOR_KEY )
501
518
val diagnosticsReporter = DiagnosticReporterFactory .createPendingReporter()
502
519
@@ -537,6 +554,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
537
554
)
538
555
}
539
556
557
+ performanceManager?.notifyAnalysisFinished()
540
558
if (analyzedOutput.reportCompilationErrors(moduleStructure, diagnosticsReporter, messageCollector)) {
541
559
throw CompilationErrorException ()
542
560
}
0 commit comments