[JPS] Improve JPS dumb mode
For the correct work of the compiler, some maps should be fulfilled by the build system. In the first implementation of dumb mode for JPS all maps were disabled. Now flag was introduced to determine IC behavior: to collect data needed for the compiler's code generation and disable maps and IC analysis ^KT-65043 Fixed
This commit is contained in:
committed by
Space Team
parent
32bc2b55ed
commit
1e7e42baf2
@@ -49,7 +49,7 @@ interface IncrementalCacheCommon {
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractIncrementalCache<ClassName>(
|
abstract class AbstractIncrementalCache<ClassName>(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
icContext: IncrementalCompilationContext,
|
val icContext: IncrementalCompilationContext,
|
||||||
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
||||||
companion object {
|
companion object {
|
||||||
private const val CLASS_ATTRIBUTES = "class-attributes"
|
private const val CLASS_ATTRIBUTES = "class-attributes"
|
||||||
@@ -229,6 +229,8 @@ abstract class AbstractIncrementalCache<ClassName>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateComplementaryFiles(dirtyFiles: Collection<File>, expectActualTracker: ExpectActualTrackerImpl) {
|
override fun updateComplementaryFiles(dirtyFiles: Collection<File>, expectActualTracker: ExpectActualTrackerImpl) {
|
||||||
|
if (icContext.useCompilerMapsOnly && this is IncrementalJvmCache) return
|
||||||
|
|
||||||
dirtyFiles.forEach {
|
dirtyFiles.forEach {
|
||||||
complementaryFilesMap.remove(it)
|
complementaryFilesMap.remove(it)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class IncrementalCompilationContext(
|
|||||||
val trackChangesInLookupCache: Boolean = false,
|
val trackChangesInLookupCache: Boolean = false,
|
||||||
val icFeatures: IncrementalCompilationFeatures = IncrementalCompilationFeatures.DEFAULT_CONFIGURATION,
|
val icFeatures: IncrementalCompilationFeatures = IncrementalCompilationFeatures.DEFAULT_CONFIGURATION,
|
||||||
val fragmentContext: FragmentContext? = null,
|
val fragmentContext: FragmentContext? = null,
|
||||||
|
val useCompilerMapsOnly: Boolean = false
|
||||||
) {
|
) {
|
||||||
@Deprecated("This constructor is scheduled to be removed. KSP is using it")
|
@Deprecated("This constructor is scheduled to be removed. KSP is using it")
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import java.io.File
|
|||||||
|
|
||||||
open class IncrementalJsCache(
|
open class IncrementalJsCache(
|
||||||
cachesDir: File,
|
cachesDir: File,
|
||||||
private val icContext: IncrementalCompilationContext,
|
icContext: IncrementalCompilationContext,
|
||||||
serializerProtocol: SerializerExtensionProtocol,
|
serializerProtocol: SerializerExtensionProtocol,
|
||||||
) : AbstractIncrementalCache<FqName>(cachesDir, icContext) {
|
) : AbstractIncrementalCache<FqName>(cachesDir, icContext) {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ open class IncrementalJvmCache(
|
|||||||
sourceFiles.forEach {
|
sourceFiles.forEach {
|
||||||
sourceToClassesMap.append(it, className)
|
sourceToClassesMap.append(it, className)
|
||||||
}
|
}
|
||||||
internalNameToSource[className.internalName] = sourceFiles
|
if (!icContext.useCompilerMapsOnly) internalNameToSource[className.internalName] = sourceFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kotlinClassInfo.classId.isLocal) return
|
if (kotlinClassInfo.classId.isLocal) return
|
||||||
@@ -142,9 +142,11 @@ open class IncrementalJvmCache(
|
|||||||
packagePartMap.addPackagePart(className)
|
packagePartMap.addPackagePart(className)
|
||||||
|
|
||||||
protoMap.process(kotlinClassInfo, changesCollector)
|
protoMap.process(kotlinClassInfo, changesCollector)
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
constantsMap.process(kotlinClassInfo, changesCollector)
|
constantsMap.process(kotlinClassInfo, changesCollector)
|
||||||
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
KotlinClassHeader.Kind.MULTIFILE_CLASS -> {
|
KotlinClassHeader.Kind.MULTIFILE_CLASS -> {
|
||||||
val partNames = kotlinClassInfo.classHeaderData.toList()
|
val partNames = kotlinClassInfo.classHeaderData.toList()
|
||||||
check(partNames.isNotEmpty()) { "Multifile class has no parts: $className" }
|
check(partNames.isNotEmpty()) { "Multifile class has no parts: $className" }
|
||||||
@@ -158,6 +160,8 @@ open class IncrementalJvmCache(
|
|||||||
}
|
}
|
||||||
protoMap.remove(className, changesCollector)
|
protoMap.remove(className, changesCollector)
|
||||||
classFqNameToSourceMap.remove(className.fqNameForClassNameWithoutDollars)
|
classFqNameToSourceMap.remove(className.fqNameForClassNameWithoutDollars)
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
|
|
||||||
classAttributesMap.remove(className.fqNameForClassNameWithoutDollars)
|
classAttributesMap.remove(className.fqNameForClassNameWithoutDollars)
|
||||||
internalNameToSource.remove(className.internalName)
|
internalNameToSource.remove(className.internalName)
|
||||||
|
|
||||||
@@ -165,24 +169,31 @@ open class IncrementalJvmCache(
|
|||||||
constantsMap.process(kotlinClassInfo, changesCollector)
|
constantsMap.process(kotlinClassInfo, changesCollector)
|
||||||
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> {
|
KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> {
|
||||||
if (sourceFiles != null) {
|
if (sourceFiles != null) {
|
||||||
assert(sourceFiles.size == 1) { "Multifile class part from several source files: $sourceFiles" }
|
assert(sourceFiles.size == 1) { "Multifile class part from several source files: $sourceFiles" }
|
||||||
}
|
}
|
||||||
packagePartMap.addPackagePart(className)
|
packagePartMap.addPackagePart(className)
|
||||||
partToMultifileFacade[className] = kotlinClassInfo.multifileClassName!!
|
partToMultifileFacade[className] = kotlinClassInfo.multifileClassName!!
|
||||||
|
|
||||||
protoMap.process(kotlinClassInfo, changesCollector)
|
protoMap.process(kotlinClassInfo, changesCollector)
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
constantsMap.process(kotlinClassInfo, changesCollector)
|
constantsMap.process(kotlinClassInfo, changesCollector)
|
||||||
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
KotlinClassHeader.Kind.CLASS -> {
|
KotlinClassHeader.Kind.CLASS -> {
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
addToClassStorage(kotlinClassInfo.protoData as ClassProtoData, sourceFiles?.let { sourceFiles.single() })
|
addToClassStorage(kotlinClassInfo.protoData as ClassProtoData, sourceFiles?.let { sourceFiles.single() })
|
||||||
|
}
|
||||||
|
|
||||||
protoMap.process(kotlinClassInfo, changesCollector)
|
protoMap.process(kotlinClassInfo, changesCollector)
|
||||||
|
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
constantsMap.process(kotlinClassInfo, changesCollector)
|
constantsMap.process(kotlinClassInfo, changesCollector)
|
||||||
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
inlineFunctionsMap.process(kotlinClassInfo, changesCollector)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
KotlinClassHeader.Kind.UNKNOWN, KotlinClassHeader.Kind.SYNTHETIC_CLASS -> {
|
KotlinClassHeader.Kind.UNKNOWN, KotlinClassHeader.Kind.SYNTHETIC_CLASS -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,10 +239,15 @@ open class IncrementalJvmCache(
|
|||||||
|
|
||||||
fun saveJavaClassProto(source: File?, serializedJavaClass: SerializedJavaClass, collector: ChangesCollector) {
|
fun saveJavaClassProto(source: File?, serializedJavaClass: SerializedJavaClass, collector: ChangesCollector) {
|
||||||
val jvmClassName = JvmClassName.byClassId(serializedJavaClass.classId)
|
val jvmClassName = JvmClassName.byClassId(serializedJavaClass.classId)
|
||||||
|
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
javaSourcesProtoMap.process(jvmClassName, serializedJavaClass, collector)
|
javaSourcesProtoMap.process(jvmClassName, serializedJavaClass, collector)
|
||||||
|
}
|
||||||
source?.let { sourceToClassesMap.append(source, jvmClassName) }
|
source?.let { sourceToClassesMap.append(source, jvmClassName) }
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
addToClassStorage(serializedJavaClass.toProtoData(), source)
|
addToClassStorage(serializedJavaClass.toProtoData(), source)
|
||||||
// collector.addJavaProto(ClassProtoData(proto, nameResolver))
|
// collector.addJavaProto(ClassProtoData(proto, nameResolver))
|
||||||
|
}
|
||||||
dirtyOutputClassesMap.notDirty(jvmClassName)
|
dirtyOutputClassesMap.notDirty(jvmClassName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,13 +296,17 @@ open class IncrementalJvmCache(
|
|||||||
packagePartMap.remove(it)
|
packagePartMap.remove(it)
|
||||||
multifileFacadeToParts.remove(it)
|
multifileFacadeToParts.remove(it)
|
||||||
partToMultifileFacade.remove(it)
|
partToMultifileFacade.remove(it)
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
constantsMap.remove(it)
|
constantsMap.remove(it)
|
||||||
inlineFunctionsMap.remove(it)
|
inlineFunctionsMap.remove(it)
|
||||||
internalNameToSource.remove(it.internalName)
|
internalNameToSource.remove(it.internalName)
|
||||||
javaSourcesProtoMap.remove(it, changesCollector)
|
javaSourcesProtoMap.remove(it, changesCollector)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!icContext.useCompilerMapsOnly) {
|
||||||
removeAllFromClassStorage(dirtyClasses.map { it.fqNameForClassNameWithoutDollars }, changesCollector)
|
removeAllFromClassStorage(dirtyClasses.map { it.fqNameForClassNameWithoutDollars }, changesCollector)
|
||||||
|
}
|
||||||
dirtyOutputClassesMap.clear()
|
dirtyOutputClassesMap.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
val generatedFiles = getGeneratedFiles(context, chunk, environment.outputItemsCollector)
|
val generatedFiles = getGeneratedFiles(context, chunk, environment.outputItemsCollector)
|
||||||
|
|
||||||
markDirtyComplementaryMultifileClasses(generatedFiles, kotlinContext, incrementalCaches, fsOperations)
|
if (!isKotlinBuilderInDumbMode) markDirtyComplementaryMultifileClasses(generatedFiles, kotlinContext, incrementalCaches, fsOperations)
|
||||||
|
|
||||||
val kotlinTargets = kotlinContext.targetsBinding
|
val kotlinTargets = kotlinContext.targetsBinding
|
||||||
for ((target, outputItems) in generatedFiles) {
|
for ((target, outputItems) in generatedFiles) {
|
||||||
@@ -530,7 +530,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
environment
|
environment
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isKotlinBuilderInDumbMode || !representativeTarget.isIncrementalCompilationEnabled) {
|
if (!representativeTarget.isIncrementalCompilationEnabled) {
|
||||||
return OK
|
return OK
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +552,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isKotlinBuilderInDumbMode) {
|
||||||
updateLookupStorage(lookupTracker, kotlinContext.lookupStorageManager, kotlinDirtyFilesHolder)
|
updateLookupStorage(lookupTracker, kotlinContext.lookupStorageManager, kotlinDirtyFilesHolder)
|
||||||
|
|
||||||
if (!isChunkRebuilding) {
|
if (!isChunkRebuilding) {
|
||||||
@@ -563,6 +564,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return OK
|
return OK
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ class KotlinCompileContext(val jpsContext: CompileContext) {
|
|||||||
|
|
||||||
val icContext = IncrementalCompilationContext(
|
val icContext = IncrementalCompilationContext(
|
||||||
pathConverterForSourceFiles = fileToPathConverter,
|
pathConverterForSourceFiles = fileToPathConverter,
|
||||||
pathConverterForOutputFiles = fileToPathConverter
|
pathConverterForOutputFiles = fileToPathConverter,
|
||||||
|
useCompilerMapsOnly = KotlinBuilder.isKotlinBuilderInDumbMode
|
||||||
)
|
)
|
||||||
|
|
||||||
val lookupStorageManager = JpsLookupStorageManager(dataManager, icContext)
|
val lookupStorageManager = JpsLookupStorageManager(dataManager, icContext)
|
||||||
|
|||||||
Reference in New Issue
Block a user