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 org.jetbrains.kotlin.codegen.SourceInfo
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
@@ -67,11 +66,11 @@ class SourceMapCopier(val parent: SourceMapper, private val smap: SMAP, val call
|
||||
return mappedLineNumber
|
||||
}
|
||||
|
||||
val newLineNumber = if (lineNumber in JvmAbi.SYNTHETIC_MARKER_LINE_NUMBERS) {
|
||||
// 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
|
||||
// this range in the SMAP).
|
||||
parent.mapSyntheticLineNumber(lineNumber)
|
||||
val newLineNumber = if (lineNumber == 65100) {
|
||||
// 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
|
||||
// this range in the SMAP).
|
||||
parent.mapSyntheticLineNumber(InlineOnlySmapSkipper.LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER)
|
||||
} else {
|
||||
val range = lastVisitedRange?.takeIf { lineNumber in it } ?: smap.findRange(lineNumber) ?: return -1
|
||||
lastVisitedRange = range
|
||||
@@ -112,7 +111,6 @@ class SourceMapper(val sourceInfo: SourceInfo?) {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,6 +541,10 @@ internal fun isThis0(name: String): Boolean = AsmUtil.CAPTURED_THIS_FIELD == nam
|
||||
class InlineOnlySmapSkipper(codegen: BaseExpressionCodegen) {
|
||||
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) {
|
||||
val firstLine = info.node.node.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
|
||||
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.
|
||||
val label = 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user