Don't generate source mapping on inlining 'InlineOnly' functions
This commit is contained in:
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
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.callUtil.CallUtilKt;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||||
@@ -276,7 +277,8 @@ 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, isDefaultCompilation,
|
||||||
|
AnnotationUtilKt.hasInlineOnlyAnnotation(functionDescriptor)
|
||||||
);
|
);
|
||||||
|
|
||||||
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule,
|
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule,
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public class MethodInliner {
|
|||||||
|
|
||||||
private int lambdasFinallyBlocks;
|
private int lambdasFinallyBlocks;
|
||||||
|
|
||||||
|
private final boolean skipSmap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
@@ -98,6 +100,7 @@ public class MethodInliner {
|
|||||||
this.inlineCallSiteInfo = inlineCallSiteInfo;
|
this.inlineCallSiteInfo = inlineCallSiteInfo;
|
||||||
this.typeMapper = inliningContext.state.getTypeMapper();
|
this.typeMapper = inliningContext.state.getTypeMapper();
|
||||||
this.result = InlineResult.create();
|
this.result = InlineResult.create();
|
||||||
|
skipSmap = inliningContext instanceof RootInliningContext && ((RootInliningContext) inliningContext).skipSmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InlineResult doInline(
|
public InlineResult doInline(
|
||||||
@@ -339,6 +342,8 @@ public class MethodInliner {
|
|||||||
node.instructions.resetLabels();
|
node.instructions.resetLabels();
|
||||||
MethodNode transformedNode = new MethodNode(InlineCodegenUtil.API, node.access, node.name, Type.getMethodDescriptor(returnType, allTypes), node.signature, null) {
|
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 final boolean isInliningLambda = nodeRemapper.isInsideInliningLambda();
|
||||||
|
|
||||||
private int getNewIndex(int var) {
|
private int getNewIndex(int var) {
|
||||||
@@ -362,7 +367,7 @@ public class MethodInliner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLineNumber(int line, @NotNull Label start) {
|
public void visitLineNumber(int line, @NotNull Label start) {
|
||||||
if(isInliningLambda || InlineCodegenUtil.GENERATE_SMAP) {
|
if(isInliningLambda || GENERATE_DEBUG_INFO) {
|
||||||
super.visitLineNumber(line, start);
|
super.visitLineNumber(line, start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,7 +376,7 @@ public class MethodInliner {
|
|||||||
public void visitLocalVariable(
|
public void visitLocalVariable(
|
||||||
@NotNull String name, @NotNull String desc, String signature, @NotNull Label start, @NotNull Label end, int index
|
@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() &&
|
String varSuffix = inliningContext.isRoot() &&
|
||||||
!isDefaultCompilation() &&
|
!isDefaultCompilation() &&
|
||||||
!InlineCodegenUtil.isFakeLocalVariableForInline(name) ?
|
!InlineCodegenUtil.isFakeLocalVariableForInline(name) ?
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class RootInliningContext extends InliningContext {
|
|||||||
private final InlineCallSiteInfo inlineCallSiteInfo;
|
private final InlineCallSiteInfo inlineCallSiteInfo;
|
||||||
public final TypeParameterMappings typeParameterMappings;
|
public final TypeParameterMappings typeParameterMappings;
|
||||||
public final boolean isDefaultCompilation;
|
public final boolean isDefaultCompilation;
|
||||||
|
public final boolean skipSmap;
|
||||||
public final KtElement callElement;
|
public final KtElement callElement;
|
||||||
|
|
||||||
public RootInliningContext(
|
public RootInliningContext(
|
||||||
@@ -40,7 +41,8 @@ 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 isDefaultCompilation,
|
||||||
|
boolean skipSmap
|
||||||
) {
|
) {
|
||||||
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
||||||
this.callElement = callElement;
|
this.callElement = callElement;
|
||||||
@@ -48,6 +50,7 @@ public class RootInliningContext extends InliningContext {
|
|||||||
this.inlineCallSiteInfo = classNameToInline;
|
this.inlineCallSiteInfo = classNameToInline;
|
||||||
this.typeParameterMappings = typeParameterMappings;
|
this.typeParameterMappings = typeParameterMappings;
|
||||||
this.isDefaultCompilation = isDefaultCompilation;
|
this.isDefaultCompilation = isDefaultCompilation;
|
||||||
|
this.skipSmap = skipSmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
fun box(): String {
|
||||||
|
return "KO".reversed()
|
||||||
|
}
|
||||||
|
|
||||||
|
//SMAP
|
||||||
|
//noSmap.1.kt
|
||||||
|
//Kotlin
|
||||||
|
//*S Kotlin
|
||||||
|
//*F
|
||||||
|
//+ 1 noSmap.1.kt
|
||||||
|
//NoSmap_1Kt
|
||||||
|
//*L
|
||||||
|
//1#1,14:1
|
||||||
|
//*E
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
inline fun stub() {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val z = className<String>()
|
||||||
|
if (z != "String") return "fail: $z"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
//SMAP
|
||||||
|
//reified.1.kt
|
||||||
|
//Kotlin
|
||||||
|
//*S Kotlin
|
||||||
|
//*F
|
||||||
|
//+ 1 reified.1.kt
|
||||||
|
//Reified_1Kt
|
||||||
|
//+ 2 reified.2.kt
|
||||||
|
//test/Reified_2Kt
|
||||||
|
//*L
|
||||||
|
//1#1,22:1
|
||||||
|
//3#2:23
|
||||||
|
//*E
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
inline fun <reified T> className() = T::class.simpleName
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Return code: 0
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package InlineOnly
|
||||||
|
|
||||||
|
fun main(args : Array<String>) {
|
||||||
|
error("my error")
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
ERR:
|
||||||
|
Exception in thread "main" java.lang.IllegalStateException: my error
|
||||||
|
at InlineOnly.InlineOnlyKt.main(inlineOnly.kt:4)
|
||||||
|
|
||||||
|
Return code: 1
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
ERR:
|
ERR:
|
||||||
java.lang.IllegalStateException: my error
|
java.lang.IllegalStateException: my error
|
||||||
at Script.main(script.kts:12)
|
at Script.main(script.kts:2)
|
||||||
at Script.a(script.kts:6)
|
at Script.a(script.kts:6)
|
||||||
at Script.<init>(script.kts:9)
|
at Script.<init>(script.kts:9)
|
||||||
|
|
||||||
|
|||||||
+21
@@ -1834,6 +1834,27 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class InlineOnly extends AbstractBlackBoxInlineCodegenTest {
|
||||||
|
public void testAllFilesPresentInInlineOnly() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/inlineOnly"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noSmap.1.kt")
|
||||||
|
public void testNoSmap() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly/noSmap.1.kt");
|
||||||
|
doTestMultiFileWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reified.1.kt")
|
||||||
|
public void testReified() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly/reified.1.kt");
|
||||||
|
doTestMultiFileWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/smap/resolve")
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/resolve")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -70,4 +70,12 @@ public class CompilerSmokeTest extends CompilerSmokeTestBase {
|
|||||||
|
|
||||||
runCompiler("script", "script.kts", "-d", jar);
|
runCompiler("script", "script.kts", "-d", jar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInlineOnly() throws Exception {
|
||||||
|
String jar = tmpdir.getAbsolutePath() + File.separator + "inlineOnly.jar";
|
||||||
|
|
||||||
|
assertEquals("compilation failed", 0, runCompiler("inlineOnly.compile", "-include-runtime", "inlineOnly.kt", "-d", jar));
|
||||||
|
run("inlineOnly.run", "-cp", jar, "InlineOnly.InlineOnlyKt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
@@ -1834,6 +1834,27 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class InlineOnly extends AbstractCompileKotlinAgainstInlineKotlinTest {
|
||||||
|
public void testAllFilesPresentInInlineOnly() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/inlineOnly"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noSmap.1.kt")
|
||||||
|
public void testNoSmap() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly/noSmap.1.kt");
|
||||||
|
doBoxTestWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reified.1.kt")
|
||||||
|
public void testReified() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly/reified.1.kt");
|
||||||
|
doBoxTestWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/smap/resolve")
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/resolve")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
LineBreakpoint created at inlineOnly.kt:5
|
||||||
|
!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! inlineOnly.InlineOnlyKt
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
inlineOnly.kt:5
|
||||||
|
PrintStream.!EXT!
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
|
OK
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package inlineOnly
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
//Breakpoint!
|
||||||
|
println("OK")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TRACING_FILTERS_ENABLED: false
|
||||||
@@ -235,6 +235,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
doStepIntoTest(fileName);
|
doStepIntoTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineOnly.kt")
|
||||||
|
public void testInlineOnly() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/inlineOnly.kt");
|
||||||
|
doStepIntoTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("returnVoid.kt")
|
@TestMetadata("returnVoid.kt")
|
||||||
public void testReturnVoid() throws Exception {
|
public void testReturnVoid() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/returnVoid.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/returnVoid.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user