Save info about inlined calls to incremental caches
This commit is contained in:
@@ -31,6 +31,9 @@ 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.PackageClassUtils;
|
||||
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.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
@@ -44,6 +47,7 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.types.expressions.LabelResolver;
|
||||
import org.jetbrains.org.objectweb.asm.Label;
|
||||
@@ -119,6 +123,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
isSameModule = JvmCodegenUtil.isCallInsideSameModuleAsDeclared(functionDescriptor, codegen.getContext(), state.getOutDirectory());
|
||||
|
||||
sourceMapper = codegen.getParentCodegen().getOrCreateSourceMapper();
|
||||
reportIncrementalInfo(functionDescriptor, codegen.getContext().getFunctionDescriptor().getOriginal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -736,4 +741,37 @@ public class InlineCodegen extends CallGenerator {
|
||||
return new NestedSourceMapper(sourceMapper, nodeAndSmap.getRanges(), nodeAndSmap.getClassSMAP().getSourceInfo());
|
||||
}
|
||||
|
||||
private void reportIncrementalInfo(
|
||||
@NotNull FunctionDescriptor sourceDescriptor,
|
||||
@NotNull FunctionDescriptor targetDescriptor
|
||||
) {
|
||||
IncrementalCompilationComponents incrementalCompilationComponents = state.getIncrementalCompilationComponents();
|
||||
String moduleId = state.getModuleId();
|
||||
|
||||
if (incrementalCompilationComponents == null || moduleId == null) return;
|
||||
|
||||
String sourceFile = getFilePath(sourceDescriptor);
|
||||
String targetFile = getFilePath(targetDescriptor);
|
||||
|
||||
if (sourceFile != null && targetFile != null) {
|
||||
IncrementalCache incrementalCache = incrementalCompilationComponents.getIncrementalCache(moduleId);
|
||||
InlineRegistering inlineRegistering = incrementalCache.getInlineRegistering();
|
||||
inlineRegistering.registerInline(sourceFile, jvmSignature.toString(), targetFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getFilePath(@NotNull FunctionDescriptor descriptor) {
|
||||
SourceElement source = descriptor.getSource();
|
||||
if (!(source instanceof PsiSourceElement)) return null;
|
||||
|
||||
PsiElement psi = ((PsiSourceElement) source).getPsi();
|
||||
if (psi == null) return null;
|
||||
|
||||
VirtualFile file = psi.getContainingFile().getVirtualFile();
|
||||
if (file == null) return null;
|
||||
|
||||
return file.getCanonicalPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user