Temporary disable smap generation
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.inline.FileMapping;
|
||||
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.kotlin.codegen.inline.SMAPBuilder;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
@@ -103,7 +104,7 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
if (!fileMappings.isEmpty()) {
|
||||
if (!fileMappings.isEmpty() && InlineCodegenUtil.GENERATE_SMAP) {
|
||||
FileMapping origin = fileMappings.get(0);
|
||||
assert sourceName == null || origin.getName().equals(sourceName) : "Error " + origin.getName() + " != " + sourceName;
|
||||
getVisitor().visitSource(origin.getName(), new SMAPBuilder(origin.getName(), origin.getPath(), fileMappings).build());
|
||||
|
||||
+6
-1
@@ -167,9 +167,14 @@ public class AnonymousObjectTransformer {
|
||||
//seems we can't do any clever mapping cause we don't know any about original class name
|
||||
sourceMapper = IdenticalSourceMapper.INSTANCE$;
|
||||
}
|
||||
if (sourceInfo != null && !InlineCodegenUtil.GENERATE_SMAP) {
|
||||
classBuilder.visitSource(sourceInfo, debugInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
classBuilder.visitSource(sourceInfo, debugInfo);
|
||||
if (sourceInfo != null) {
|
||||
classBuilder.visitSource(sourceInfo, debugInfo);
|
||||
}
|
||||
sourceMapper = IdenticalSourceMapper.INSTANCE$;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,12 @@ public class InlineAdapter extends InstructionAdapter {
|
||||
|
||||
@Override
|
||||
public void visitLineNumber(int line, Label start) {
|
||||
sourceMapper.visitLineNumber(mv, line, start);
|
||||
if (InlineCodegenUtil.GENERATE_SMAP) {
|
||||
sourceMapper.visitLineNumber(mv, line, start);
|
||||
}
|
||||
else {
|
||||
super.visitLineNumber(line, start);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,6 +63,7 @@ import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isTrait;
|
||||
|
||||
public class InlineCodegenUtil {
|
||||
public static final boolean GENERATE_SMAP = false;
|
||||
public static final int API = Opcodes.ASM5;
|
||||
public static final String INVOKE = "invoke";
|
||||
|
||||
@@ -124,7 +125,7 @@ public class InlineCodegenUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, ClassReader.SKIP_FRAMES);
|
||||
}, ClassReader.SKIP_FRAMES | (GENERATE_SMAP ? 0 : ClassReader.SKIP_DEBUG));
|
||||
|
||||
SMAP smap = SMAPParser.parseOrCreateDefault(debugInfo[1], debugInfo[0], classId.toString(), lines[0], lines[1]);
|
||||
return new SMAPAndMethodNode(node[0], smap);
|
||||
|
||||
@@ -329,6 +329,13 @@ public class MethodInliner {
|
||||
super.visitMaxs(maxStack, maxLocals + capturedParamsSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLineNumber(int line, @NotNull Label start) {
|
||||
if(isInliningLambda || InlineCodegenUtil.GENERATE_SMAP) {
|
||||
super.visitLineNumber(line, start);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalVariable(
|
||||
@NotNull String name, @NotNull String desc, String signature, @NotNull Label start, @NotNull Label end, int index
|
||||
|
||||
@@ -367,5 +367,4 @@ data open public class RangeMapping(val source: Int, val dest: Int, var range: I
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,4 +12,4 @@ fun foo() {
|
||||
.bar()
|
||||
}
|
||||
|
||||
// 2 3 7 8 9 11 12 17 13
|
||||
// 2 3 7 8 9 11 12 13
|
||||
|
||||
@@ -12,4 +12,4 @@ fun foo() {
|
||||
.bar()
|
||||
}
|
||||
|
||||
// 2 3 7 8 9 11 17 12 17 13
|
||||
// 2 3 7 8 9 11 12 13
|
||||
|
||||
@@ -9,4 +9,4 @@ fun foo(i: Int = 1) {
|
||||
inline fun bar(i: Int = 1) {
|
||||
}
|
||||
|
||||
// 2 3 9 4 7 6 10 9 10
|
||||
// 2 3 4 7 6 10 9
|
||||
|
||||
@@ -13,4 +13,4 @@ inline fun foo(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
|
||||
// 2 12 3 6 12 7 9 12 13 14
|
||||
// 2 3 6 7 9 12 13 14
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFile
|
||||
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
@@ -65,6 +66,10 @@ public trait AbstractSMAPBaseTest {
|
||||
}
|
||||
|
||||
fun checkSMAP(inputFiles: List<JetFile>, outputFiles: List<OutputFile>) {
|
||||
if (!InlineCodegenUtil.GENERATE_SMAP) {
|
||||
return
|
||||
}
|
||||
|
||||
val sourceData = inputFiles.map { extractSmapFromSource(it) }.filterNotNull()
|
||||
val compiledData = extractSMAPFromClasses(outputFiles).groupBy {
|
||||
it.sourceFile
|
||||
|
||||
+34
-18
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollectorPlainTextToStrea
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
|
||||
@@ -222,15 +223,21 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
"-d", tmpdir.getPath()
|
||||
));
|
||||
|
||||
ClassWriter cw;
|
||||
File inlineFunClass = new File(tmpdir.getAbsolutePath(), "test/A.class");
|
||||
ClassReader reader = new ClassReader(new FileInputStream(inlineFunClass));
|
||||
ClassWriter cw = new ClassWriter(Opcodes.ASM5);
|
||||
reader.accept(new ClassVisitor(Opcodes.ASM5, cw) {
|
||||
@Override
|
||||
public void visitSource(String source, String debug) {
|
||||
//skip debug info
|
||||
}
|
||||
}, 0);
|
||||
FileInputStream is = new FileInputStream(inlineFunClass);
|
||||
try {
|
||||
ClassReader reader = new ClassReader(is);
|
||||
cw = new ClassWriter(Opcodes.ASM5);
|
||||
reader.accept(new ClassVisitor(Opcodes.ASM5, cw) {
|
||||
@Override
|
||||
public void visitSource(String source, String debug) {
|
||||
//skip debug info
|
||||
}
|
||||
}, 0);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
|
||||
assert inlineFunClass.delete();
|
||||
assert !inlineFunClass.exists();
|
||||
@@ -250,16 +257,21 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
"-d", tmpdir.getPath()
|
||||
));
|
||||
|
||||
File resultFile = new File(tmpdir.getAbsolutePath(), "test/B.class");
|
||||
reader = new ClassReader(new FileInputStream(resultFile));
|
||||
final Ref<String> debugInfo = new Ref<String>();
|
||||
reader.accept(new ClassVisitor(Opcodes.ASM5) {
|
||||
@Override
|
||||
public void visitSource(String source, String debug) {
|
||||
//skip debug info
|
||||
debugInfo.set(debug);
|
||||
}
|
||||
}, 0);
|
||||
File resultFile = new File(tmpdir.getAbsolutePath(), "test/B.class");
|
||||
FileInputStream resultStream = new FileInputStream(resultFile);
|
||||
try {
|
||||
ClassReader reader = new ClassReader(resultStream);
|
||||
reader.accept(new ClassVisitor(Opcodes.ASM5) {
|
||||
@Override
|
||||
public void visitSource(String source, String debug) {
|
||||
//skip debug info
|
||||
debugInfo.set(debug);
|
||||
}
|
||||
}, 0);
|
||||
} finally {
|
||||
resultStream.close();
|
||||
}
|
||||
|
||||
String expected = "SMAP\n" +
|
||||
"source.kt\n" +
|
||||
@@ -272,6 +284,10 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
"1#1,13:1\n" +
|
||||
"*E\n";
|
||||
|
||||
assertEquals(expected, debugInfo.get());
|
||||
if (InlineCodegenUtil.GENERATE_SMAP) {
|
||||
assertEquals(expected, debugInfo.get());
|
||||
} else {
|
||||
assertEquals(null, debugInfo.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
LineBreakpoint created at stepIntoFromInlineFun.kt:13
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoFromInlineFun.StepIntoFromInlineFunPackage
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
stepIntoFromInlineFun.kt:13
|
||||
stepIntoFromInlineFun.kt:7
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
|
||||
@@ -2,8 +2,8 @@ LineBreakpoint created at stepIntoInlineFun.kt:8
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoInlineFun.StepIntoInlineFunPackage
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
stepIntoInlineFun.kt:8
|
||||
stepIntoInlineFun.kt:13
|
||||
stepIntoInlineFun.kt:8
|
||||
stepIntoInlineFun.kt:9
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
|
||||
@@ -2,7 +2,7 @@ LineBreakpoint created at stepIntoStdLibInlineFun.kt:6
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdLibInlineFun.StepIntoStdLibInlineFunPackage
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
stepIntoStdLibInlineFun.kt:6
|
||||
_Mapping.!EXT!
|
||||
ArrayList.!EXT!
|
||||
resuming stepIntoStdLibInlineFun.kt:5
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user