diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index cf17c5f1ff6..68cc10ae84e 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -210,6 +210,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() { ) var irModuleName: String? by NullableStringFreezableVar(null) + // TODO: REMOVE IT @Argument(value = "-Xir-base-class-in-metadata", description = "Write base class into metadata") var irBaseClassInMetadata: Boolean by FreezableVar(false) @@ -235,6 +236,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xir-per-file", description = "Splits generated .js per-file") var irPerFile: Boolean by FreezableVar(false) + // TODO: REMOVE IT @Argument(value = "-Xir-new-ir2js", description = "New fragment-based ir2js") var irNewIr2Js: Boolean by FreezableVar(true) diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index cc4893e137b..d61606e08ef 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -94,14 +94,12 @@ class K2JsIrCompiler : CLICompiler() { arguments.irDceRuntimeDiagnostic, messageCollector ), - baseClassIntoMetadata = arguments.irBaseClassInMetadata, safeExternalBoolean = arguments.irSafeExternalBoolean, safeExternalBooleanDiagnostic = RuntimeDiagnostic.resolve( arguments.irSafeExternalBooleanDiagnostic, messageCollector ), - granularity = arguments.granularity, - icCompatibleIr2Js = true, + granularity = arguments.granularity ) } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt index 10cc0cffb97..2bb3457c77d 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt @@ -53,12 +53,6 @@ import org.jetbrains.kotlin.util.collectionUtils.filterIsInstanceMapNotNull import org.jetbrains.kotlin.utils.addToStdlib.cast import org.jetbrains.kotlin.utils.addToStdlib.safeAs -enum class IcCompatibleIr2Js(val isCompatible: Boolean, val incrementalCacheEnabled: Boolean) { - DISABLED(false, false), - COMPATIBLE(true, false), - IC_MODE(true, true) -} - @OptIn(ObsoleteDescriptorBasedAPI::class) class JsIrBackendContext( val module: ModuleDescriptor, @@ -68,16 +62,16 @@ class JsIrBackendContext( val additionalExportedDeclarationNames: Set, keep: Set, override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context - override val scriptMode: Boolean = false, override val es6mode: Boolean = false, val dceRuntimeDiagnostic: RuntimeDiagnostic? = null, - val baseClassIntoMetadata: Boolean = false, val safeExternalBoolean: Boolean = false, val safeExternalBooleanDiagnostic: RuntimeDiagnostic? = null, override val mapping: JsMapping = JsMapping(), val granularity: JsGenerationGranularity = JsGenerationGranularity.WHOLE_PROGRAM, - val icCompatibleIr2Js: IcCompatibleIr2Js = IcCompatibleIr2Js.DISABLED, + val incrementalCacheEnabled: Boolean = false ) : JsCommonBackendContext { + override val scriptMode: Boolean get() = false + val polyfills = JsPolyfills() val fieldToInitializer: MutableMap = mutableMapOf() diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt index 223287f5df3..695cb340d9f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt @@ -54,12 +54,10 @@ fun compile( dceRuntimeDiagnostic: RuntimeDiagnostic? = null, es6mode: Boolean = false, verifySignatures: Boolean = true, - baseClassIntoMetadata: Boolean = false, safeExternalBoolean: Boolean = false, safeExternalBooleanDiagnostic: RuntimeDiagnostic? = null, filesToLower: Set? = null, granularity: JsGenerationGranularity = JsGenerationGranularity.WHOLE_PROGRAM, - icCompatibleIr2Js: Boolean = false, ): LoweredIr { val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer, moduleToName) = @@ -79,11 +77,9 @@ fun compile( keep, dceRuntimeDiagnostic, es6mode, - baseClassIntoMetadata, safeExternalBoolean, safeExternalBooleanDiagnostic, granularity, - icCompatibleIr2Js, ) } @@ -101,11 +97,9 @@ fun compileIr( keep: Set, dceRuntimeDiagnostic: RuntimeDiagnostic?, es6mode: Boolean, - baseClassIntoMetadata: Boolean, safeExternalBoolean: Boolean, safeExternalBooleanDiagnostic: RuntimeDiagnostic?, granularity: JsGenerationGranularity, - icCompatibleIr2Js: Boolean, ): LoweredIr { val moduleDescriptor = moduleFragment.descriptor val irFactory = symbolTable.irFactory @@ -126,11 +120,10 @@ fun compileIr( configuration, es6mode = es6mode, dceRuntimeDiagnostic = dceRuntimeDiagnostic, - baseClassIntoMetadata = baseClassIntoMetadata, safeExternalBoolean = safeExternalBoolean, safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic, granularity = granularity, - icCompatibleIr2Js = if (icCompatibleIr2Js) IcCompatibleIr2Js.COMPATIBLE else IcCompatibleIr2Js.DISABLED, + incrementalCacheEnabled = false ) // Load declarations referenced during `context` initialization diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compilerWithIC.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compilerWithIC.kt index 859a74f9b5a..359259cf249 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compilerWithIC.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compilerWithIC.kt @@ -45,7 +45,7 @@ class JsIrCompilerWithIC( configuration = configuration, es6mode = es6mode, granularity = granularity, - icCompatibleIr2Js = IcCompatibleIr2Js.IC_MODE, + incrementalCacheEnabled = true ) } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt index b229bfb22ea..0aaedb2184f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt @@ -21,7 +21,7 @@ class JsPropertyAccessorInlineLowering( return false // Member properties could be safely inlined, because initialization processed via parent declaration - if (!isTopLevel && !context.icCompatibleIr2Js.incrementalCacheEnabled) + if (!isTopLevel && !context.incrementalCacheEnabled) return true // Just undefined value @@ -30,29 +30,9 @@ class JsPropertyAccessorInlineLowering( } // TODO: teach the deserializer to load constant property initializers - if (context.icCompatibleIr2Js.isCompatible) { - val accessFile = accessContainer.fileOrNull ?: return false - val file = fileOrNull ?: return false + val accessFile = accessContainer.fileOrNull ?: return false + val file = fileOrNull ?: return false - 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 - } + return accessFile == file } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/AbstractJsKLibABITestCase.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/AbstractJsKLibABITestCase.kt index 1cf81effff2..e26169ccb77 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/AbstractJsKLibABITestCase.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/AbstractJsKLibABITestCase.kt @@ -203,8 +203,7 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() { PhaseConfig(jsPhases), IrFactoryImplForJsIC(WholeWorldStageController()), exportedDeclarations = setOf(BOX_FUN_FQN), - granularity = JsGenerationGranularity.PER_MODULE, - icCompatibleIr2Js = true + granularity = JsGenerationGranularity.PER_MODULE ) val transformer = IrModuleToJsTransformerTmp( diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt index 3e8c8930dcc..f043e4b987f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt @@ -143,11 +143,9 @@ class JsIrBackendFacade( keep = keep, dceRuntimeDiagnostic = null, es6mode = false, - baseClassIntoMetadata = false, safeExternalBoolean = JsEnvironmentConfigurationDirectives.SAFE_EXTERNAL_BOOLEAN in module.directives, safeExternalBooleanDiagnostic = module.directives[JsEnvironmentConfigurationDirectives.SAFE_EXTERNAL_BOOLEAN_DIAGNOSTIC].singleOrNull(), granularity = granularity, - icCompatibleIr2Js = true, ) return loweredIr2JsArtifact(module, loweredIr, granularity)