Refactor CHECK_BYTECODE_LISTING directive for JVM IR tests

Create a separate _ir.txt bytecode listing file for JVM IR, to avoid
duplicate tests and to fix "Codegent tests on different JDKs"
configuration where this test is muted but passes because only execution
is checked there, not bytecode listing.
This commit is contained in:
Alexander Udalov
2019-11-08 17:35:24 +01:00
parent ce09be3f59
commit de54e549af
13 changed files with 27 additions and 180 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -24,4 +23,4 @@ fun box(): String {
}
if (res != "OK1000") return res
return "OK"
}
}
@@ -1,27 +0,0 @@
// WITH_RUNTIME
// WITH_COROUTINES
// CHECK_BYTECODE_LISTING
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
import helpers.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun call(c: suspend Long.() -> String): String {
return 1000L.c()
}
fun box(): String {
var res = ""
builder {
res = call { ->
"OK$this"
}
}
if (res != "OK1000") return res
return "OK"
}
@@ -1,5 +1,5 @@
@kotlin.Metadata
final class LambdaWithLongReceiver_irKt$$call$Continuation {
final class LambdaWithLongReceiverKt$$call$Continuation {
field label: int
@org.jetbrains.annotations.NotNull field result: java.lang.Object
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
@@ -8,10 +8,10 @@ final class LambdaWithLongReceiver_irKt$$call$Continuation {
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class LambdaWithLongReceiver_irKt$box$1$1 {
final class LambdaWithLongReceiverKt$box$1$1 {
private field $p: long
private field label: int
inner class LambdaWithLongReceiver_irKt$box$1$1
inner class LambdaWithLongReceiverKt$box$1$1
public method <init>(): void
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
@@ -21,11 +21,11 @@ final class LambdaWithLongReceiver_irKt$box$1$1 {
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class LambdaWithLongReceiver_irKt$box$1 {
final class LambdaWithLongReceiverKt$box$1 {
private field $res: kotlin.jvm.internal.Ref$ObjectRef
field L$0: java.lang.Object
private field label: int
inner class LambdaWithLongReceiver_irKt$box$1
inner class LambdaWithLongReceiverKt$box$1
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef): void
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
@@ -34,9 +34,9 @@ final class LambdaWithLongReceiver_irKt$box$1 {
}
@kotlin.Metadata
public final class LambdaWithLongReceiver_irKt {
inner class LambdaWithLongReceiver_irKt$box$1
inner class LambdaWithLongReceiver_irKt$box$1$1
public final class LambdaWithLongReceiverKt {
inner class LambdaWithLongReceiverKt$box$1
inner class LambdaWithLongReceiverKt$box$1$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void
public final static @org.jetbrains.annotations.Nullable method call(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function2, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -24,4 +23,4 @@ fun box(): String {
}
if (res != "OK12345") return res
return "OK"
}
}
@@ -1,28 +0,0 @@
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
// CHECK_BYTECODE_LISTING
// IGNORE_BACKEND: JVM
// TARGET_BACKEND: JVM
import helpers.*
import COROUTINES_PACKAGE.*
fun builder(c: suspend() -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun call(c: suspend(String, Long, Long, Long, Long, Long) -> String): String {
return c("OK", 1, 2, 3, 4, 5)
}
fun box(): String {
var res = ""
builder {
res = call { a, b, c, d, e, f ->
"$a$b$c$d$e$f"
}
}
if (res != "OK12345") return res
return "OK"
}
@@ -1,5 +1,5 @@
@kotlin.Metadata
final class LambdaWithMultipleParameters_irKt$$call$Continuation {
final class LambdaWithMultipleParametersKt$$call$Continuation {
field label: int
@org.jetbrains.annotations.NotNull field result: java.lang.Object
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
@@ -8,7 +8,7 @@ final class LambdaWithMultipleParameters_irKt$$call$Continuation {
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class LambdaWithMultipleParameters_irKt$box$1$1 {
final class LambdaWithMultipleParametersKt$box$1$1 {
private field a: java.lang.String
private field b: long
private field c: long
@@ -16,7 +16,7 @@ final class LambdaWithMultipleParameters_irKt$box$1$1 {
private field e: long
private field f: long
private field label: int
inner class LambdaWithMultipleParameters_irKt$box$1$1
inner class LambdaWithMultipleParametersKt$box$1$1
public method <init>(): void
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
public final method invoke(p0: java.lang.Object, p1: java.lang.Object, p2: java.lang.Object, p3: java.lang.Object, p4: java.lang.Object, p5: java.lang.Object, p6: java.lang.Object): java.lang.Object
@@ -25,11 +25,11 @@ final class LambdaWithMultipleParameters_irKt$box$1$1 {
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class LambdaWithMultipleParameters_irKt$box$1 {
final class LambdaWithMultipleParametersKt$box$1 {
private field $res: kotlin.jvm.internal.Ref$ObjectRef
field L$0: java.lang.Object
private field label: int
inner class LambdaWithMultipleParameters_irKt$box$1
inner class LambdaWithMultipleParametersKt$box$1
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef): void
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
@@ -38,9 +38,9 @@ final class LambdaWithMultipleParameters_irKt$box$1 {
}
@kotlin.Metadata
public final class LambdaWithMultipleParameters_irKt {
inner class LambdaWithMultipleParameters_irKt$box$1
inner class LambdaWithMultipleParameters_irKt$box$1$1
public final class LambdaWithMultipleParametersKt {
inner class LambdaWithMultipleParametersKt$box$1
inner class LambdaWithMultipleParametersKt$box$1$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void
public final static @org.jetbrains.annotations.Nullable method call(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function7, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -14,6 +13,7 @@ inline suspend fun suspendThere(v: String): String = suspendCoroutineUnintercept
COROUTINE_SUSPENDED
}
// TODO: Somehow we still generate continuations for tail-call function, but we don't use them.
suspend fun suspendHere(): String = suspendThere("O")
// There is a kind of redundant state machine generated for complexSuspend:
@@ -1,42 +0,0 @@
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JVM
// TARGET_BACKEND: JVM
import helpers.*
// CHECK_BYTECODE_LISTING
// CHECK_NEW_COUNT: function=suspendHere count=0
// CHECK_NEW_COUNT: function=complexSuspend count=0
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
inline suspend fun suspendThere(v: String): String = suspendCoroutineUninterceptedOrReturn { x ->
x.resume(v)
COROUTINE_SUSPENDED
}
// TODO: Somehow we still generate continuations for tail-call function, but we don't use them.
suspend fun suspendHere(): String = suspendThere("O")
// There is a kind of redundant state machine generated for complexSuspend:
// it's basically has the only suspend call just before return, but there is
// a redundant CHECKCAST String in the run's lambda, so we have to insert the state machine.
// TODO: Think of avoiding such redundant casts
suspend fun complexSuspend(): String {
return run {
suspendThere("K")
}
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = ""
builder {
result = suspendHere() + complexSuspend()
}
return result
}
@@ -1,6 +1,6 @@
@kotlin.Metadata
@kotlin.coroutines.jvm.internal.DebugMetadata
final class InlineWithoutStateMachine_irKt$$complexSuspend$Continuation {
final class InlineWithoutStateMachineKt$$complexSuspend$Continuation {
field L$0: java.lang.Object
field L$1: java.lang.Object
field label: int
@@ -11,7 +11,7 @@ final class InlineWithoutStateMachine_irKt$$complexSuspend$Continuation {
@kotlin.Metadata
@kotlin.coroutines.jvm.internal.DebugMetadata
final class InlineWithoutStateMachine_irKt$$suspendHere$Continuation {
final class InlineWithoutStateMachineKt$$suspendHere$Continuation {
field L$0: java.lang.Object
field label: int
@org.jetbrains.annotations.NotNull field result: java.lang.Object
@@ -21,12 +21,12 @@ final class InlineWithoutStateMachine_irKt$$suspendHere$Continuation {
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class InlineWithoutStateMachine_irKt$box$1 {
final class InlineWithoutStateMachineKt$box$1 {
private field $result: kotlin.jvm.internal.Ref$ObjectRef
field L$0: java.lang.Object
field L$1: java.lang.Object
private field label: int
inner class InlineWithoutStateMachine_irKt$box$1
inner class InlineWithoutStateMachineKt$box$1
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef): void
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
@@ -35,8 +35,8 @@ final class InlineWithoutStateMachine_irKt$box$1 {
}
@kotlin.Metadata
public final class InlineWithoutStateMachine_irKt {
inner class InlineWithoutStateMachine_irKt$box$1
public final class InlineWithoutStateMachineKt {
inner class InlineWithoutStateMachineKt$box$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void
public final static @org.jetbrains.annotations.Nullable method complexSuspend(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object
@@ -69,7 +69,8 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
String suffix =
(coroutinesPackage.contains("experimental") || coroutinesPackage.isEmpty())
&& InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(wholeFile), "COMMON_COROUTINES_TEST")
? "_1_2" : "";
? "_1_2" :
getBackend().isIR() ? "_ir" : "";
File expectedFile = new File(wholeFile.getParent(), FilesKt.getNameWithoutExtension(wholeFile) + suffix + ".txt");
String text =
@@ -6675,11 +6675,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithLongReceiver_ir.kt")
public void testLambdaWithLongReceiver_ir() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver_ir.kt");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines.experimental");
@@ -6689,16 +6684,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testLambdaWithMultipleParameters_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithMultipleParameters_ir.kt")
public void testLambdaWithMultipleParameters_ir_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters_ir.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithMultipleParameters_ir.kt")
public void testLambdaWithMultipleParameters_ir_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters_ir.kt", "kotlin.coroutines");
}
}
@TestMetadata("compiler/testData/codegen/box/coroutines/controlFlow")
@@ -8384,11 +8369,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt", "kotlin.coroutines");
}
@TestMetadata("inlineWithoutStateMachine_ir.kt")
public void testInlineWithoutStateMachine_ir() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine_ir.kt");
}
@TestMetadata("innerObjectRetransformation.kt")
public void testInnerObjectRetransformation_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tailCallOptimizations/innerObjectRetransformation.kt", "kotlin.coroutines.experimental");
@@ -6653,21 +6653,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Bridges extends AbstractLightAnalysisModeTest {
@TestMetadata("lambdaWithLongReceiver_ir.kt")
public void ignoreLambdaWithLongReceiver_ir() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver_ir.kt");
}
@TestMetadata("lambdaWithMultipleParameters_ir.kt")
public void ignoreLambdaWithMultipleParameters_ir_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters_ir.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithMultipleParameters_ir.kt")
public void ignoreLambdaWithMultipleParameters_ir_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters_ir.kt", "kotlin.coroutines");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@@ -8342,11 +8327,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TailCallOptimizations extends AbstractLightAnalysisModeTest {
@TestMetadata("inlineWithoutStateMachine_ir.kt")
public void ignoreInlineWithoutStateMachine_ir() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine_ir.kt");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@@ -6225,20 +6225,10 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithLongReceiver_ir.kt")
public void testLambdaWithLongReceiver_ir() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver_ir.kt");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithMultipleParameters_ir.kt")
public void testLambdaWithMultipleParameters_ir_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters_ir.kt", "kotlin.coroutines");
}
}
@TestMetadata("compiler/testData/codegen/box/coroutines/controlFlow")
@@ -7329,11 +7319,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt", "kotlin.coroutines");
}
@TestMetadata("inlineWithoutStateMachine_ir.kt")
public void testInlineWithoutStateMachine_ir() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine_ir.kt");
}
@TestMetadata("innerObjectRetransformation.kt")
public void testInnerObjectRetransformation_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tailCallOptimizations/innerObjectRetransformation.kt", "kotlin.coroutines");