Separately process inline function default impl body compilation (non general inline magic),
Fix for KT-10670 Debugger: Evaluate Expression/Watches fail for inline function parameter initialized with default value #KT-10670 Fixed
This commit is contained in:
@@ -86,7 +86,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
|
||||
private final ReifiedTypeInliner reifiedTypeInliner;
|
||||
@Nullable private final TypeParameterMappings typeParameterMappings;
|
||||
private final boolean isDefaultCompilation;
|
||||
private final boolean isDefaultMethodCompilation;
|
||||
|
||||
private LambdaInfo activeLambda;
|
||||
|
||||
@@ -98,11 +98,11 @@ public class InlineCodegen extends CallGenerator {
|
||||
@NotNull FunctionDescriptor function,
|
||||
@NotNull KtElement callElement,
|
||||
@Nullable TypeParameterMappings typeParameterMappings,
|
||||
boolean isDefaultCompilation
|
||||
boolean isDefaultMethodCompilation
|
||||
) {
|
||||
assert InlineUtil.isInline(function) || InlineUtil.isArrayConstructorWithLambda(function) :
|
||||
"InlineCodegen can inline only inline functions and array constructors: " + function;
|
||||
this.isDefaultCompilation = isDefaultCompilation;
|
||||
this.isDefaultMethodCompilation = isDefaultMethodCompilation;
|
||||
this.state = state;
|
||||
this.typeMapper = state.getTypeMapper();
|
||||
this.codegen = codegen;
|
||||
@@ -148,7 +148,11 @@ public class InlineCodegen extends CallGenerator {
|
||||
|
||||
try {
|
||||
nodeAndSmap = createMethodNode(callDefault);
|
||||
endCall(inlineCall(nodeAndSmap));
|
||||
if (isDefaultMethodCompilation) {
|
||||
nodeAndSmap.getNode().accept(new MethodBodyVisitor(codegen.v));
|
||||
} else {
|
||||
endCall(inlineCall(nodeAndSmap));
|
||||
}
|
||||
}
|
||||
catch (CompilationException e) {
|
||||
throw e;
|
||||
@@ -277,7 +281,7 @@ 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,
|
||||
AnnotationUtilKt.hasInlineOnlyAnnotation(functionDescriptor)
|
||||
);
|
||||
|
||||
@@ -678,6 +682,11 @@ public class InlineCodegen extends CallGenerator {
|
||||
@NotNull Type parameterType,
|
||||
@NotNull StackValue value
|
||||
) {
|
||||
if (isDefaultMethodCompilation) {
|
||||
//original method would be inlined directly into default impl body without any inline magic
|
||||
//so we no need to load variables on stack to further method call
|
||||
return;
|
||||
}
|
||||
putValueIfNeeded(parameterType, value, -1);
|
||||
}
|
||||
|
||||
|
||||
@@ -288,8 +288,7 @@ public class MethodInliner {
|
||||
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
||||
}
|
||||
}
|
||||
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false)) &&
|
||||
!isDefaultCompilation()) {
|
||||
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
|
||||
// we will put it if needed in anew processing
|
||||
}
|
||||
else {
|
||||
@@ -378,7 +377,6 @@ public class MethodInliner {
|
||||
) {
|
||||
if (isInliningLambda || GENERATE_DEBUG_INFO) {
|
||||
String varSuffix = inliningContext.isRoot() &&
|
||||
!isDefaultCompilation() &&
|
||||
!InlineCodegenUtil.isFakeLocalVariableForInline(name) ?
|
||||
INLINE_FUN_VAR_SUFFIX : "";
|
||||
String varName = !varSuffix.isEmpty() && name.equals("this") ? name + "_" : name;
|
||||
@@ -446,7 +444,7 @@ public class MethodInliner {
|
||||
|
||||
if (frame != null) {
|
||||
if (ReifiedTypeInliner.isNeedClassReificationMarker(cur)) {
|
||||
awaitClassReification = !isDefaultCompilation();
|
||||
awaitClassReification = true;
|
||||
}
|
||||
else if (cur.getType() == AbstractInsnNode.METHOD_INSN) {
|
||||
if (InlineCodegenUtil.isFinallyStart(cur)) {
|
||||
@@ -809,8 +807,4 @@ public class MethodInliner {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isDefaultCompilation() {
|
||||
return inliningContext.isRoot() && ((RootInliningContext) inliningContext).isDefaultCompilation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class RootInliningContext extends InliningContext {
|
||||
public final CodegenContext startContext;
|
||||
private final InlineCallSiteInfo inlineCallSiteInfo;
|
||||
public final TypeParameterMappings typeParameterMappings;
|
||||
public final boolean isDefaultCompilation;
|
||||
public final boolean skipSmap;
|
||||
public final KtElement callElement;
|
||||
|
||||
@@ -41,7 +40,6 @@ public class RootInliningContext extends InliningContext {
|
||||
@NotNull InlineCallSiteInfo classNameToInline,
|
||||
@NotNull ReifiedTypeInliner inliner,
|
||||
@Nullable TypeParameterMappings typeParameterMappings,
|
||||
boolean isDefaultCompilation,
|
||||
boolean skipSmap
|
||||
) {
|
||||
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
||||
@@ -49,7 +47,6 @@ public class RootInliningContext extends InliningContext {
|
||||
this.startContext = startContext;
|
||||
this.inlineCallSiteInfo = classNameToInline;
|
||||
this.typeParameterMappings = typeParameterMappings;
|
||||
this.isDefaultCompilation = isDefaultCompilation;
|
||||
this.skipSmap = skipSmap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user