[JS IR] IC: pass through the main args

This commit is contained in:
Anton Bannykh
2021-12-17 15:41:49 +03:00
parent 106d3c4c9c
commit ca60caa7e9
3 changed files with 29 additions and 3 deletions
@@ -223,6 +223,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
libraries, libraries,
icCaches, icCaches,
IrFactoryImplForJsIC(WholeWorldStageController()), IrFactoryImplForJsIC(WholeWorldStageController()),
mainCallArguments,
::buildCacheForModuleFiles ::buildCacheForModuleFiles
) )
@@ -161,6 +161,7 @@ private fun buildCacheForModule(
cacheConsumer: PersistentCacheConsumer, cacheConsumer: PersistentCacheConsumer,
signatureDeserializers: Map<FilePath, Map<IdSignature, Int>>, signatureDeserializers: Map<FilePath, Map<IdSignature, Int>>,
fileFingerPrints: Map<String, Hash>, fileFingerPrints: Map<String, Hash>,
mainArguments: List<String>?,
cacheExecutor: CacheExecutor cacheExecutor: CacheExecutor
) { ) {
val dirtyIrFiles = irModule.files.filter { it.fileEntry.name in dirtyFiles } val dirtyIrFiles = irModule.files.filter { it.fileEntry.name in dirtyFiles }
@@ -202,7 +203,7 @@ private fun buildCacheForModule(
// TODO: actual way of building a cache could change in future // TODO: actual way of building a cache could change in future
cacheExecutor.execute(irModule, dependencies, deserializer, configuration, dirtyFiles, deletedFiles, cacheConsumer, emptySet(), null) // TODO: main arguments? cacheExecutor.execute(irModule, dependencies, deserializer, configuration, dirtyFiles, deletedFiles, cacheConsumer, emptySet(), mainArguments)
cacheConsumer.commitLibraryPath(libraryInfo.libPath.toCanonicalPath(), libraryInfo.flatHash, libraryInfo.transHash) cacheConsumer.commitLibraryPath(libraryInfo.libPath.toCanonicalPath(), libraryInfo.flatHash, libraryInfo.transHash)
} }
@@ -391,6 +392,7 @@ fun actualizeCacheForModule(
dependencies: Collection<ModulePath>, dependencies: Collection<ModulePath>,
icCachePaths: Collection<String>, icCachePaths: Collection<String>,
irFactory: IrFactory, irFactory: IrFactory,
mainArguments: List<String>?,
executor: CacheExecutor executor: CacheExecutor
): CacheUpdateStatus { ): CacheUpdateStatus {
val modulePath = moduleName.toCanonicalPath() val modulePath = moduleName.toCanonicalPath()
@@ -418,7 +420,17 @@ fun actualizeCacheForModule(
val currentModule = libraries[moduleName.toCanonicalPath()] ?: error("No loaded library found for path $moduleName") val currentModule = libraries[moduleName.toCanonicalPath()] ?: error("No loaded library found for path $moduleName")
val persistentCacheConsumer = createCacheConsumer(cachePath) val persistentCacheConsumer = createCacheConsumer(cachePath)
return actualizeCacheForModule(currentModule, cacheInfo, compilerConfiguration, dependencyGraph, persistentCacheProviders, persistentCacheConsumer, irFactory, executor) return actualizeCacheForModule(
currentModule,
cacheInfo,
compilerConfiguration,
dependencyGraph,
persistentCacheProviders,
persistentCacheConsumer,
irFactory,
mainArguments,
executor
)
} }
@@ -430,6 +442,7 @@ private fun actualizeCacheForModule(
persistentCacheProviders: Map<KotlinLibrary, PersistentCacheProvider>, persistentCacheProviders: Map<KotlinLibrary, PersistentCacheProvider>,
persistentCacheConsumer: PersistentCacheConsumer, persistentCacheConsumer: PersistentCacheConsumer,
irFactory: IrFactory, irFactory: IrFactory,
mainArguments: List<String>?,
cacheExecutor: CacheExecutor cacheExecutor: CacheExecutor
): CacheUpdateStatus { ): CacheUpdateStatus {
// 1. Invalidate // 1. Invalidate
@@ -529,6 +542,7 @@ private fun actualizeCacheForModule(
persistentCacheConsumer, persistentCacheConsumer,
deserializers, deserializers,
fileFingerPrints, fileFingerPrints,
mainArguments,
cacheExecutor cacheExecutor
) )
return CacheUpdateStatus.DIRTY // invalidated and re-built return CacheUpdateStatus.DIRTY // invalidated and re-built
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
import org.jetbrains.kotlin.test.util.JUnit4Assertions import org.jetbrains.kotlin.test.util.JUnit4Assertions
import java.io.File import java.io.File
import kotlin.io.path.createTempDirectory import kotlin.io.path.createTempDirectory
@@ -66,7 +67,16 @@ abstract class AbstractInvalidationTest : KotlinTestWithEnvironment() {
val configuration = createConfiguration("stdlib") val configuration = createConfiguration("stdlib")
actualizeCacheForModule(stdlibKlibPath, cacheDir.canonicalPath, configuration, listOf(stdlibKlibPath), emptyList(), IrFactoryImpl, ::emptyChecker) actualizeCacheForModule(
stdlibKlibPath,
cacheDir.canonicalPath,
configuration,
listOf(stdlibKlibPath),
emptyList(),
IrFactoryImpl,
null, // TODO: mainArguments
::emptyChecker
)
stdlibCacheDir = cacheDir stdlibCacheDir = cacheDir
} }
@@ -209,6 +219,7 @@ abstract class AbstractInvalidationTest : KotlinTestWithEnvironment() {
dependenciesPaths, dependenciesPaths,
icCaches.map { it.canonicalPath },// + moduleCacheDir.canonicalPath, icCaches.map { it.canonicalPath },// + moduleCacheDir.canonicalPath,
IrFactoryImpl, IrFactoryImpl,
null, // TODO: mainArguments
::dirtyFilesChecker ::dirtyFilesChecker
) )