[JS IR] Replace IrModuleToJsTransformer with IrModuleToJsTransformerTmp

This commit is contained in:
Alexander Korepanov
2022-10-19 13:48:25 +02:00
committed by Space Team
parent 2ec07b861b
commit d17794481d
6 changed files with 25 additions and 89 deletions
@@ -82,15 +82,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
val mainCallArguments: List<String>?
) {
private fun lowerIr(): LoweredIr {
val irFactory = when {
arguments.irNewIr2Js -> IrFactoryImplForJsIC(WholeWorldStageController())
else -> IrFactoryImpl
}
return compile(
module,
phaseConfig,
irFactory,
IrFactoryImplForJsIC(WholeWorldStageController()),
keep = arguments.irKeep?.split(",")
?.filterNot { it.isEmpty() }
?.toSet()
@@ -106,7 +101,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
messageCollector
),
granularity = arguments.granularity,
icCompatibleIr2Js = arguments.irNewIr2Js,
icCompatibleIr2Js = true,
)
}
@@ -123,22 +118,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
val out = generator.generateJsCode(relativeRequirePath = true, outJsProgram = false)
return TransformResult(out, dts)
}
fun compileAndTransformIrOld(): TransformResult {
val ir = lowerIr()
val transformer = IrModuleToJsTransformer(
ir.context,
mainCallArguments,
fullJs = !arguments.irDce,
dceJs = arguments.irDce,
multiModule = arguments.irPerModule,
relativeRequirePath = true,
moduleToName = ir.moduleFragmentToUniqueName
)
val result = transformer.generateModule(ir.allModules)
return TransformResult(result.outputs.values.single(), result.tsDefinitions ?: error("No ts definitions"))
}
}
@@ -427,12 +406,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
val start = System.currentTimeMillis()
try {
val (outputs, tsDefinitions) = if (arguments.irNewIr2Js) {
Ir2JsTransformer(arguments, module, phaseConfig, messageCollector, mainCallArguments).compileAndTransformIrNew()
} else {
Ir2JsTransformer(arguments, module, phaseConfig, messageCollector, mainCallArguments).compileAndTransformIrOld()
}
val ir2JsTransformer = Ir2JsTransformer(arguments, module, phaseConfig, messageCollector, mainCallArguments)
val (outputs, tsDefinitions) = ir2JsTransformer.compileAndTransformIrNew()
messageCollector.report(INFO, "Executable production duration: ${System.currentTimeMillis() - start}ms")