[JS IR] make old Ir2Js pass all tests
This commit is contained in:
committed by
TeamCityServer
parent
d565cc4262
commit
1ae042edc3
@@ -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
|
||||
|
||||
+22
-20
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ class JsIrBackendFacade(
|
||||
val splitPerModule = JsEnvironmentConfigurationDirectives.SPLIT_PER_MODULE in module.directives
|
||||
val splitPerFile = JsEnvironmentConfigurationDirectives.SPLIT_PER_FILE in module.directives
|
||||
val perModule = JsEnvironmentConfigurationDirectives.PER_MODULE in module.directives
|
||||
val runNewIr2Js = JsEnvironmentConfigurationDirectives.RUN_NEW_IR_2_JS in module.directives
|
||||
|
||||
val granularity = when {
|
||||
!firstTimeCompilation -> JsGenerationGranularity.WHOLE_PROGRAM
|
||||
@@ -117,7 +118,8 @@ class JsIrBackendFacade(
|
||||
lowerPerModule = lowerPerModule,
|
||||
safeExternalBoolean = JsEnvironmentConfigurationDirectives.SAFE_EXTERNAL_BOOLEAN in module.directives,
|
||||
safeExternalBooleanDiagnostic = module.directives[JsEnvironmentConfigurationDirectives.SAFE_EXTERNAL_BOOLEAN_DIAGNOSTIC].singleOrNull(),
|
||||
granularity = granularity
|
||||
granularity = granularity,
|
||||
icCompatibleIr2Js = runNewIr2Js,
|
||||
)
|
||||
|
||||
return loweredIr2JsArtifact(module, loweredIr, granularity)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1285
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
package foo
|
||||
|
||||
|
||||
+4
-4
@@ -6,6 +6,10 @@ declare namespace JS_TESTS {
|
||||
interface ExportedInternalInterface {
|
||||
}
|
||||
}
|
||||
namespace foo {
|
||||
interface FileLevelExportedExternalInterface {
|
||||
}
|
||||
}
|
||||
namespace foo {
|
||||
const exportedVal: number;
|
||||
function exportedFun(): number;
|
||||
@@ -14,10 +18,6 @@ declare namespace JS_TESTS {
|
||||
readonly value: number;
|
||||
}
|
||||
}
|
||||
namespace foo {
|
||||
interface FileLevelExportedExternalInterface {
|
||||
}
|
||||
}
|
||||
namespace foo {
|
||||
const fileLevelExportedVal: number;
|
||||
function fileLevelExportedFun(): number;
|
||||
|
||||
Reference in New Issue
Block a user