Use both target name and target type to get incremental cache from backend

This commit is contained in:
Alexey Tsvetkov
2015-08-11 16:25:54 +03:00
parent 18dc752c21
commit 0988b21e9c
16 changed files with 81 additions and 39 deletions
@@ -143,7 +143,7 @@ public class PackageCodegen {
// TODO rewrite it to something more robust when module system is implemented
for (PackageFragmentDescriptor fragment : state.getModule().getPackage(fqName).getFragments()) {
if (fragment instanceof IncrementalPackageFragmentProvider.IncrementalPackageFragment &&
((IncrementalPackageFragmentProvider.IncrementalPackageFragment) fragment).getModuleId().equals(state.getModuleId())) {
((IncrementalPackageFragmentProvider.IncrementalPackageFragment) fragment).getTarget().equals(state.getTarget())) {
return fragment;
}
}
@@ -33,9 +33,9 @@ fun List<PackageParts>.addCompiledPartsAndSort(state: GenerationState): List<Pac
addCompiledParts(state).sortedBy { it.packageFqName }
private fun List<PackageParts>.addCompiledParts(state: GenerationState): List<PackageParts> {
if (state.incrementalCompilationComponents == null || state.moduleId == null) return this
if (state.incrementalCompilationComponents == null || state.target == null) return this
val incrementalCache = state.incrementalCompilationComponents.getIncrementalCache(state.moduleId)
val incrementalCache = state.incrementalCompilationComponents.getIncrementalCache(state.target)
val moduleMappingData = incrementalCache.getModuleMappingData() ?: return this
val mapping = ModuleMapping.create(moduleMappingData)
@@ -30,10 +30,14 @@ import org.jetbrains.kotlin.codegen.context.PackageContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.load.kotlin.*;
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass;
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass;
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents;
import org.jetbrains.kotlin.load.kotlin.incremental.components.InlineRegistering;
import org.jetbrains.kotlin.modules.Module;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
@@ -746,9 +750,9 @@ public class InlineCodegen extends CallGenerator {
@NotNull FunctionDescriptor targetDescriptor
) {
IncrementalCompilationComponents incrementalCompilationComponents = state.getIncrementalCompilationComponents();
String moduleId = state.getModuleId();
Module target = state.getTarget();
if (incrementalCompilationComponents == null || moduleId == null) return;
if (incrementalCompilationComponents == null || target == null) return;
String sourceFile = getFilePath(sourceDescriptor);
String targetFile = getFilePath(targetDescriptor);
@@ -765,7 +769,7 @@ public class InlineCodegen extends CallGenerator {
assert sourceFile != null: "No source file for inline fun: " + jvmSignature;
assert targetFile != null: "No target file for inline fun: " + jvmSignature;
IncrementalCache incrementalCache = incrementalCompilationComponents.getIncrementalCache(moduleId);
IncrementalCache incrementalCache = incrementalCompilationComponents.getIncrementalCache(target);
InlineRegistering inlineRegistering = incrementalCache.getInlineRegistering();
inlineRegistering.registerInline(sourceFile, jvmSignature.toString(), targetFile);
}
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetFile
@@ -51,7 +52,7 @@ public class GenerationState jvmOverloads constructor(
public val diagnostics: DiagnosticSink = DiagnosticSink.DO_NOTHING,
public val packagesWithObsoleteParts: Collection<FqName> = emptySet(),
// for PackageCodegen in incremental compilation mode
public val moduleId: String? = null,
public val target: Module? = null,
moduleName: String? = null,
// TODO: temporary hack, see JetTypeMapperWithOutDirectory state for details
public val outDirectory: File? = null,