diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StringConcatGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/StringConcatGenerator.kt index ec663f3f7e4..e584eef2eba 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StringConcatGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StringConcatGenerator.kt @@ -87,7 +87,7 @@ class StringConcatGenerator(val mode: JvmStringConcat, val mv: InstructionAdapte paramTypes.add(type) paramSlots += type.size template.append("\u0001") - if (paramSlots >= 200) { + if (paramSlots >= 199) { // Concatenate current arguments into string // because of `StringConcatFactory` limitation add use it as new argument for further processing: // "The number of parameter slots in {@code concatType} is less than or equal to 200" @@ -166,4 +166,4 @@ class StringConcatGenerator(val mode: JvmStringConcat, val mv: InstructionAdapte StringConcatGenerator(state.runtimeStringConcat, mv) } -} \ No newline at end of file +} diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index 138a5919a00..4a38c2e4e3e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -5104,6 +5104,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic.kt"); } + @Test + @TestMetadata("concatDynamic199.kt") + public void testConcatDynamic199() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic199.kt"); + } + @Test @TestMetadata("concatDynamic200.kt") public void testConcatDynamic200() throws Exception { diff --git a/compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic199Long.kt b/compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic199Long.kt new file mode 100644 index 00000000000..760b6db75a5 --- /dev/null +++ b/compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic199Long.kt @@ -0,0 +1,26 @@ +// STRING_CONCAT: indy-with-constants +fun test(z: Long): String { + val result = "" + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z //199 z + + return result +} + +fun box(): String { + val result = test(0L) + + if (result.length != 199) + return "fail 1: ${result.length}" + + return if (result != "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + "fail 2: ${result}" + else "OK" +} diff --git a/compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamicIndy199Long.kt b/compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamicIndy199Long.kt new file mode 100644 index 00000000000..7b4cfb985b6 --- /dev/null +++ b/compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamicIndy199Long.kt @@ -0,0 +1,26 @@ +// STRING_CONCAT: indy +fun test(z: Long): String { + val result = "" + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z //199 z + + return result +} + +fun box(): String { + val result = test(0L) + + if (result.length != 199) + return "fail 1: ${result.length}" + + return if (result != "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + "fail 2: ${result}" + else "OK" +} diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic199.kt b/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic199.kt new file mode 100644 index 00000000000..23900b36906 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic199.kt @@ -0,0 +1,21 @@ +// KOTLIN_CONFIGURATION_FLAGS: STRING_CONCAT=indy-with-constants +// JVM_TARGET: 9 + +fun box() { + val z = "0" + val result = z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + "some constant" + "some constant" + "some constant" + "some constant" + // constant in this mode are inlined in recipe + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z //199 +} + +// 1 INVOKEDYNAMIC makeConcatWithConstants +// 0 append +// 0 stringPlus diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic200.kt b/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic200.kt index 7a2a1106ccb..d70aa654614 100644 --- a/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic200.kt +++ b/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic200.kt @@ -16,6 +16,6 @@ fun box() { z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z //200 } -// 1 INVOKEDYNAMIC makeConcatWithConstants +// 2 INVOKEDYNAMIC makeConcatWithConstants // 0 append -// 0 stringPlus \ No newline at end of file +// 0 stringPlus diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxModernJdkCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxModernJdkCodegenTestGenerated.java index 3330b457d12..664597491a8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxModernJdkCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxModernJdkCodegenTestGenerated.java @@ -42,6 +42,12 @@ public class BlackBoxModernJdkCodegenTestGenerated extends AbstractBlackBoxCodeg runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic.kt"); } + @Test + @TestMetadata("concatDynamic199Long.kt") + public void testConcatDynamic199Long() throws Exception { + runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic199Long.kt"); + } + @Test @TestMetadata("concatDynamic200.kt") public void testConcatDynamic200() throws Exception { @@ -60,6 +66,12 @@ public class BlackBoxModernJdkCodegenTestGenerated extends AbstractBlackBoxCodeg runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic201.kt"); } + @Test + @TestMetadata("concatDynamicIndy199Long.kt") + public void testConcatDynamicIndy199Long() throws Exception { + runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamicIndy199Long.kt"); + } + @Test @TestMetadata("concatDynamicIndy200.kt") public void testConcatDynamicIndy200() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index 95b29831aa3..43b96c900b6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -4966,6 +4966,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic.kt"); } + @Test + @TestMetadata("concatDynamic199.kt") + public void testConcatDynamic199() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic199.kt"); + } + @Test @TestMetadata("concatDynamic200.kt") public void testConcatDynamic200() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxModernJdkCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxModernJdkCodegenTestGenerated.java index f6934d568ed..1455fde418a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxModernJdkCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxModernJdkCodegenTestGenerated.java @@ -42,6 +42,12 @@ public class IrBlackBoxModernJdkCodegenTestGenerated extends AbstractIrBlackBoxC runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic.kt"); } + @Test + @TestMetadata("concatDynamic199Long.kt") + public void testConcatDynamic199Long() throws Exception { + runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic199Long.kt"); + } + @Test @TestMetadata("concatDynamic200.kt") public void testConcatDynamic200() throws Exception { @@ -60,6 +66,12 @@ public class IrBlackBoxModernJdkCodegenTestGenerated extends AbstractIrBlackBoxC runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamic201.kt"); } + @Test + @TestMetadata("concatDynamicIndy199Long.kt") + public void testConcatDynamicIndy199Long() throws Exception { + runTest("compiler/testData/codegen/boxModernJdk/testsWithJava11/concatDynamicIndy199Long.kt"); + } + @Test @TestMetadata("concatDynamicIndy200.kt") public void testConcatDynamicIndy200() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index 8ff2c8fb5e0..d68d84a3bee 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -5104,6 +5104,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic.kt"); } + @Test + @TestMetadata("concatDynamic199.kt") + public void testConcatDynamic199() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamic199.kt"); + } + @Test @TestMetadata("concatDynamic200.kt") public void testConcatDynamic200() throws Exception {