JVM_IR. Support inlining of bound CR
This commit is contained in:
@@ -438,7 +438,10 @@ class MethodInliner(
|
|||||||
private fun getNewIndex(`var`: Int): Int {
|
private fun getNewIndex(`var`: Int): Int {
|
||||||
val lambdaInfo = inliningContext.lambdaInfo
|
val lambdaInfo = inliningContext.lambdaInfo
|
||||||
if (reorderIrLambdaParameters && lambdaInfo is IrExpressionLambda) {
|
if (reorderIrLambdaParameters && lambdaInfo is IrExpressionLambda) {
|
||||||
val extensionSize = if (lambdaInfo.isExtensionLambda) lambdaInfo.invokeMethod.argumentTypes[0].size else 0
|
val extensionSize =
|
||||||
|
if (lambdaInfo.isExtensionLambda && !lambdaInfo.isBoundCallableReference)
|
||||||
|
lambdaInfo.invokeMethod.argumentTypes[0].size
|
||||||
|
else 0
|
||||||
return when {
|
return when {
|
||||||
// v-- extensionSize v-- argsSizeOnStack
|
// v-- extensionSize v-- argsSizeOnStack
|
||||||
// |- extension -|- captured -|- real -|- locals -| old descriptor
|
// |- extension -|- captured -|- real -|- locals -| old descriptor
|
||||||
|
|||||||
+5
-3
@@ -217,14 +217,16 @@ class IrExpressionLambdaImpl(
|
|||||||
|
|
||||||
private val loweredMethod = methodSignatureMapper.mapAsmMethod(function.getOrCreateSuspendFunctionViewIfNeeded(context))
|
private val loweredMethod = methodSignatureMapper.mapAsmMethod(function.getOrCreateSuspendFunctionViewIfNeeded(context))
|
||||||
|
|
||||||
val capturedParamsInDesc: List<Type> =
|
val capturedParamsInDesc: List<Type> = if (isBoundCallableReference) {
|
||||||
loweredMethod.argumentTypes.drop(if (isExtensionLambda) 1 else 0).take(capturedVars.size)
|
loweredMethod.argumentTypes.take(1)
|
||||||
|
} else loweredMethod.argumentTypes.drop(if (isExtensionLambda) 1 else 0).take(capturedVars.size)
|
||||||
|
|
||||||
override val invokeMethod: Method = loweredMethod.let {
|
override val invokeMethod: Method = loweredMethod.let {
|
||||||
Method(
|
Method(
|
||||||
it.name,
|
it.name,
|
||||||
it.returnType,
|
it.returnType,
|
||||||
((if (isExtensionLambda) it.argumentTypes.take(1) else emptyList()) +
|
(if (isBoundCallableReference) it.argumentTypes.drop(1)
|
||||||
|
else (if (isExtensionLambda) it.argumentTypes.take(1) else emptyList()) +
|
||||||
it.argumentTypes.drop((if (isExtensionLambda) 1 else 0) + capturedVars.size)).toTypedArray()
|
it.argumentTypes.drop((if (isExtensionLambda) 1 else 0) + capturedVars.size)).toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
class Z
|
||||||
|
|
||||||
|
class Q {
|
||||||
|
inline fun f(z: Z) = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return Z().run(Q()::f)
|
||||||
|
}
|
||||||
+5
@@ -876,6 +876,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineValueParameterInsteadOfReceiver.kt")
|
||||||
|
public void testInlineValueParameterInsteadOfReceiver() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerGenericConstuctor.kt")
|
@TestMetadata("innerGenericConstuctor.kt")
|
||||||
public void testInnerGenericConstuctor() throws Exception {
|
public void testInnerGenericConstuctor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
||||||
|
|||||||
Generated
+5
@@ -876,6 +876,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineValueParameterInsteadOfReceiver.kt")
|
||||||
|
public void testInlineValueParameterInsteadOfReceiver() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerGenericConstuctor.kt")
|
@TestMetadata("innerGenericConstuctor.kt")
|
||||||
public void testInnerGenericConstuctor() throws Exception {
|
public void testInnerGenericConstuctor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
||||||
|
|||||||
+5
@@ -876,6 +876,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
|||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineValueParameterInsteadOfReceiver.kt")
|
||||||
|
public void testInlineValueParameterInsteadOfReceiver() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerGenericConstuctor.kt")
|
@TestMetadata("innerGenericConstuctor.kt")
|
||||||
public void testInnerGenericConstuctor() throws Exception {
|
public void testInnerGenericConstuctor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
||||||
|
|||||||
Generated
+5
@@ -876,6 +876,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
|||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineValueParameterInsteadOfReceiver.kt")
|
||||||
|
public void testInlineValueParameterInsteadOfReceiver() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerGenericConstuctor.kt")
|
@TestMetadata("innerGenericConstuctor.kt")
|
||||||
public void testInnerGenericConstuctor() throws Exception {
|
public void testInnerGenericConstuctor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
||||||
|
|||||||
+5
@@ -146,6 +146,11 @@ public class IrCallableReferenceInlineTestsGenerated extends AbstractIrCallableR
|
|||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineValueParameterInsteadOfReceiver.kt")
|
||||||
|
public void testInlineValueParameterInsteadOfReceiver() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerGenericConstuctor.kt")
|
@TestMetadata("innerGenericConstuctor.kt")
|
||||||
public void testInnerGenericConstuctor() throws Exception {
|
public void testInnerGenericConstuctor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
||||||
|
|||||||
Generated
+5
@@ -146,6 +146,11 @@ public class CallableReferenceInlineTestsGenerated extends AbstractCallableRefer
|
|||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/filter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineValueParameterInsteadOfReceiver.kt")
|
||||||
|
public void testInlineValueParameterInsteadOfReceiver() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/inlineValueParameterInsteadOfReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerGenericConstuctor.kt")
|
@TestMetadata("innerGenericConstuctor.kt")
|
||||||
public void testInnerGenericConstuctor() throws Exception {
|
public void testInnerGenericConstuctor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
runTest("compiler/testData/codegen/boxInline/callableReference/bound/innerGenericConstuctor.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user