Skip to content

Commit c3a1c4e

Browse files
ivandev0Space Team
authored and
Space Team
committed
[CLI] Notify WASM perf manager when generation is started and finished
#KT-67473 (cherry picked from commit 0867bf1)
1 parent 4bbc4cf commit c3a1c4e

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
352352
exportedDeclarations = setOf(FqName("main")),
353353
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
354354
)
355+
356+
performanceManager?.notifyIRGenerationStarted()
355357
val dceDumpNameCache = DceDumpNameCache()
356358
if (arguments.irDce) {
357359
eliminateDeadDeclarations(allModules, backendContext, dceDumpNameCache)
@@ -370,6 +372,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
370372
generateWat = configuration.get(JSConfigurationKeys.WASM_GENERATE_WAT, false),
371373
generateSourceMaps = generateSourceMaps
372374
)
375+
performanceManager?.notifyIRGenerationFinished()
376+
performanceManager?.notifyGenerationFinished()
373377

374378
writeCompilationResult(
375379
result = res,

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

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
}
55

66
dependencies {
7+
implementation(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

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.backend.wasm.ir2wasm.WasmModuleFragmentGenerator
1414
import org.jetbrains.kotlin.backend.wasm.ir2wasm.toJsStringLiteral
1515
import org.jetbrains.kotlin.backend.wasm.lower.markExportedDeclarations
1616
import org.jetbrains.kotlin.config.CompilerConfiguration
17+
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
1718
import org.jetbrains.kotlin.ir.backend.js.MainModule
1819
import org.jetbrains.kotlin.ir.backend.js.ModulesStructure
1920
import org.jetbrains.kotlin.ir.backend.js.SourceMapsInfo
@@ -51,6 +52,9 @@ fun compileToLoweredIr(
5152
): Pair<List<IrModuleFragment>, WasmBackendContext> {
5253
val mainModule = depsDescriptors.mainModule
5354
val configuration = depsDescriptors.compilerConfiguration
55+
val performanceManager = depsDescriptors.compilerConfiguration[CLIConfigurationKeys.PERF_MANAGER]
56+
performanceManager?.notifyIRTranslationStarted()
57+
5458
val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, irLinker) = loadIr(
5559
depsDescriptors,
5660
irFactory,
@@ -83,7 +87,11 @@ fun compileToLoweredIr(
8387
for (file in module.files)
8488
markExportedDeclarations(context, file, exportedDeclarations)
8589

90+
performanceManager?.notifyIRTranslationFinished()
91+
performanceManager?.notifyGenerationStarted()
92+
performanceManager?.notifyIRLoweringStarted()
8693
wasmPhases.invokeToplevel(phaseConfig, context, allModules)
94+
performanceManager?.notifyIRLoweringFinished()
8795

8896
return Pair(allModules, context)
8997
}
@@ -179,7 +187,7 @@ private fun generateSourceMap(
179187
prev = location
180188

181189
location.apply {
182-
// TODO resulting path goes too deep since temporary directory we compiled first is deeper than final destination.
190+
// TODO resulting path goes too deep since temporary directory we compiled first is deeper than final destination.
183191
val relativePath = pathResolver.getPathRelativeToSourceRoots(File(file)).substring(3)
184192
sourceMapBuilder.addMapping(relativePath, null, { null }, line, column, null, mapping.offset)
185193
}

0 commit comments

Comments
 (0)