From 94d20d9176f1ec6aab13713797824964c8e60592 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 17 Feb 2020 17:48:50 +0300 Subject: [PATCH] Update bytecode text tests in JVM_IR --- .../conditions/noBoxingForBoxedEqPrimitive.kt | 2 ++ .../conditions/noBoxingForPrimitiveEqBoxed.kt | 2 ++ .../conditions/noBoxingForPrimitiveEqObject.kt | 2 ++ .../bytecodeText/controlStructures/kt17110.kt | 8 +++++++- .../defaultArguments/maskAndArgumentElimination.kt | 2 ++ .../defaultArguments/methodHandlerElimination.kt | 2 ++ .../codegen/bytecodeText/directInvoke/localFun.kt | 7 +++++-- .../testData/codegen/bytecodeText/enum/kt18731.kt | 2 ++ .../forLoop/forInOptimizableUnsignedRange.kt | 1 + .../forInEmptySequenceWithIndex.kt | 1 + .../forInSequenceTypeParameterWithIndex.kt | 1 + .../forInSequenceWithIndex.kt | 1 + .../forInSequenceWithIndexNoElementVar.kt | 1 + .../forInSequenceWithIndexNoIndexVar.kt | 1 + .../forInSequenceWithIndexThrowsCME.kt | 1 + ...nceWithIndexWithExplicitlyTypedIndexVariable.kt | 1 + .../bytecodeText/inline/specialEnumFunction.kt | 14 ++++++++++++-- .../boxUnboxOfInlineClassesWithFunctionalTypes.kt | 1 + .../callMemberMethodsInsideInlineClass.kt | 7 ++++++- .../uIntArrayIteratorWithoutBoxing.kt | 1 + 20 files changed, 52 insertions(+), 6 deletions(-) diff --git a/compiler/testData/codegen/bytecodeText/conditions/noBoxingForBoxedEqPrimitive.kt b/compiler/testData/codegen/bytecodeText/conditions/noBoxingForBoxedEqPrimitive.kt index ce45d19cd8a..8fe6c521665 100644 --- a/compiler/testData/codegen/bytecodeText/conditions/noBoxingForBoxedEqPrimitive.kt +++ b/compiler/testData/codegen/bytecodeText/conditions/noBoxingForBoxedEqPrimitive.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36646 Don't box primitive values in equality comparison with nullable primitive values in JVM_IR + fun testBoolean1(a: Boolean?, b: Boolean) = a == b fun testBoolean2(a: Boolean?, b: Boolean) = a != b diff --git a/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt b/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt index e22d7d13845..adbfe82cb82 100644 --- a/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt +++ b/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36646 Don't box primitive values in equality comparison with nullable primitive values in JVM_IR + fun testBoolean1(a: Boolean, b: Boolean?) = a == b fun testBoolean2(a: Boolean, b: Boolean?) = a != b diff --git a/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt b/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt index b1841a7a51a..2321696701e 100644 --- a/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt +++ b/compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36646 Don't box primitive values in equality comparison with nullable primitive values in JVM_IR + fun testBoolean1(a: Boolean, b: Any?) = a == b fun testBoolean2(a: Boolean, b: Any?) = a != b diff --git a/compiler/testData/codegen/bytecodeText/controlStructures/kt17110.kt b/compiler/testData/codegen/bytecodeText/controlStructures/kt17110.kt index 090cf495d42..a174b7eb763 100644 --- a/compiler/testData/codegen/bytecodeText/controlStructures/kt17110.kt +++ b/compiler/testData/codegen/bytecodeText/controlStructures/kt17110.kt @@ -17,5 +17,11 @@ fun infiniteLoop() { while(true) {} } +// JVM_TEMPLATES // 2 GOTO L7 -// 1 GOTO L1 \ No newline at end of file +// 1 GOTO L1 + +// JVM_IR_TEMPLATES +// 1 GOTO L6 +// 1 GOTO L7 +// 1 GOtO L0 \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/defaultArguments/maskAndArgumentElimination.kt b/compiler/testData/codegen/bytecodeText/defaultArguments/maskAndArgumentElimination.kt index 16e565df207..0a2c9a50fc0 100644 --- a/compiler/testData/codegen/bytecodeText/defaultArguments/maskAndArgumentElimination.kt +++ b/compiler/testData/codegen/bytecodeText/defaultArguments/maskAndArgumentElimination.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36769 Missing LVT entries for inline function (default) parameters at call site + inline fun test(p: String = "OK"): String { return p } diff --git a/compiler/testData/codegen/bytecodeText/defaultArguments/methodHandlerElimination.kt b/compiler/testData/codegen/bytecodeText/defaultArguments/methodHandlerElimination.kt index bcf66164715..f3a88105711 100644 --- a/compiler/testData/codegen/bytecodeText/defaultArguments/methodHandlerElimination.kt +++ b/compiler/testData/codegen/bytecodeText/defaultArguments/methodHandlerElimination.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36771 Missing special code for super calls to inline functions support in JVM_IR + //open modality to method handle check generation open class A { inline fun test(p: String = "OK"): String { diff --git a/compiler/testData/codegen/bytecodeText/directInvoke/localFun.kt b/compiler/testData/codegen/bytecodeText/directInvoke/localFun.kt index 1d4be98a6bd..cd9409caa3b 100644 --- a/compiler/testData/codegen/bytecodeText/directInvoke/localFun.kt +++ b/compiler/testData/codegen/bytecodeText/directInvoke/localFun.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun test() { fun local(s: Int) { } @@ -6,4 +5,8 @@ fun test() { local(1) } -// 2 invoke \(I\)V \ No newline at end of file +// JVM_TEMPLATES +// 2 invoke \(I\)V + +// JVM_IR_TEMPLATES +// 1 INVOKESTATIC LocalFunKt\.test\$local \(I\)V \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/enum/kt18731.kt b/compiler/testData/codegen/bytecodeText/enum/kt18731.kt index a1638827061..5175ee2b5c0 100644 --- a/compiler/testData/codegen/bytecodeText/enum/kt18731.kt +++ b/compiler/testData/codegen/bytecodeText/enum/kt18731.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36772 Equality compaison between enums should use reference equality in JVM_IR + enum class Bar { ONE, TWO diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInOptimizableUnsignedRange.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInOptimizableUnsignedRange.kt index 456210dab06..2a11658762f 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInOptimizableUnsignedRange.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInOptimizableUnsignedRange.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36773 Use counter loop when generating 'for' loop over an unsigned range in JVM_IR fun testUIntRangeLiteral(a: UInt, b: UInt): Int { var s = 0 diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInEmptySequenceWithIndex.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInEmptySequenceWithIndex.kt index 1d695b13574..35007311a48 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInEmptySequenceWithIndex.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInEmptySequenceWithIndex.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. val xs = listOf().asSequence() diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceTypeParameterWithIndex.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceTypeParameterWithIndex.kt index 45e5d15ae29..96fb7dd045a 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceTypeParameterWithIndex.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceTypeParameterWithIndex.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. fun > test(sequence: T): String { val s = StringBuilder() diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndex.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndex.kt index 52e143652ee..f0ff18d9280 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndex.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndex.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. val xs = listOf("a", "b", "c", "d").asSequence() diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoElementVar.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoElementVar.kt index 24efdbdba13..67c9174247d 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoElementVar.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoElementVar.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. val xs = listOf("a", "b", "c", "d").asSequence() diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVar.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVar.kt index 0ae5164815e..91b7475f7f5 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVar.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexNoIndexVar.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. val xs = listOf("a", "b", "c", "d").asSequence() diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexThrowsCME.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexThrowsCME.kt index 2ee840bde14..af56bcb34e5 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexThrowsCME.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexThrowsCME.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. // FULL_JDK diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexWithExplicitlyTypedIndexVariable.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexWithExplicitlyTypedIndexVariable.kt index a22e78d60f6..bc6e4649175 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexWithExplicitlyTypedIndexVariable.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexWithExplicitlyTypedIndexVariable.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// TODO KT-36774 Generate optimized loops over 'xs.withIndex()' in JVM_IR // TODO: Handle Sequences by extending DefaultIterableHandler. val xs = listOf("a", "b", "c", "d").asSequence() diff --git a/compiler/testData/codegen/bytecodeText/inline/specialEnumFunction.kt b/compiler/testData/codegen/bytecodeText/inline/specialEnumFunction.kt index c8987908293..62c928e4f47 100644 --- a/compiler/testData/codegen/bytecodeText/inline/specialEnumFunction.kt +++ b/compiler/testData/codegen/bytecodeText/inline/specialEnumFunction.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR inline fun > myValues(): String { val values = enumValues() return "OK" @@ -14,12 +13,23 @@ fun main() { value() } +// JVM_TEMPLATES //2 reifiedOperationMarker //1 INVOKESTATIC kotlin/jvm/internal/Intrinsics\.reifiedOperationMarker \(ILjava/lang/String;\)V\s*ICONST_0\s*ANEWARRAY java/lang/Enum //1 INVOKESTATIC Z\.values \(\)\[LZ; - //4 valueOf //1 INVOKESTATIC kotlin/jvm/internal/Intrinsics\.reifiedOperationMarker \(ILjava/lang/String;\)V\s*ACONST_NULL\s*ALOAD 2\s*INVOKESTATIC java/lang/Enum\.valueOf \(Ljava/lang/Class;Ljava/lang/String;\)Ljava/lang/Enum; //1 INVOKESTATIC Z\.valueOf \(Ljava/lang/String;\)LZ; //1 public static valueOf //2 INVOKESTATIC java/lang/Enum.valueOf \(Ljava/lang/Class;Ljava/lang/String;\)Ljava/lang/Enum; + +// JVM_IR_TEMPLATES +//2 reifiedOperationMarker +//1 INVOKESTATIC kotlin/jvm/internal/Intrinsics\.reifiedOperationMarker \(ILjava/lang/String;\)V\s*ICONST_0\s*ANEWARRAY java/lang/Enum +//1 INVOKESTATIC Z\.values \(\)\[LZ; +//4 valueOf +//1 INVOKESTATIC kotlin/jvm/internal/Intrinsics\.reifiedOperationMarker \(ILjava/lang/String;\)V\s*ACONST_NULL\s*ALOAD 2\s*INVOKESTATIC java/lang/Enum\.valueOf \(Ljava/lang/Class;Ljava/lang/String;\)Ljava/lang/Enum; +//1 INVOKESTATIC Z\.valueOf \(Ljava/lang/String;\)LZ; +//1 public final static valueOf +// ^ valueOf is generated as 'public final static' in JVM_IR +//2 INVOKESTATIC java/lang/Enum.valueOf \(Ljava/lang/Class;Ljava/lang/String;\)Ljava/lang/Enum; \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/boxUnboxOfInlineClassesWithFunctionalTypes.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/boxUnboxOfInlineClassesWithFunctionalTypes.kt index e4a562fc295..8e15c4de0fe 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/boxUnboxOfInlineClassesWithFunctionalTypes.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/boxUnboxOfInlineClassesWithFunctionalTypes.kt @@ -1,5 +1,6 @@ // !LANGUAGE: +InlineClasses // IGNORE_BACKEND: JVM_IR +// TODO KT-36783 Consider generating GETFIELD instructions instead of unbox-impl calls in special methods of inline classes in JVM_IR inline class UInt(val value: Int) inline class ULong(val value: Long) diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt index f0c4b80fb8c..a9d8d714d56 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt @@ -1,5 +1,6 @@ // !LANGUAGE: +InlineClasses // IGNORE_BACKEND: JVM_IR +// TODO KT-36783 Consider generating GETFIELD instructions instead of unbox-impl calls in special methods of inline classes in JVM_IR inline class Foo(val x: Int) { fun empty() {} @@ -16,4 +17,8 @@ inline class Foo(val x: Int) { // 1 INVOKESTATIC Foo\.empty-impl \(I\)V // 1 INVOKESTATIC Foo\.withParam-impl \(ILjava/lang/String;\)V // 1 INVOKESTATIC Foo\.withInlineClassParam-GWb7d6U \(II\)V -// 5 INVOKEVIRTUAL \ No newline at end of file +// 5 INVOKEVIRTUAL +// 2 INVOKEVIRTUAL java/lang/StringBuilder\.append \(Ljava/lang/String;\)Ljava/lang/StringBuilder; +// 1 INVOKEVIRTUAL java/lang/StringBuilder\.append \(I\)Ljava/lang/StringBuilder; +// 1 INVOKEVIRTUAL java/lang/StringBuilder.toString \(\)Ljava/lang/String; +// 1 INVOKEVIRTUAL Foo.unbox-impl \(\)I \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt index 37702009374..eaeb74ffaf7 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt @@ -1,5 +1,6 @@ // !LANGUAGE: +InlineClasses // IGNORE_BACKEND: JVM_IR +// TODO KT-36783 Consider generating GETFIELD instructions instead of unbox-impl calls in special methods of inline classes in JVM_IR inline class UInt(private val value: Int)