Skip to content

Commit 0867bf1

Browse files
ivandev0Space Team
authored andcommitted
[CLI] Notify WASM perf manager when generation is started and finished
#KT-67473
1 parent 5bf27f0 commit 0867bf1

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
395395
generateTypeScriptFragment = generateDts,
396396
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
397397
)
398+
399+
performanceManager?.notifyIRGenerationStarted()
398400
val dceDumpNameCache = DceDumpNameCache()
399401
if (arguments.irDce) {
400402
eliminateDeadDeclarations(allModules, backendContext, dceDumpNameCache)
@@ -412,6 +414,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
412414
generateWat = configuration.get(WasmConfigurationKeys.WASM_GENERATE_WAT, false),
413415
generateSourceMaps = generateSourceMaps,
414416
)
417+
performanceManager?.notifyIRGenerationFinished()
418+
performanceManager?.notifyGenerationFinished()
415419

416420
writeCompilationResult(
417421
result = res,

compiler/ir/backend.wasm/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
}
55

66
dependencies {
7+
api(project(":compiler:cli-base"))
78
api(project(":compiler:util"))
89
api(project(":compiler:frontend"))
910
api(project(":compiler:backend-common"))

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.backend.wasm.ir2wasm.toJsStringLiteral
1616
import org.jetbrains.kotlin.backend.wasm.lower.JsInteropFunctionsLowering
1717
import org.jetbrains.kotlin.backend.wasm.lower.markExportedDeclarations
1818
import org.jetbrains.kotlin.backend.wasm.utils.SourceMapGenerator
19+
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
1920
import org.jetbrains.kotlin.ir.backend.js.MainModule
2021
import org.jetbrains.kotlin.ir.backend.js.ModulesStructure
2122
import org.jetbrains.kotlin.ir.backend.js.export.ExportModelToTsDeclarations
@@ -65,6 +66,9 @@ fun compileToLoweredIr(
6566
): LoweredIrWithExtraArtifacts {
6667
val mainModule = depsDescriptors.mainModule
6768
val configuration = depsDescriptors.compilerConfiguration
69+
val performanceManager = depsDescriptors.compilerConfiguration[CLIConfigurationKeys.PERF_MANAGER]
70+
performanceManager?.notifyIRTranslationStarted()
71+
6872
val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, irLinker) = loadIr(
6973
depsDescriptors,
7074
irFactory,
@@ -103,13 +107,17 @@ fun compileToLoweredIr(
103107
val fragment = exportModelToDtsTranslator.generateTypeScriptFragment(ModuleKind.ES, exportModel.declarations)
104108
TypeScriptFragment(exportModelToDtsTranslator.generateTypeScript("", ModuleKind.ES, listOf(fragment)))
105109
}
110+
performanceManager?.notifyIRTranslationFinished()
106111

112+
performanceManager?.notifyGenerationStarted()
113+
performanceManager?.notifyIRLoweringStarted()
107114
val phaserState = PhaserState<IrModuleFragment>()
108115
loweringList.forEachIndexed { _, lowering ->
109116
allModules.forEach { module ->
110117
lowering.invoke(phaseConfig, phaserState, context, module)
111118
}
112119
}
120+
performanceManager?.notifyIRLoweringFinished()
113121

114122
return LoweredIrWithExtraArtifacts(allModules, context, typeScriptFragment)
115123
}

0 commit comments

Comments
 (0)