Don't generate source mapping on inlining 'InlineOnly' functions

This commit is contained in:
Michael Bogdanov
2016-02-17 15:05:32 +03:00
parent 6f1def9366
commit 1d17bee6cc
17 changed files with 143 additions and 5 deletions
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
@@ -276,7 +277,8 @@ public class InlineCodegen extends CallGenerator {
InliningContext info = new RootInliningContext(
expressionMap, state, codegen.getInlineNameGenerator().subGenerator(jvmSignature.getAsmMethod().getName()),
codegen.getContext(), callElement, getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings, isDefaultCompilation
codegen.getContext(), callElement, getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings, isDefaultCompilation,
AnnotationUtilKt.hasInlineOnlyAnnotation(functionDescriptor)
);
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule,
@@ -71,6 +71,8 @@ public class MethodInliner {
private int lambdasFinallyBlocks;
private final boolean skipSmap;
/*
*
* @param node
@@ -98,6 +100,7 @@ public class MethodInliner {
this.inlineCallSiteInfo = inlineCallSiteInfo;
this.typeMapper = inliningContext.state.getTypeMapper();
this.result = InlineResult.create();
skipSmap = inliningContext instanceof RootInliningContext && ((RootInliningContext) inliningContext).skipSmap;
}
public InlineResult doInline(
@@ -339,6 +342,8 @@ public class MethodInliner {
node.instructions.resetLabels();
MethodNode transformedNode = new MethodNode(InlineCodegenUtil.API, node.access, node.name, Type.getMethodDescriptor(returnType, allTypes), node.signature, null) {
private final boolean GENERATE_DEBUG_INFO = InlineCodegenUtil.GENERATE_SMAP && !skipSmap;
private final boolean isInliningLambda = nodeRemapper.isInsideInliningLambda();
private int getNewIndex(int var) {
@@ -362,7 +367,7 @@ public class MethodInliner {
@Override
public void visitLineNumber(int line, @NotNull Label start) {
if(isInliningLambda || InlineCodegenUtil.GENERATE_SMAP) {
if(isInliningLambda || GENERATE_DEBUG_INFO) {
super.visitLineNumber(line, start);
}
}
@@ -371,7 +376,7 @@ public class MethodInliner {
public void visitLocalVariable(
@NotNull String name, @NotNull String desc, String signature, @NotNull Label start, @NotNull Label end, int index
) {
if (isInliningLambda || InlineCodegenUtil.GENERATE_SMAP) {
if (isInliningLambda || GENERATE_DEBUG_INFO) {
String varSuffix = inliningContext.isRoot() &&
!isDefaultCompilation() &&
!InlineCodegenUtil.isFakeLocalVariableForInline(name) ?
@@ -29,6 +29,7 @@ public class RootInliningContext extends InliningContext {
private final InlineCallSiteInfo inlineCallSiteInfo;
public final TypeParameterMappings typeParameterMappings;
public final boolean isDefaultCompilation;
public final boolean skipSmap;
public final KtElement callElement;
public RootInliningContext(
@@ -40,7 +41,8 @@ public class RootInliningContext extends InliningContext {
@NotNull InlineCallSiteInfo classNameToInline,
@NotNull ReifiedTypeInliner inliner,
@Nullable TypeParameterMappings typeParameterMappings,
boolean isDefaultCompilation
boolean isDefaultCompilation,
boolean skipSmap
) {
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
this.callElement = callElement;
@@ -48,6 +50,7 @@ public class RootInliningContext extends InliningContext {
this.inlineCallSiteInfo = classNameToInline;
this.typeParameterMappings = typeParameterMappings;
this.isDefaultCompilation = isDefaultCompilation;
this.skipSmap = skipSmap;
}
@Override