JVM_IR don't use Intrinsics.stringPlus for 2-argument concatenation
This commit is contained in:
committed by
TeamCityServer
parent
8a459821d0
commit
7e86f5dcd9
+18
@@ -41561,6 +41561,24 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
-7
@@ -147,13 +147,6 @@ private class JvmStringConcatenationLowering(val context: JvmBackendContext) : F
|
||||
arguments.size == 1 ->
|
||||
lowerInlineClassArgument(arguments[0]) ?: callToString(arguments[0].unwrapImplicitNotNull())
|
||||
|
||||
arguments.size == 2 && arguments[0].type.isStringClassType() ->
|
||||
irCall(backendContext.ir.symbols.intrinsicStringPlus).apply {
|
||||
putValueArgument(0, lowerInlineClassArgument(arguments[0]) ?: arguments[0].unwrapImplicitNotNull())
|
||||
// Unwrapping IMPLICIT_NOTNULL is not strictly necessary on 2nd argument (parameter type is `Any?`)
|
||||
putValueArgument(1, lowerInlineClassArgument(arguments[1]) ?: arguments[1])
|
||||
}
|
||||
|
||||
arguments.size < MAX_STRING_CONCAT_DEPTH -> {
|
||||
irCall(toStringFunction).apply {
|
||||
dispatchReceiver = appendWindow(arguments, irCall(constructor))
|
||||
|
||||
@@ -177,9 +177,6 @@ class JvmSymbols(
|
||||
override val throwKotlinNothingValueException: IrSimpleFunctionSymbol =
|
||||
intrinsicsClass.functions.single { it.owner.name.asString() == "throwKotlinNothingValueException" }
|
||||
|
||||
val intrinsicStringPlus: IrFunctionSymbol =
|
||||
intrinsicsClass.functions.single { it.owner.name.asString() == "stringPlus" }
|
||||
|
||||
val intrinsicsKotlinClass: IrClassSymbol =
|
||||
(intrinsicsClass.owner.declarations.single { it is IrClass && it.name.asString() == "Kotlin" } as IrClass).symbol
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
fun stringPlus(x: String?, y: Any?) = x + y
|
||||
|
||||
fun box(): String {
|
||||
val t1 = stringPlus("a", "b")
|
||||
if (t1 != "ab") return "Failed: t1=$t1"
|
||||
|
||||
val t2 = stringPlus("a", null)
|
||||
if (t2 != "anull") return "Failed: t2=$t2"
|
||||
|
||||
val t3 = stringPlus(null, "b")
|
||||
if (t3 != "nullb") return "Failed: t3=$t3"
|
||||
|
||||
val t4 = stringPlus(null, null)
|
||||
if (t4 != "nullnull") return "Failed: t4=$t4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fun stringPlus(x: String?, y: Any?) = x.plus(y)
|
||||
|
||||
fun box(): String {
|
||||
val t1 = stringPlus("a", "b")
|
||||
if (t1 != "ab") return "Failed: t1=$t1"
|
||||
|
||||
val t2 = stringPlus("a", null)
|
||||
if (t2 != "anull") return "Failed: t2=$t2"
|
||||
|
||||
val t3 = stringPlus(null, "b")
|
||||
if (t3 != "nullb") return "Failed: t3=$t3"
|
||||
|
||||
val t4 = stringPlus(null, null)
|
||||
if (t4 != "nullnull") return "Failed: t4=$t4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fun stringPlus(x: String?, y: Any?) = "$x$y"
|
||||
|
||||
fun box(): String {
|
||||
val t1 = stringPlus("a", "b")
|
||||
if (t1 != "ab") return "Failed: t1=$t1"
|
||||
|
||||
val t2 = stringPlus("a", null)
|
||||
if (t2 != "anull") return "Failed: t2=$t2"
|
||||
|
||||
val t3 = stringPlus(null, "b")
|
||||
if (t3 != "nullb") return "Failed: t3=$t3"
|
||||
|
||||
val t4 = stringPlus(null, null)
|
||||
if (t4 != "nullnull") return "Failed: t4=$t4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -33,19 +33,8 @@ fun box(): String {
|
||||
// 1 IFGE
|
||||
// 1 IFLE
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// -- no boxing but lots of StringBuilder calls
|
||||
// 0 valueOf
|
||||
// 0 Intrinsics.stringPlus
|
||||
// 4 StringBuilder.<init>
|
||||
// 8 StringBuilder.append
|
||||
// 4 StringBuilder.toString
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// -- perform boxing and call Intrinsics.stringPlus instead
|
||||
// -- of having inlined string builder allocation, appends, and toString
|
||||
// 4 valueOf
|
||||
// 4 Intrinsics.stringPlus
|
||||
// 0 StringBuilder.<init>
|
||||
// 0 StringBuilder.append
|
||||
// 0 StringBuilder.toString
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
fun foo(x: String?, y: Any?) = x + y
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 stringPlus
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 NEW java/lang/StringBuilder
|
||||
// 2 INVOKEVIRTUAL java/lang/StringBuilder\.append \(Ljava/lang/Object;\)Ljava/lang/StringBuilder;
|
||||
// 1 INVOKEVIRTUAL java/lang/StringBuilder\.toString \(\)Ljava/lang/String;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
fun f(s: String?, t: String): String {
|
||||
return s.plus(t)
|
||||
}
|
||||
@@ -12,6 +10,9 @@ fun h(s: String, t: Any?): String {
|
||||
return s + t
|
||||
}
|
||||
|
||||
// 0 valueOf
|
||||
// 0 NEW java/lang/StringBuilder
|
||||
// 3 INVOKESTATIC kotlin/jvm/internal/Intrinsics.stringPlus
|
||||
// JVM_TEMPLATES
|
||||
// 1 INVOKESTATIC kotlin/jvm/internal/Intrinsics.stringPlus
|
||||
// - used in 's.plus(t)'
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 INVOKESTATIC kotlin/jvm/internal/Intrinsics.stringPlus
|
||||
@@ -26,11 +26,13 @@ fun fail() : String {
|
||||
// LINENUMBERS
|
||||
// test.kt:4 box
|
||||
// test.kt:12 box
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:16 fail
|
||||
// test.kt:4 box
|
||||
// test.kt:7 box
|
||||
// test.kt:16 fail
|
||||
// test.kt:7 box
|
||||
// test.kt:8 box
|
||||
// test.kt:12 box
|
||||
// test.kt:7 box
|
||||
|
||||
+18
@@ -41405,6 +41405,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+18
@@ -41561,6 +41561,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+15
@@ -33275,6 +33275,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/super")
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+15
@@ -27800,6 +27800,21 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/super")
|
||||
|
||||
Generated
+15
@@ -27206,6 +27206,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/super")
|
||||
|
||||
Generated
+15
@@ -27131,6 +27131,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/super")
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+15
@@ -16415,6 +16415,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
public void testSurrogatePair() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/surrogatePair.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringOperatorPlus.kt")
|
||||
public void testTwoArgumentNullableStringOperatorPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringOperatorPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentNullableStringPlus.kt")
|
||||
public void testTwoArgumentNullableStringPlus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentNullableStringPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgumentStringTemplate.kt")
|
||||
public void testTwoArgumentStringTemplate() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/strings/twoArgumentStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/super")
|
||||
|
||||
Reference in New Issue
Block a user