JVM: use 1 as a synthetic line number for @InlineOnly lambdas
The source path already marks it as synthetic.
This commit is contained in:
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.codegen.inline
|
|||||||
|
|
||||||
import gnu.trove.TIntIntHashMap
|
import gnu.trove.TIntIntHashMap
|
||||||
import org.jetbrains.kotlin.codegen.SourceInfo
|
import org.jetbrains.kotlin.codegen.SourceInfo
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
|
||||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@@ -67,11 +66,11 @@ class SourceMapCopier(val parent: SourceMapper, private val smap: SMAP, val call
|
|||||||
return mappedLineNumber
|
return mappedLineNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
val newLineNumber = if (lineNumber in JvmAbi.SYNTHETIC_MARKER_LINE_NUMBERS) {
|
val newLineNumber = if (lineNumber == 65100) {
|
||||||
// This is a compatibility hack for reading bytecode generated by 1.4-M1. Once the bootstrap
|
// TODO This is a compatibility hack for reading bytecode generated by 1.4-M1. Once the bootstrap
|
||||||
// compiler is updated to a newer version, it can be removed (as newer bytecode explicitly lists
|
// compiler is updated to a newer version, it can be removed (as newer bytecode explicitly lists
|
||||||
// this range in the SMAP).
|
// this range in the SMAP).
|
||||||
parent.mapSyntheticLineNumber(lineNumber)
|
parent.mapSyntheticLineNumber(InlineOnlySmapSkipper.LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER)
|
||||||
} else {
|
} else {
|
||||||
val range = lastVisitedRange?.takeIf { lineNumber in it } ?: smap.findRange(lineNumber) ?: return -1
|
val range = lastVisitedRange?.takeIf { lineNumber in it } ?: smap.findRange(lineNumber) ?: return -1
|
||||||
lastVisitedRange = range
|
lastVisitedRange = range
|
||||||
@@ -112,7 +111,6 @@ class SourceMapper(val sourceInfo: SourceInfo?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun mapSyntheticLineNumber(id: Int): Int {
|
fun mapSyntheticLineNumber(id: Int): Int {
|
||||||
assert(id in JvmAbi.SYNTHETIC_MARKER_LINE_NUMBERS) { "$id is not a synthetic line number" }
|
|
||||||
return mapLineNumber(SourcePosition(id, "fake.kt", "kotlin/jvm/internal/FakeKt"), null)
|
return mapLineNumber(SourcePosition(id, "fake.kt", "kotlin/jvm/internal/FakeKt"), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,6 +541,10 @@ internal fun isThis0(name: String): Boolean = AsmUtil.CAPTURED_THIS_FIELD == nam
|
|||||||
class InlineOnlySmapSkipper(codegen: BaseExpressionCodegen) {
|
class InlineOnlySmapSkipper(codegen: BaseExpressionCodegen) {
|
||||||
private val callLineNumber = codegen.lastLineNumber
|
private val callLineNumber = codegen.lastLineNumber
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER = 1
|
||||||
|
}
|
||||||
|
|
||||||
fun onInlineLambdaStart(mv: MethodVisitor, info: LambdaInfo, smap: SourceMapper) {
|
fun onInlineLambdaStart(mv: MethodVisitor, info: LambdaInfo, smap: SourceMapper) {
|
||||||
val firstLine = info.node.node.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
|
val firstLine = info.node.node.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
|
||||||
if (callLineNumber >= 0 && firstLine == callLineNumber) {
|
if (callLineNumber >= 0 && firstLine == callLineNumber) {
|
||||||
@@ -552,7 +556,7 @@ class InlineOnlySmapSkipper(codegen: BaseExpressionCodegen) {
|
|||||||
// number that is remapped by the SMAP to a line that does not exist.
|
// number that is remapped by the SMAP to a line that does not exist.
|
||||||
val label = Label()
|
val label = Label()
|
||||||
mv.visitLabel(label)
|
mv.visitLabel(label)
|
||||||
mv.visitLineNumber(smap.mapSyntheticLineNumber(JvmAbi.LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER), label)
|
mv.visitLineNumber(smap.mapSyntheticLineNumber(LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER), label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,5 +26,5 @@ _2Kt
|
|||||||
kotlin/jvm/internal/FakeKt
|
kotlin/jvm/internal/FakeKt
|
||||||
*L
|
*L
|
||||||
1#1,9:1
|
1#1,9:1
|
||||||
65100#2:10
|
1#2:10
|
||||||
*E
|
*E
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ fun box(): String {
|
|||||||
|
|
||||||
// LINENUMBERS
|
// LINENUMBERS
|
||||||
// test.kt:4
|
// test.kt:4
|
||||||
// fake.kt:65100
|
// fake.kt:1
|
||||||
// test.kt:4
|
// test.kt:4
|
||||||
// test.kt:5
|
// test.kt:5
|
||||||
// test.kt:6
|
// test.kt:6
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.load.java;
|
package org.jetbrains.kotlin.load.java;
|
||||||
|
|
||||||
import kotlin.collections.CollectionsKt;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.builtins.CompanionObjectMapping;
|
import org.jetbrains.kotlin.builtins.CompanionObjectMapping;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
@@ -14,8 +13,6 @@ import org.jetbrains.kotlin.name.FqName;
|
|||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.CapitalizeDecapitalizeKt;
|
import org.jetbrains.kotlin.util.capitalizeDecapitalize.CapitalizeDecapitalizeKt;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isClassOrEnumClass;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isClassOrEnumClass;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
||||||
|
|
||||||
@@ -48,20 +45,6 @@ public final class JvmAbi {
|
|||||||
|
|
||||||
public static final ClassId REFLECTION_FACTORY_IMPL = ClassId.topLevel(new FqName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl"));
|
public static final ClassId REFLECTION_FACTORY_IMPL = ClassId.topLevel(new FqName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl"));
|
||||||
|
|
||||||
/*
|
|
||||||
Line number is used when inlining function arguments to @InlineOnly functions.
|
|
||||||
All line information is stripped from the inlined implementation of such functions,
|
|
||||||
so if a lambda is on the same line with the call, the debugger can't stop on both 'line' and 'lambda' breakpoints.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
> require(foo) { "foo is false" }
|
|
||||||
*/
|
|
||||||
public static final int LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER = 65100;
|
|
||||||
|
|
||||||
public static final List<Integer> SYNTHETIC_MARKER_LINE_NUMBERS = CollectionsKt.listOf(
|
|
||||||
LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final String LOCAL_VARIABLE_NAME_PREFIX_INLINE_ARGUMENT = "$i$a$";
|
public static final String LOCAL_VARIABLE_NAME_PREFIX_INLINE_ARGUMENT = "$i$a$";
|
||||||
public static final String LOCAL_VARIABLE_NAME_PREFIX_INLINE_FUNCTION = "$i$f$";
|
public static final String LOCAL_VARIABLE_NAME_PREFIX_INLINE_FUNCTION = "$i$f$";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user