JVM replace redundant GOTOs with NOPs to preserve debugging behavior
This commit is contained in:
committed by
teamcityserver
parent
0a67ab54fe
commit
ca7ee75f88
+2
-5
@@ -19,11 +19,7 @@ package org.jetbrains.kotlin.codegen.optimization
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful
|
||||
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.JumpInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.LabelNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.LineNumberNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
|
||||
class RedundantGotoMethodTransformer : MethodTransformer() {
|
||||
/**
|
||||
@@ -80,6 +76,7 @@ class RedundantGotoMethodTransformer : MethodTransformer() {
|
||||
}
|
||||
|
||||
for (insnToRemove in insnsToRemove) {
|
||||
methodNode.instructions.insertBefore(insnToRemove, InsnNode(Opcodes.NOP))
|
||||
methodNode.instructions.remove(insnToRemove)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,4 +30,4 @@ suspend fun ApplicationCall.test(authenticationService: AuthenticationService) {
|
||||
// 0 ILOAD 3
|
||||
// 0 ILOAD 2
|
||||
// 1 \$i\$f\$receiveJSON I .* 2
|
||||
// 2 \$i\$f\$respond I .* 3
|
||||
// 3 \$i\$f\$respond I .* 3
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ inline fun lookAtMe(f: (String) -> Unit) {
|
||||
f(a) // Should be no unneeded nops on this line, that might be generated for zero-parameters lambda
|
||||
}
|
||||
|
||||
// 0 NOP
|
||||
// 2 NOP
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// FILE: test.kt
|
||||
|
||||
fun box() {
|
||||
lookAtMe {
|
||||
val c = "c"
|
||||
}
|
||||
}
|
||||
|
||||
inline fun lookAtMe(f: (String) -> Unit) {
|
||||
val a = "a"
|
||||
f(a)
|
||||
}
|
||||
|
||||
// LINENUMBERS
|
||||
// test.kt:4 box
|
||||
// test.kt:10 box
|
||||
// test.kt:11 box
|
||||
// test.kt:5 box
|
||||
// test.kt:6 box
|
||||
// test.kt:12 box
|
||||
// test.kt:7 box
|
||||
Generated
+6
@@ -290,6 +290,12 @@ public class IrSteppingTestGenerated extends AbstractIrSteppingTest {
|
||||
runTest("compiler/testData/debug/stepping/lineNumberAfterInline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("linenumberForOneParametersArgumentCall.kt")
|
||||
public void testLinenumberForOneParametersArgumentCall() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/linenumberForOneParametersArgumentCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
|
||||
Generated
+6
@@ -290,6 +290,12 @@ public class SteppingTestGenerated extends AbstractSteppingTest {
|
||||
runTest("compiler/testData/debug/stepping/lineNumberAfterInline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("linenumberForOneParametersArgumentCall.kt")
|
||||
public void testLinenumberForOneParametersArgumentCall() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/linenumberForOneParametersArgumentCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user