[JS IR] support new Ir2Js in tests and in K2JsTranslator
This commit is contained in:
committed by
TeamCityServer
parent
3c859138d1
commit
d565cc4262
+3
@@ -176,6 +176,9 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-Xir-per-file", description = "Splits generated .js per-file")
|
||||
var irPerFile: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xir-new-ir2js", description = "New fragment-based ir2js")
|
||||
var irNewIr2Js: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xinclude",
|
||||
valueDescription = "<path>",
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.ir.backend.js.ic.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationGranularity
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformerTmp
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
|
||||
import org.jetbrains.kotlin.js.config.*
|
||||
@@ -381,16 +382,29 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
granularity = granularity
|
||||
)
|
||||
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
ir.context,
|
||||
mainCallArguments,
|
||||
fullJs = true,
|
||||
dceJs = arguments.irDce,
|
||||
multiModule = arguments.irPerModule,
|
||||
relativeRequirePath = false,
|
||||
generateGlobalThisPolyfill = configuration.languageVersionSettings.supportsFeature(LanguageFeature.JsAllowInvalidCharsIdentifiersEscaping)
|
||||
)
|
||||
val compiledModule: CompilerResult = transformer.generateModule(ir.allModules)
|
||||
val compiledModule: CompilerResult = if (arguments.irNewIr2Js) {
|
||||
val transformer = IrModuleToJsTransformerTmp(
|
||||
ir.context,
|
||||
mainCallArguments,
|
||||
fullJs = true,
|
||||
dceJs = arguments.irDce,
|
||||
multiModule = arguments.irPerModule,
|
||||
relativeRequirePath = false,
|
||||
)
|
||||
|
||||
transformer.generateModule(ir.allModules)
|
||||
} else {
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
ir.context,
|
||||
mainCallArguments,
|
||||
fullJs = true,
|
||||
dceJs = arguments.irDce,
|
||||
multiModule = arguments.irPerModule,
|
||||
relativeRequirePath = false
|
||||
)
|
||||
|
||||
transformer.generateModule(ir.allModules)
|
||||
}
|
||||
|
||||
messageCollector.report(INFO, "Executable production duration: ${System.currentTimeMillis() - start}ms")
|
||||
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ where advanced options include:
|
||||
-Xir-dce-runtime-diagnostic={log|exception}
|
||||
Enable runtime diagnostics when performing DCE instead of removing declarations
|
||||
-Xir-module-name=<name> Specify a compilation module name for IR backend
|
||||
-Xir-new-ir2js New fragment-based ir2js
|
||||
-Xir-only Disables pre-IR backend
|
||||
-Xir-per-file Splits generated .js per-file
|
||||
-Xir-per-module Splits generated .js per-module
|
||||
|
||||
+5
@@ -234,4 +234,9 @@ object JsEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
|
||||
description = "",
|
||||
applicability = DirectiveApplicability.Global
|
||||
)
|
||||
|
||||
val RUN_NEW_IR_2_JS by directive(
|
||||
description = "",
|
||||
applicability = DirectiveApplicability.Global
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user