Remove old IC: remove unnecessary caches
This commit is contained in:
@@ -106,9 +106,6 @@ open class IncrementalCacheImpl<Target>(
|
||||
result
|
||||
}
|
||||
|
||||
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
||||
}
|
||||
|
||||
protected open fun debugLog(message: String) {}
|
||||
|
||||
fun addDependentCache(cache: IncrementalCacheImpl<Target>) {
|
||||
@@ -747,7 +744,6 @@ open class IncrementalCacheImpl<Target>(
|
||||
emptySequence<ChangeInfo>()
|
||||
}
|
||||
|
||||
processChangedInlineFunctions(className, changed)
|
||||
return CompilationResult(changes = changes)
|
||||
}
|
||||
|
||||
@@ -758,12 +754,6 @@ open class IncrementalCacheImpl<Target>(
|
||||
override fun dumpValue(value: Map<String, Long>): String =
|
||||
value.dumpMap { java.lang.Long.toHexString(it) }
|
||||
}
|
||||
|
||||
protected open fun processChangedInlineFunctions(
|
||||
className: JvmClassName,
|
||||
changedFunctions: Collection<String>
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
private object PathCollectionExternalizer : CollectionExternalizer<String>(PathStringDescriptor, { THashSet(FileUtil.PATH_HASHING_STRATEGY) })
|
||||
|
||||
@@ -107,7 +107,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
isSameModule = sourceCompiler.isCallInsideSameModuleAsDeclared(functionDescriptor)
|
||||
|
||||
if (functionDescriptor !is FictitiousArrayConstructor) {
|
||||
reportIncrementalInfo(functionDescriptor, sourceCompiler.compilationContextFunctionDescriptor.original, jvmSignature, state)
|
||||
val functionOrAccessorName = typeMapper.mapAsmMethod(function).name
|
||||
//track changes for property accessor and @JvmName inline functions/property accessors
|
||||
if (functionOrAccessorName != functionDescriptor.name.asString()) {
|
||||
@@ -561,19 +560,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
fun createNestedSourceMapper(nodeAndSmap: SMAPAndMethodNode, parent: SourceMapper): SourceMapper {
|
||||
return NestedSourceMapper(parent, nodeAndSmap.sortedRanges, nodeAndSmap.classSMAP.sourceInfo)
|
||||
}
|
||||
|
||||
internal fun reportIncrementalInfo(
|
||||
sourceDescriptor: FunctionDescriptor,
|
||||
targetDescriptor: FunctionDescriptor,
|
||||
jvmSignature: JvmMethodSignature,
|
||||
state: GenerationState
|
||||
) {
|
||||
val incrementalCache = state.incrementalCacheForThisTarget ?: return
|
||||
val classFilePath = sourceDescriptor.getClassFilePath(state.typeMapper, incrementalCache)
|
||||
val sourceFilePath = targetDescriptor.sourceFilePath
|
||||
val method = jvmSignature.asmMethod
|
||||
incrementalCache.registerInline(classFilePath, method.name + method.descriptor, sourceFilePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -61,8 +61,6 @@ class InlineCodegenForDefaultBody(
|
||||
sourceCompilerForInline.initializeInlineFunctionContext(functionDescriptor)
|
||||
jvmSignature = state.typeMapper.mapSignatureWithGeneric(functionDescriptor, sourceCompilerForInline.contextKind)
|
||||
|
||||
InlineCodegen.reportIncrementalInfo(functionDescriptor, codegen.context.functionDescriptor.original, jvmSignature, state)
|
||||
|
||||
//InlineCodegenForDefaultBody created just after visitCode call
|
||||
codegen.v.visitLabel(methodStartLabel)
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,8 +56,8 @@ open class CompilerCallbackServicesFacadeServer(
|
||||
|
||||
override fun incrementalCache_getModuleMappingData(target: TargetId): ByteArray? = incrementalCompilationComponents!!.getIncrementalCache(target).getModuleMappingData()
|
||||
|
||||
// todo: remove (the method it called was relevant only for old IC)
|
||||
override fun incrementalCache_registerInline(target: TargetId, fromPath: String, jvmSignature: String, toPath: String) {
|
||||
incrementalCompilationComponents!!.getIncrementalCache(target).registerInline(fromPath, jvmSignature, toPath)
|
||||
}
|
||||
|
||||
override fun incrementalCache_getClassFilePath(target: TargetId, internalClassName: String): String = incrementalCompilationComponents!!.getIncrementalCache(target).getClassFilePath(internalClassName)
|
||||
|
||||
@@ -35,10 +35,6 @@ class RemoteIncrementalCacheClient(val facade: CompilerCallbackServicesFacade, v
|
||||
|
||||
override fun getModuleMappingData(): ByteArray? = profiler.withMeasure(this) { facade.incrementalCache_getModuleMappingData(target) }
|
||||
|
||||
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
||||
profiler.withMeasure(this) { facade.incrementalCache_registerInline(target, fromPath, jvmSignature, toPath) }
|
||||
}
|
||||
|
||||
override fun getClassFilePath(internalClassName: String): String = profiler.withMeasure(this) { facade.incrementalCache_getClassFilePath(target,internalClassName) }
|
||||
|
||||
override fun close(): Unit = profiler.withMeasure(this) { facade.incrementalCache_close(target) }
|
||||
|
||||
-2
@@ -31,8 +31,6 @@ interface IncrementalCache {
|
||||
|
||||
fun getModuleMappingData(): ByteArray?
|
||||
|
||||
fun registerInline(fromPath: String, jvmSignature: String, toPath: String)
|
||||
|
||||
fun getClassFilePath(internalClassName: String): String
|
||||
|
||||
fun close()
|
||||
|
||||
@@ -309,7 +309,6 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
}
|
||||
|
||||
changesInfo.processChangesUsingLookups(filesToCompile.values().toSet(), dataManager, fsOperations, incrementalCaches.values)
|
||||
incrementalCaches.values.forEach { it.cleanDirtyInlineFunctions() }
|
||||
|
||||
return OK
|
||||
}
|
||||
|
||||
@@ -16,110 +16,22 @@
|
||||
|
||||
package org.jetbrains.kotlin.jps.incremental
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import gnu.trove.THashSet
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
||||
import org.jetbrains.jps.builders.storage.StorageProvider
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
||||
import org.jetbrains.jps.incremental.storage.StorageOwner
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.incremental.IncrementalCacheImpl
|
||||
import org.jetbrains.kotlin.incremental.dumpCollection
|
||||
import org.jetbrains.kotlin.incremental.storage.BasicMap
|
||||
import org.jetbrains.kotlin.incremental.storage.BasicStringMap
|
||||
import org.jetbrains.kotlin.incremental.storage.StringCollectionExternalizer
|
||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||
import org.jetbrains.kotlin.jps.incremental.storages.PathCollectionExternalizer
|
||||
import org.jetbrains.kotlin.jps.incremental.storages.PathFunctionPair
|
||||
import org.jetbrains.kotlin.jps.incremental.storages.PathFunctionPairKeyDescriptor
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import java.io.File
|
||||
|
||||
class JpsIncrementalCacheImpl(
|
||||
target: ModuleBuildTarget,
|
||||
paths: BuildDataPaths
|
||||
) : IncrementalCacheImpl<ModuleBuildTarget>(paths.getTargetDataRoot(target), target.outputDir, target), StorageOwner {
|
||||
|
||||
private val dirtyInlineFunctionsMap = registerMap(DirtyInlineFunctionsMap(DIRTY_INLINE_FUNCTIONS.storageFile))
|
||||
private val inlinedTo = registerMap(InlineFunctionsFilesMap(INLINED_TO.storageFile))
|
||||
|
||||
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
||||
if (!IncrementalCompilation.isEnabled()) {
|
||||
inlinedTo.add(fromPath, jvmSignature, toPath)
|
||||
}
|
||||
}
|
||||
|
||||
override fun debugLog(message: String) {
|
||||
KotlinBuilder.LOG.debug(message)
|
||||
}
|
||||
|
||||
fun getFilesToReinline(): Collection<File> {
|
||||
val result = THashSet(FileUtil.PATH_HASHING_STRATEGY)
|
||||
|
||||
for ((className, functions) in dirtyInlineFunctionsMap.getEntries()) {
|
||||
val classFilePath = getClassFilePath(className.internalName)
|
||||
|
||||
for (cache in thisWithDependentCaches) {
|
||||
val targetFiles = functions.flatMap { (cache as JpsIncrementalCacheImpl).inlinedTo[classFilePath, it] }
|
||||
result.addAll(targetFiles)
|
||||
}
|
||||
}
|
||||
|
||||
return result.map(::File)
|
||||
}
|
||||
|
||||
fun cleanDirtyInlineFunctions() {
|
||||
dirtyInlineFunctionsMap.clean()
|
||||
}
|
||||
|
||||
override fun processChangedInlineFunctions(className: JvmClassName, changedFunctions: Collection<String>) {
|
||||
if (changedFunctions.isNotEmpty()) {
|
||||
dirtyInlineFunctionsMap.put(className, changedFunctions.toList())
|
||||
}
|
||||
}
|
||||
|
||||
private inner class DirtyInlineFunctionsMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
|
||||
fun getEntries(): Map<JvmClassName, Collection<String>> =
|
||||
storage.keys.associateBy(JvmClassName::byInternalName) { storage[it]!! }
|
||||
|
||||
fun put(className: JvmClassName, changedFunctions: List<String>) {
|
||||
storage[className.internalName] = changedFunctions
|
||||
}
|
||||
|
||||
override fun dumpValue(value: Collection<String>) = value.dumpCollection()
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping: (sourceFile+inlineFunction)->(targetFiles)
|
||||
*
|
||||
* Where:
|
||||
* * sourceFile - path to some kotlin source
|
||||
* * inlineFunction - jvmSignature of some inline function in source file
|
||||
* * target files - collection of files inlineFunction has been inlined to
|
||||
*/
|
||||
private inner class InlineFunctionsFilesMap(storageFile: File) : BasicMap<PathFunctionPair, Collection<String>>(storageFile, PathFunctionPairKeyDescriptor, PathCollectionExternalizer) {
|
||||
fun add(sourcePath: String, jvmSignature: String, targetPath: String) {
|
||||
val key = PathFunctionPair(sourcePath, jvmSignature)
|
||||
storage.append(key, targetPath)
|
||||
}
|
||||
|
||||
operator fun get(sourcePath: String, jvmSignature: String): Collection<String> {
|
||||
val key = PathFunctionPair(sourcePath, jvmSignature)
|
||||
return storage[key] ?: emptySet()
|
||||
}
|
||||
|
||||
override fun dumpKey(key: PathFunctionPair): String =
|
||||
"(${key.path}, ${key.function})"
|
||||
|
||||
override fun dumpValue(value: Collection<String>) =
|
||||
value.dumpCollection()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DIRTY_INLINE_FUNCTIONS = "dirty-inline-functions"
|
||||
private val INLINED_TO = "inlined-to"
|
||||
}
|
||||
}
|
||||
|
||||
private class KotlinIncrementalStorageProvider(
|
||||
|
||||
Reference in New Issue
Block a user