[JVM] Reduce number of param slots for string concatenation

With paramSlot = 200 those tests fails on JDKs which are newer than JDK 9
- testConcatDynamic200Long
- testConcatDynamicIndy200Long()
This commit is contained in:
Dmitriy Novozhilov
2021-07-30 18:55:08 +03:00
committed by teamcityserver
parent 5206b45ce3
commit 199ec60742
10 changed files with 119 additions and 4 deletions
@@ -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)
}
}
}
@@ -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 {
@@ -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"
}
@@ -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"
}
@@ -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
@@ -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
// 0 stringPlus
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {