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;
|
private final ReifiedTypeInliner reifiedTypeInliner;
|
||||||
@Nullable private final TypeParameterMappings typeParameterMappings;
|
@Nullable private final TypeParameterMappings typeParameterMappings;
|
||||||
private final boolean isDefaultCompilation;
|
private final boolean isDefaultMethodCompilation;
|
||||||
|
|
||||||
private LambdaInfo activeLambda;
|
private LambdaInfo activeLambda;
|
||||||
|
|
||||||
@@ -98,11 +98,11 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
@NotNull FunctionDescriptor function,
|
@NotNull FunctionDescriptor function,
|
||||||
@NotNull KtElement callElement,
|
@NotNull KtElement callElement,
|
||||||
@Nullable TypeParameterMappings typeParameterMappings,
|
@Nullable TypeParameterMappings typeParameterMappings,
|
||||||
boolean isDefaultCompilation
|
boolean isDefaultMethodCompilation
|
||||||
) {
|
) {
|
||||||
assert InlineUtil.isInline(function) || InlineUtil.isArrayConstructorWithLambda(function) :
|
assert InlineUtil.isInline(function) || InlineUtil.isArrayConstructorWithLambda(function) :
|
||||||
"InlineCodegen can inline only inline functions and array constructors: " + function;
|
"InlineCodegen can inline only inline functions and array constructors: " + function;
|
||||||
this.isDefaultCompilation = isDefaultCompilation;
|
this.isDefaultMethodCompilation = isDefaultMethodCompilation;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.typeMapper = state.getTypeMapper();
|
this.typeMapper = state.getTypeMapper();
|
||||||
this.codegen = codegen;
|
this.codegen = codegen;
|
||||||
@@ -148,7 +148,11 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
nodeAndSmap = createMethodNode(callDefault);
|
nodeAndSmap = createMethodNode(callDefault);
|
||||||
endCall(inlineCall(nodeAndSmap));
|
if (isDefaultMethodCompilation) {
|
||||||
|
nodeAndSmap.getNode().accept(new MethodBodyVisitor(codegen.v));
|
||||||
|
} else {
|
||||||
|
endCall(inlineCall(nodeAndSmap));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CompilationException e) {
|
catch (CompilationException e) {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -277,7 +281,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
|
|
||||||
InliningContext info = new RootInliningContext(
|
InliningContext info = new RootInliningContext(
|
||||||
expressionMap, state, codegen.getInlineNameGenerator().subGenerator(jvmSignature.getAsmMethod().getName()),
|
expressionMap, state, codegen.getInlineNameGenerator().subGenerator(jvmSignature.getAsmMethod().getName()),
|
||||||
codegen.getContext(), callElement, getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings, isDefaultCompilation,
|
codegen.getContext(), callElement, getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings,
|
||||||
AnnotationUtilKt.hasInlineOnlyAnnotation(functionDescriptor)
|
AnnotationUtilKt.hasInlineOnlyAnnotation(functionDescriptor)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -678,6 +682,11 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
@NotNull Type parameterType,
|
@NotNull Type parameterType,
|
||||||
@NotNull StackValue value
|
@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);
|
putValueIfNeeded(parameterType, value, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -288,8 +288,7 @@ public class MethodInliner {
|
|||||||
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false)) &&
|
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
|
||||||
!isDefaultCompilation()) {
|
|
||||||
// we will put it if needed in anew processing
|
// we will put it if needed in anew processing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -378,7 +377,6 @@ public class MethodInliner {
|
|||||||
) {
|
) {
|
||||||
if (isInliningLambda || GENERATE_DEBUG_INFO) {
|
if (isInliningLambda || GENERATE_DEBUG_INFO) {
|
||||||
String varSuffix = inliningContext.isRoot() &&
|
String varSuffix = inliningContext.isRoot() &&
|
||||||
!isDefaultCompilation() &&
|
|
||||||
!InlineCodegenUtil.isFakeLocalVariableForInline(name) ?
|
!InlineCodegenUtil.isFakeLocalVariableForInline(name) ?
|
||||||
INLINE_FUN_VAR_SUFFIX : "";
|
INLINE_FUN_VAR_SUFFIX : "";
|
||||||
String varName = !varSuffix.isEmpty() && name.equals("this") ? name + "_" : name;
|
String varName = !varSuffix.isEmpty() && name.equals("this") ? name + "_" : name;
|
||||||
@@ -446,7 +444,7 @@ public class MethodInliner {
|
|||||||
|
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
if (ReifiedTypeInliner.isNeedClassReificationMarker(cur)) {
|
if (ReifiedTypeInliner.isNeedClassReificationMarker(cur)) {
|
||||||
awaitClassReification = !isDefaultCompilation();
|
awaitClassReification = true;
|
||||||
}
|
}
|
||||||
else if (cur.getType() == AbstractInsnNode.METHOD_INSN) {
|
else if (cur.getType() == AbstractInsnNode.METHOD_INSN) {
|
||||||
if (InlineCodegenUtil.isFinallyStart(cur)) {
|
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;
|
public final CodegenContext startContext;
|
||||||
private final InlineCallSiteInfo inlineCallSiteInfo;
|
private final InlineCallSiteInfo inlineCallSiteInfo;
|
||||||
public final TypeParameterMappings typeParameterMappings;
|
public final TypeParameterMappings typeParameterMappings;
|
||||||
public final boolean isDefaultCompilation;
|
|
||||||
public final boolean skipSmap;
|
public final boolean skipSmap;
|
||||||
public final KtElement callElement;
|
public final KtElement callElement;
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ public class RootInliningContext extends InliningContext {
|
|||||||
@NotNull InlineCallSiteInfo classNameToInline,
|
@NotNull InlineCallSiteInfo classNameToInline,
|
||||||
@NotNull ReifiedTypeInliner inliner,
|
@NotNull ReifiedTypeInliner inliner,
|
||||||
@Nullable TypeParameterMappings typeParameterMappings,
|
@Nullable TypeParameterMappings typeParameterMappings,
|
||||||
boolean isDefaultCompilation,
|
|
||||||
boolean skipSmap
|
boolean skipSmap
|
||||||
) {
|
) {
|
||||||
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
||||||
@@ -49,7 +47,6 @@ public class RootInliningContext extends InliningContext {
|
|||||||
this.startContext = startContext;
|
this.startContext = startContext;
|
||||||
this.inlineCallSiteInfo = classNameToInline;
|
this.inlineCallSiteInfo = classNameToInline;
|
||||||
this.typeParameterMappings = typeParameterMappings;
|
this.typeParameterMappings = typeParameterMappings;
|
||||||
this.isDefaultCompilation = isDefaultCompilation;
|
|
||||||
this.skipSmap = skipSmap;
|
this.skipSmap = skipSmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at remappedParameterInInline.kt:11
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! remappedParameterInInline.RemappedParameterInInlineKt
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
remappedParameterInInline.kt:11
|
||||||
|
Compile bytecode for p
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package remappedParameterInInline
|
||||||
|
|
||||||
|
inline fun watch(p: String, f: (String) -> Int) {
|
||||||
|
f(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun inlineDefault(p: Int = 1, f: (Int) -> Unit) {
|
||||||
|
// EXPRESSION: p
|
||||||
|
// RESULT: 1: I
|
||||||
|
//Breakpoint!
|
||||||
|
f(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val local = "mno"
|
||||||
|
watch(local) { it.length }
|
||||||
|
|
||||||
|
inlineDefault { it }
|
||||||
|
}
|
||||||
+6
@@ -790,6 +790,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
doMultipleBreakpointsTest(fileName);
|
doMultipleBreakpointsTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("remappedParameterInInline.kt")
|
||||||
|
public void testRemappedParameterInInline() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/remappedParameterInInline.kt");
|
||||||
|
doMultipleBreakpointsTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("whenEntry.kt")
|
@TestMetadata("whenEntry.kt")
|
||||||
public void testWhenEntry() throws Exception {
|
public void testWhenEntry() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/whenEntry.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/whenEntry.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user