JVM_IR KT-47984 allow noinline functional inplace args

This commit is contained in:
Dmitry Petrov
2021-08-09 17:44:24 +03:00
committed by TeamCityServer
parent 9be941def2
commit 7a99f9ff2e
11 changed files with 94 additions and 1 deletions

View File

@@ -18252,6 +18252,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@Test
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@Test
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {

View File

@@ -58,7 +58,7 @@ class IrInlineCodegen(
}
if (actualParametersCount == 0)
return false
if (function.valueParameters.any { it.isFunctionOrSuspendFunction() })
if (function.valueParameters.any { !it.isNoinline && it.isFunctionOrSuspendFunction() })
return false
return canInlineArgumentsInPlace(sourceCompiler.compileInlineFunction(jvmSignature).node)

View File

@@ -0,0 +1,30 @@
// IGNORE_BACKEND: WASM
// FULL_JDK
// WITH_RUNTIME
val z = ArrayList<String>()
inline fun a(body: () -> Unit) {
body()
z += "a"
}
inline fun b(body: () -> Unit) {
z += "b"
body()
a { z += "from b" }
}
fun test() {
b { z += "test" }
}
fun box(): String {
test()
if (z != listOf("b", "test", "from b", "a"))
return z.toString()
return "OK"
}

View File

@@ -0,0 +1,20 @@
// IGNORE_BACKEND: WASM
// WITH_RUNTIME
// CHECK_BYTECODE_TEXT
// JVM_IR_TEMPLATES
// 1 ASTORE 1
// 12 ALOAD 1
// JVM_TEMPLATES
// 2 ASTORE 1
// 13 ALOAD 1
@Suppress("DEPRECATION_ERROR")
fun box(): String {
val seq = buildSequence {
yield("O")
yield("K")
}
val it = seq.iterator()
return it.next() + it.next()
}

View File

@@ -18108,6 +18108,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@Test
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@Test
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {

View File

@@ -18252,6 +18252,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@Test
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@Test
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {

View File

@@ -15009,6 +15009,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/suspensionPointInsideArgument.kt");

View File

@@ -13098,6 +13098,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/suspensionPointInsideArgument.kt");

View File

@@ -12504,6 +12504,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/suspensionPointInsideArgument.kt");

View File

@@ -12569,6 +12569,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/suspensionPointInsideArgument.kt");

View File

@@ -6659,6 +6659,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/inlineArgsInPlace/mutableCollectionPlusAssign.kt");
}
@TestMetadata("noinlineParameter.kt")
public void testNoinlineParameter() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/noinlineParameter.kt");
}
@TestMetadata("suspensionPointInsideArgument.kt")
public void testSuspensionPointInsideArgument() throws Exception {
runTest("compiler/testData/codegen/box/inlineArgsInPlace/suspensionPointInsideArgument.kt");