[JVM] Fix shrinking of local range for dead variables.

Coroutine transform would occasionally *extend* the range of a
local instead of shrinking it (if the next suspension point
is after the end point for the local). That leads to the local
variable table having a local that covers code where it is not
defined. That is invalid and leads to D8 removing the locals
table from the code.
This commit is contained in:
Mads Ager
2021-04-09 09:37:17 +02:00
committed by TeamCityServer
parent ebdbcbb7b6
commit b27a109a1e
9 changed files with 62 additions and 1 deletions
@@ -1329,7 +1329,7 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
variable.desc,
variable.signature,
variable.start,
nextSuspensionPointStartLabel(variable.start),
min(variable.end, nextSuspensionPointStartLabel(variable.start)),
variable.index
)
)
@@ -10849,6 +10849,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@Test
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@Test
@TestMetadata("usedInArrayStore.kt")
public void testUsedInArrayStore() throws Exception {
@@ -0,0 +1,23 @@
// WITH_RUNTIME
// WITH_COROUTINES
// FULL_RUNTIME
// KJS_WITH_FULL_RUNTIME
class JarFile {
fun entries() = listOf<String>()
}
private fun scriptTemplatesDiscoverySequence(): Sequence<String> {
return sequence<String> {
yield("OK")
for (dep in listOf<String>()) {
try {
} catch (e: Throwable) {
}
}
}
}
fun box(): String {
return scriptTemplatesDiscoverySequence().first()
}
@@ -10849,6 +10849,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@Test
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@Test
@TestMetadata("usedInArrayStore.kt")
public void testUsedInArrayStore() throws Exception {
@@ -10849,6 +10849,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@Test
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@Test
@TestMetadata("usedInArrayStore.kt")
public void testUsedInArrayStore() throws Exception {
@@ -8630,6 +8630,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@TestMetadata("usedInArrayStore.kt")
public void testUsedInArrayStore() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt");
@@ -7789,6 +7789,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@TestMetadata("usedInMethodCall.kt")
public void testUsedInMethodCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt");
@@ -7210,6 +7210,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@TestMetadata("usedInMethodCall.kt")
public void testUsedInMethodCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt");
@@ -7210,6 +7210,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt");
}
@TestMetadata("unusedCatchVar.kt")
public void testUnusedCatchVar() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt");
}
@TestMetadata("usedInMethodCall.kt")
public void testUsedInMethodCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt");