JVM collect additional performance metrics in FE1.0 + JVM_IR pipeline

This commit is contained in:
Dmitry Petrov
2022-02-02 11:18:41 +03:00
committed by Space
parent 74cf792b41
commit bbad3e9e94
@@ -87,9 +87,8 @@ object KotlinToJVMBytecodeCompiler {
val projectEnvironment = val projectEnvironment =
PsiBasedProjectEnvironment( PsiBasedProjectEnvironment(
environment.project, environment.project,
VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL), VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
{ environment.createPackagePartProvider(it) } ) { environment.createPackagePartProvider(it) }
)
return FirKotlinToJvmBytecodeCompiler.compileModulesUsingFrontendIR( return FirKotlinToJvmBytecodeCompiler.compileModulesUsingFrontendIR(
projectEnvironment, projectEnvironment,
environment.configuration, environment.configuration,
@@ -160,7 +159,7 @@ object KotlinToJVMBytecodeCompiler {
val file = File(path) val file = File(path)
packagePrefix == null && packagePrefix == null &&
(file.name == PsiJavaModule.MODULE_INFO_FILE || (file.name == PsiJavaModule.MODULE_INFO_FILE ||
(file.isDirectory && file.listFiles().any { it.name == PsiJavaModule.MODULE_INFO_FILE })) (file.isDirectory && file.listFiles()!!.any { it.name == PsiJavaModule.MODULE_INFO_FILE }))
} }
} }
@@ -272,7 +271,12 @@ object KotlinToJVMBytecodeCompiler {
configuration.languageVersionSettings, configuration.languageVersionSettings,
false, false,
) )
val performanceManager = environment.configuration[CLIConfigurationKeys.PERF_MANAGER]
performanceManager?.notifyIRTranslationStarted()
val backendInput = codegenFactory.convertToIr(input) val backendInput = codegenFactory.convertToIr(input)
performanceManager?.notifyIRTranslationFinished()
return Pair(codegenFactory, backendInput) return Pair(codegenFactory, backendInput)
} }
@@ -352,6 +356,8 @@ object KotlinToJVMBytecodeCompiler {
backendInput: CodegenFactory.BackendInput, backendInput: CodegenFactory.BackendInput,
diagnosticsReporter: BaseDiagnosticsCollector, diagnosticsReporter: BaseDiagnosticsCollector,
): CodegenFactory.CodegenInput { ): CodegenFactory.CodegenInput {
val performanceManager = environment.configuration[CLIConfigurationKeys.PERF_MANAGER]
val state = GenerationState.Builder( val state = GenerationState.Builder(
environment.project, environment.project,
ClassBuilderFactories.BINARIES, ClassBuilderFactories.BINARIES,
@@ -368,13 +374,15 @@ object KotlinToJVMBytecodeCompiler {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)?.notifyGenerationStarted() performanceManager?.notifyGenerationStarted()
state.beforeCompile() state.beforeCompile()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
performanceManager?.notifyIRLoweringStarted()
return codegenFactory.invokeLowerings(state, backendInput) return codegenFactory.invokeLowerings(state, backendInput)
.also { performanceManager?.notifyIRLoweringFinished() }
} }
private fun runCodegen( private fun runCodegen(
@@ -385,12 +393,17 @@ object KotlinToJVMBytecodeCompiler {
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
): GenerationState { ): GenerationState {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
val performanceManager = configuration[CLIConfigurationKeys.PERF_MANAGER]
performanceManager?.notifyIRGenerationStarted()
state.codegenFactory.invokeCodegen(codegenInput) state.codegenFactory.invokeCodegen(codegenInput)
CodegenFactory.doCheckCancelled(state) CodegenFactory.doCheckCancelled(state)
state.factory.done() state.factory.done()
performanceManager?.notifyIRGenerationFinished()
configuration.get(CLIConfigurationKeys.PERF_MANAGER)?.notifyGenerationFinished() performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()