[K/JS] Add useEsClasses to list of compiler arguments that invalidate IC cache ^KT-61795 Fixed

This commit is contained in:
Artem Kobzar
2023-09-13 09:50:24 +00:00
committed by Space Team
parent 274d7ba47d
commit 2578bfefd5
11 changed files with 12 additions and 19 deletions
@@ -116,7 +116,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
messageCollector
),
granularity = arguments.granularity,
es6mode = arguments.useEsClasses
)
}
@@ -171,6 +170,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
configuration.put(JSConfigurationKeys.WASM_USE_TRAPS_INSTEAD_OF_EXCEPTIONS, arguments.wasmUseTrapsInsteadOfExceptions)
configuration.putIfNotNull(JSConfigurationKeys.WASM_TARGET, arguments.wasmTarget?.let(WasmTarget::fromName))
configuration.put(JSConfigurationKeys.USE_ES6_CLASSES, arguments.useEsClasses)
configuration.put(JSConfigurationKeys.OPTIMIZE_GENERATED_JS, arguments.optimizeGeneratedJs)
val commonSourcesArray = arguments.commonSources
@@ -604,7 +604,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
cfg,
arguments.granularity,
PhaseConfig(jsPhases),
es6mode = arguments.useEsClasses
)
}
)
@@ -62,7 +62,6 @@ class JsIrBackendContext(
val additionalExportedDeclarationNames: Set<FqName>,
keep: Set<String>,
override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context
override val es6mode: Boolean = false,
val dceRuntimeDiagnostic: RuntimeDiagnostic? = null,
val safeExternalBoolean: Boolean = false,
val safeExternalBooleanDiagnostic: RuntimeDiagnostic? = null,
@@ -104,6 +103,7 @@ class JsIrBackendContext(
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
val errorPolicy = configuration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT
override val es6mode = configuration[JSConfigurationKeys.USE_ES6_CLASSES] ?: false
val externalPackageFragment = mutableMapOf<IrFileSymbol, IrFile>()
@@ -43,7 +43,6 @@ fun compile(
exportedDeclarations: Set<FqName> = emptySet(),
keep: Set<String> = emptySet(),
dceRuntimeDiagnostic: RuntimeDiagnostic? = null,
es6mode: Boolean = false,
verifySignatures: Boolean = true,
safeExternalBoolean: Boolean = false,
safeExternalBooleanDiagnostic: RuntimeDiagnostic? = null,
@@ -67,7 +66,6 @@ fun compile(
exportedDeclarations,
keep,
dceRuntimeDiagnostic,
es6mode,
safeExternalBoolean,
safeExternalBooleanDiagnostic,
granularity,
@@ -87,7 +85,6 @@ fun compileIr(
exportedDeclarations: Set<FqName>,
keep: Set<String>,
dceRuntimeDiagnostic: RuntimeDiagnostic?,
es6mode: Boolean,
safeExternalBoolean: Boolean,
safeExternalBooleanDiagnostic: RuntimeDiagnostic?,
granularity: JsGenerationGranularity,
@@ -108,7 +105,6 @@ fun compileIr(
exportedDeclarations,
keep,
configuration,
es6mode = es6mode,
dceRuntimeDiagnostic = dceRuntimeDiagnostic,
safeExternalBoolean = safeExternalBoolean,
safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic,
@@ -27,7 +27,6 @@ class JsIrCompilerWithIC(
granularity: JsGenerationGranularity,
private val phaseConfig: PhaseConfig,
exportedDeclarations: Set<FqName> = emptySet(),
es6mode: Boolean = false
) : JsIrCompilerICInterface {
private val context: JsIrBackendContext
@@ -42,7 +41,6 @@ class JsIrCompilerWithIC(
exportedDeclarations,
keep = emptySet(),
configuration = configuration,
es6mode = es6mode,
granularity = granularity,
incrementalCacheEnabled = true
)
@@ -782,7 +782,6 @@ fun rebuildCacheForDirtyFiles(
irFactory: IrFactory,
exportedDeclarations: Set<FqName>,
mainArguments: List<String>?,
es6mode: Boolean
): Pair<IrModuleFragment, List<Pair<IrFile, List<JsIrProgramFragment>>>> {
val internationService = IrInterningService()
val emptyMetadata = object : KotlinSourceFileExports() {
@@ -809,7 +808,6 @@ fun rebuildCacheForDirtyFiles(
JsGenerationGranularity.PER_MODULE,
PhaseConfig(jsPhases),
exportedDeclarations,
es6mode
)
// Load declarations referenced during `context` initialization
@@ -152,6 +152,7 @@ internal class ICHasher {
JSConfigurationKeys.SOURCE_MAP,
JSConfigurationKeys.META_INFO,
JSConfigurationKeys.DEVELOPER_MODE,
JSConfigurationKeys.USE_ES6_CLASSES,
JSConfigurationKeys.GENERATE_POLYFILLS,
JSConfigurationKeys.GENERATE_DTS,
JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION,
@@ -137,6 +137,10 @@ fun createCompilerConfiguration(module: TestModule, configurators: List<Abstract
configuration.put(JSConfigurationKeys.GENERATE_DTS, true)
}
if (JsEnvironmentConfigurationDirectives.ES6_MODE in module.directives) {
configuration.put(JSConfigurationKeys.USE_ES6_CLASSES, true)
}
if (module.frontendKind == FrontendKinds.FIR) {
configuration[CommonConfigurationKeys.USE_FIR] = true
}
@@ -132,4 +132,7 @@ public class JSConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> OPTIMIZE_GENERATED_JS =
CompilerConfigurationKey.create("perform additional optimizations on the generated JS code");
public static final CompilerConfigurationKey<Boolean> USE_ES6_CLASSES =
CompilerConfigurationKey.create("perform ES6 class usage");
}
@@ -132,6 +132,7 @@ abstract class AbstractInvalidationTest(
copy.put(JSConfigurationKeys.MODULE_KIND, moduleKind)
copy.put(JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION, true)
copy.put(JSConfigurationKeys.SOURCE_MAP, true)
copy.put(JSConfigurationKeys.USE_ES6_CLASSES, targetBackend == TargetBackend.JS_IR_ES6)
copy.languageVersionSettings = with(LanguageVersionSettingsBuilder()) {
language.forEach {
@@ -370,7 +371,6 @@ abstract class AbstractInvalidationTest(
granularity,
getPhaseConfig(projStep.id),
setOf(FqName(BOX_FUNCTION_NAME)),
targetBackend == TargetBackend.JS_IR_ES6
)
}
)
@@ -86,7 +86,6 @@ class JsIrBackendFacade(
val splitPerFile = JsEnvironmentConfigurationDirectives.SPLIT_PER_FILE in module.directives
val perModule = JsEnvironmentConfigurationDirectives.PER_MODULE in module.directives
val keep = module.directives[JsEnvironmentConfigurationDirectives.KEEP].toSet()
val es6Mode = JsEnvironmentConfigurationDirectives.ES6_MODE in module.directives
val granularity = when {
!firstTimeCompilation -> JsGenerationGranularity.WHOLE_PROGRAM
@@ -153,7 +152,6 @@ class JsIrBackendFacade(
exportedDeclarations = setOf(FqName.fromSegments(listOfNotNull(testPackage, TEST_FUNCTION))),
keep = keep,
dceRuntimeDiagnostic = null,
es6mode = es6Mode,
safeExternalBoolean = JsEnvironmentConfigurationDirectives.SAFE_EXTERNAL_BOOLEAN in module.directives,
safeExternalBooleanDiagnostic = module.directives[JsEnvironmentConfigurationDirectives.SAFE_EXTERNAL_BOOLEAN_DIAGNOSTIC].singleOrNull(),
granularity = granularity,
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.konan.properties.propertyList
import org.jetbrains.kotlin.library.KLIB_PROPERTY_DEPENDS
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.*
@@ -87,7 +86,7 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test
.run { if (shouldBeGenerated()) arguments() else null }
runtimeKlibPath.forEach {
recordIncrementalData(it, null, libs, configuration, mainArguments, module.targetBackend)
recordIncrementalData(it, null, libs, configuration, mainArguments)
}
}
@@ -109,7 +108,6 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test
allDependencies + library,
configuration,
mainArguments,
module.targetBackend
)
}
@@ -119,7 +117,6 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test
allDependencies: List<KotlinLibrary>,
configuration: CompilerConfiguration,
mainArguments: List<String>?,
targetBackend: TargetBackend?
) {
val canonicalPath = File(path).canonicalPath
val predefinedModuleCache = predefinedKlibHasIcCache[canonicalPath]
@@ -150,7 +147,6 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test
IrFactoryImplForJsIC(WholeWorldStageController()),
setOf(FqName.fromSegments(listOfNotNull(testPackage, JsBoxRunner.TEST_FUNCTION))),
mainArguments,
targetBackend == TargetBackend.JS_IR_ES6
)
val moduleCache = icCache[canonicalPath] ?: TestArtifactCache(mainModuleIr.name.asString())