Extracted common function getRecompilationDecision.

Original commit: 478118c12a
This commit is contained in:
Evgeny Gerashchenko
2015-02-06 16:01:28 +03:00
parent 60d7e39c98
commit 06875cc4b6
@@ -119,6 +119,14 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen
} }
} }
private fun getRecompilationDecision(protoChanged: Boolean, constantsChanged: Boolean, inlinesChanged: Boolean) =
when {
inlinesChanged -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS
constantsChanged -> RECOMPILE_OTHERS_WITH_DEPENDANTS
protoChanged -> RECOMPILE_OTHERS_IN_CHUNK
else -> DO_NOTHING
}
public fun saveFileToCache(sourceFiles: Collection<File>, classFile: File): RecompilationDecision { public fun saveFileToCache(sourceFiles: Collection<File>, classFile: File): RecompilationDecision {
if (classFile.extension.toLowerCase() != "class") return DO_NOTHING if (classFile.extension.toLowerCase() != "class") return DO_NOTHING
@@ -137,22 +145,19 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen
val annotationDataEncoded = header.annotationData val annotationDataEncoded = header.annotationData
if (annotationDataEncoded != null) { if (annotationDataEncoded != null) {
val data = BitEncoding.decodeBytes(annotationDataEncoded) val data = BitEncoding.decodeBytes(annotationDataEncoded)
when { return when {
header.isCompatiblePackageFacadeKind() -> { header.isCompatiblePackageFacadeKind() ->
return if (protoMap.put(className, data)) RECOMPILE_OTHERS_IN_CHUNK else DO_NOTHING getRecompilationDecision(
} protoChanged = protoMap.put(className, data),
header.isCompatibleClassKind() -> { constantsChanged = false,
val inlinesChanged = inlineFunctionsMap.process(className, fileBytes) inlinesChanged = false
val protoChanged = protoMap.put(className, data) )
val constantsChanged = constantsMap.process(className, fileBytes) header.isCompatibleClassKind() ->
getRecompilationDecision(
return when { protoChanged = protoMap.put(className, data),
inlinesChanged -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS constantsChanged = constantsMap.process(className, fileBytes),
constantsChanged -> RECOMPILE_OTHERS_WITH_DEPENDANTS inlinesChanged = inlineFunctionsMap.process(className, fileBytes)
protoChanged -> RECOMPILE_OTHERS_IN_CHUNK )
else -> DO_NOTHING
}
}
else -> { else -> {
throw IllegalStateException("Unexpected kind with annotationData: ${header.kind}, isCompatible: ${header.isCompatibleAbiVersion}") throw IllegalStateException("Unexpected kind with annotationData: ${header.kind}, isCompatible: ${header.isCompatibleAbiVersion}")
} }
@@ -163,14 +168,12 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen
assert(sourceFiles.size() == 1) { "Package part from several source files: $sourceFiles" } assert(sourceFiles.size() == 1) { "Package part from several source files: $sourceFiles" }
packagePartMap.addPackagePart(className) packagePartMap.addPackagePart(className)
val inlinesChanged = inlineFunctionsMap.process(className, fileBytes)
val constantsChanged = constantsMap.process(className, fileBytes)
return when { return getRecompilationDecision(
inlinesChanged -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS protoChanged = false,
constantsChanged -> RECOMPILE_OTHERS_WITH_DEPENDANTS constantsChanged = constantsMap.process(className, fileBytes),
else -> DO_NOTHING inlinesChanged = inlineFunctionsMap.process(className, fileBytes)
} )
} }
return DO_NOTHING return DO_NOTHING
@@ -181,12 +184,12 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen
for (internalClassName in dirtyOutputClassesMap.getDirtyOutputClasses()) { for (internalClassName in dirtyOutputClassesMap.getDirtyOutputClasses()) {
val className = JvmClassName.byInternalName(internalClassName) val className = JvmClassName.byInternalName(internalClassName)
val newDecision = when { val newDecision = getRecompilationDecision(
internalClassName in inlineFunctionsMap -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS protoChanged = internalClassName in protoMap,
internalClassName in constantsMap -> RECOMPILE_OTHERS_WITH_DEPENDANTS constantsChanged = internalClassName in constantsMap,
internalClassName in protoMap -> RECOMPILE_OTHERS_IN_CHUNK inlinesChanged = internalClassName in inlineFunctionsMap
else -> DO_NOTHING )
}
recompilationDecision = recompilationDecision.merge(newDecision) recompilationDecision = recompilationDecision.merge(newDecision)
protoMap.remove(className) protoMap.remove(className)