[JVM IR] Generate line number for exception store for finally.
^KT-46451 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
a1519b7b4e
commit
0b84de31b7
+4
@@ -1244,6 +1244,10 @@ class ExpressionCodegen(
|
|||||||
// Generate `try { ... } catch (e: Any?) { <finally>; throw e }` around every part of
|
// Generate `try { ... } catch (e: Any?) { <finally>; throw e }` around every part of
|
||||||
// the try-catch that is not a copy-pasted `finally` block.
|
// the try-catch that is not a copy-pasted `finally` block.
|
||||||
val defaultCatchStart = markNewLabel()
|
val defaultCatchStart = markNewLabel()
|
||||||
|
// Make sure the ASTORE generated below has the line number of the
|
||||||
|
// finally block and does not take over the line number of whatever
|
||||||
|
// was generated before.
|
||||||
|
tryInfo.onExit.markLineNumber(true)
|
||||||
// While keeping this value on the stack should be enough, the bytecode validator will
|
// While keeping this value on the stack should be enough, the bytecode validator will
|
||||||
// complain if a catch block does not start with ASTORE.
|
// complain if a catch block does not start with ASTORE.
|
||||||
val savedException = frameMap.enterTemp(AsmTypes.JAVA_THROWABLE_TYPE)
|
val savedException = frameMap.enterTemp(AsmTypes.JAVA_THROWABLE_TYPE)
|
||||||
|
|||||||
@@ -34,4 +34,5 @@ fun box(): String {
|
|||||||
// test.kt:11 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String
|
// test.kt:11 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String
|
||||||
// test.kt:12 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String, z:java.lang.String="z":java.lang.String
|
// test.kt:12 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String, z:java.lang.String="z":java.lang.String
|
||||||
// test.kt:14 box: i:int=0:int
|
// test.kt:14 box: i:int=0:int
|
||||||
|
// test.kt:17 box:
|
||||||
// test.kt:18 box:
|
// test.kt:18 box:
|
||||||
|
|||||||
@@ -34,4 +34,5 @@ fun box(): String {
|
|||||||
// test.kt:11 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String
|
// test.kt:11 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String
|
||||||
// test.kt:12 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String, z:java.lang.String="z":java.lang.String
|
// test.kt:12 box: i:int=0:int, e:java.lang.Exception=java.lang.RuntimeException, y:java.lang.String="y":java.lang.String, z:java.lang.String="z":java.lang.String
|
||||||
// test.kt:14 box: i:int=0:int
|
// test.kt:14 box: i:int=0:int
|
||||||
|
// test.kt:17 box:
|
||||||
// test.kt:18 box:
|
// test.kt:18 box:
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
try {
|
||||||
|
val x = "x"
|
||||||
|
throw RuntimeException(x)
|
||||||
|
} finally {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
return "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// The old backend steps on line 4, 5, 9, and 8. No step on the throw, and a step on the end
|
||||||
|
// brace of the finally before going into the actual finally code.
|
||||||
|
|
||||||
|
// LOCAL VARIABLES
|
||||||
|
// test.kt:4 box:
|
||||||
|
// test.kt:5 box:
|
||||||
|
// test.kt:6 box: x:java.lang.String="x":java.lang.String
|
||||||
|
// test.kt:7 box:
|
||||||
|
// test.kt:8 box:
|
||||||
+2
-1
@@ -69,8 +69,9 @@ fun box() {
|
|||||||
// test.kt:10 foo
|
// test.kt:10 foo
|
||||||
// test.kt:11 foo
|
// test.kt:11 foo
|
||||||
// test.kt:25 mightThrow2
|
// test.kt:25 mightThrow2
|
||||||
// test.kt:14 foo
|
|
||||||
// LINENUMBERS JVM
|
// LINENUMBERS JVM
|
||||||
|
// test.kt:14 foo
|
||||||
// test.kt:10 foo
|
// test.kt:10 foo
|
||||||
// LINENUMBERS JVM_IR
|
// LINENUMBERS JVM_IR
|
||||||
|
// test.kt:12 foo
|
||||||
// test.kt:13 foo
|
// test.kt:13 foo
|
||||||
Generated
+6
@@ -134,6 +134,12 @@ public class IrLocalVariableTestGenerated extends AbstractIrLocalVariableTest {
|
|||||||
runTest("compiler/testData/debug/localVariables/tryFinally16.kt");
|
runTest("compiler/testData/debug/localVariables/tryFinally16.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("tryFinally17.kt")
|
||||||
|
public void testTryFinally17() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/localVariables/tryFinally17.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("tryFinally2.kt")
|
@TestMetadata("tryFinally2.kt")
|
||||||
public void testTryFinally2() throws Exception {
|
public void testTryFinally2() throws Exception {
|
||||||
|
|||||||
Generated
+6
@@ -134,6 +134,12 @@ public class LocalVariableTestGenerated extends AbstractLocalVariableTest {
|
|||||||
runTest("compiler/testData/debug/localVariables/tryFinally16.kt");
|
runTest("compiler/testData/debug/localVariables/tryFinally16.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("tryFinally17.kt")
|
||||||
|
public void testTryFinally17() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/localVariables/tryFinally17.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("tryFinally2.kt")
|
@TestMetadata("tryFinally2.kt")
|
||||||
public void testTryFinally2() throws Exception {
|
public void testTryFinally2() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user