[Wasm] Add an option to dump declaration IR sizes to file

This commit is contained in:
Zalim Bashorov
2023-04-21 18:07:49 +02:00
parent 3c343e3074
commit bd852e87ab
5 changed files with 93 additions and 4 deletions
@@ -308,6 +308,20 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
field = value
}
@Argument(
value = "-Xir-dump-declaration-ir-sizes-to-file",
valueDescription = "<path>",
description = "Dump the IR size of each declaration to a file. " +
"The format will be chosen automatically depending on the file extension. " +
"Supported output formats include JSON for .json, JS const initialized with a plain object containing information for .js, " +
"and plain text for all other file types."
)
var irDceDumpDeclarationIrSizesToFile: String? = null
set(value) {
checkFrozen()
field = value
}
@Argument(value = "-Xir-property-lazy-initialization", description = "Perform lazy initialization for properties")
var irPropertyLazyInitialization = true
set(value) {
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.incremental.js.IncrementalNextRoundChecker
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
import org.jetbrains.kotlin.ir.backend.js.*
import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationGranularity
import org.jetbrains.kotlin.ir.backend.js.dce.dumpDeclarationIrSizesIfNeed
import org.jetbrains.kotlin.ir.backend.js.ic.*
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.CompilationOutputsBuilt
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
@@ -354,6 +355,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
eliminateDeadDeclarations(allModules, backendContext)
}
dumpDeclarationIrSizesIfNeed(arguments.irDceDumpDeclarationIrSizesToFile, allModules)
val generateSourceMaps = configuration.getBoolean(JSConfigurationKeys.SOURCE_MAP)
val res = compileWasm(