[JS IR] make old Ir2Js pass all tests

This commit is contained in:
Anton Bannykh
2021-10-29 12:31:53 +03:00
committed by TeamCityServer
parent d565cc4262
commit 1ae042edc3
8 changed files with 41 additions and 29 deletions
@@ -379,7 +379,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
messageCollector
),
lowerPerModule = icCaches.isNotEmpty(),
granularity = granularity
granularity = granularity,
icCompatibleIr2Js = arguments.irNewIr2Js,
)
val compiledModule: CompilerResult = if (arguments.irNewIr2Js) {
@@ -60,6 +60,7 @@ class JsIrBackendContext(
val safeExternalBooleanDiagnostic: RuntimeDiagnostic? = null,
override val mapping: JsMapping = JsMapping(symbolTable.irFactory),
val granularity: JsGenerationGranularity = JsGenerationGranularity.WHOLE_PROGRAM,
val icCompatibleIr2Js: Boolean = false,
) : JsCommonBackendContext {
val fileToInitializationFuns: MutableMap<IrFile, IrSimpleFunction?> = mutableMapOf()
val fileToInitializerPureness: MutableMap<IrFile, Boolean> = mutableMapOf()
@@ -63,6 +63,7 @@ fun compile(
safeExternalBooleanDiagnostic: RuntimeDiagnostic? = null,
filesToLower: Set<String>? = null,
granularity: JsGenerationGranularity = JsGenerationGranularity.WHOLE_PROGRAM,
icCompatibleIr2Js: Boolean = false,
): LoweredIr {
if (lowerPerModule) {
@@ -99,7 +100,8 @@ fun compile(
lowerPerModule,
safeExternalBoolean,
safeExternalBooleanDiagnostic,
granularity
granularity,
icCompatibleIr2Js,
)
}
@@ -122,6 +124,7 @@ fun compileIr(
safeExternalBoolean: Boolean,
safeExternalBooleanDiagnostic: RuntimeDiagnostic?,
granularity: JsGenerationGranularity,
icCompatibleIr2Js: Boolean,
): LoweredIr {
val moduleDescriptor = moduleFragment.descriptor
val irFactory = symbolTable.irFactory
@@ -144,7 +147,8 @@ fun compileIr(
baseClassIntoMetadata = baseClassIntoMetadata,
safeExternalBoolean = safeExternalBoolean,
safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic,
granularity = granularity
granularity = granularity,
icCompatibleIr2Js = icCompatibleIr2Js,
)
// Load declarations referenced during `context` initialization
@@ -70,7 +70,8 @@ fun compileWithIC(
propertyLazyInitialization = propertyLazyInitialization,
baseClassIntoMetadata = baseClassIntoMetadata,
safeExternalBoolean = safeExternalBoolean,
safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic
safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic,
icCompatibleIr2Js = true,
)
// Load declarations referenced during `context` initialization
@@ -20,27 +20,29 @@ class JsPropertyAccessorInlineLowering(
return false
// TODO: teach the deserializer to load constant property initializers
val accessFile = accessContainer.fileOrNull ?: return false
val file = fileOrNull ?: return false
if (context.icCompatibleIr2Js) {
val accessFile = accessContainer.fileOrNull ?: return false
val file = fileOrNull ?: return false
return accessFile == file
return accessFile == file
}
// if (isConst)
// return true
//
// return when (context.granularity) {
// JsGenerationGranularity.WHOLE_PROGRAM ->
// true
// JsGenerationGranularity.PER_MODULE -> {
// val accessModule = accessContainer.fileOrNull?.module ?: return false
// val module = fileOrNull?.module ?: return false
// accessModule == module
// }
// JsGenerationGranularity.PER_FILE ->
// // Not inlining because
// // 1. we need a way to distinguish per-file generation units
// // 2. per-file mode intended for debug builds only at the moment
// false
// }
if (isConst)
return true
return when (context.granularity) {
JsGenerationGranularity.WHOLE_PROGRAM ->
true
JsGenerationGranularity.PER_MODULE -> {
val accessModule = accessContainer.fileOrNull?.module ?: return false
val module = fileOrNull?.module ?: return false
accessModule == module
}
JsGenerationGranularity.PER_FILE ->
// Not inlining because
// 1. we need a way to distinguish per-file generation units
// 2. per-file mode intended for debug builds only at the moment
false
}
}
}