Decrease number of 'invokeMethodDescriptor' usage in inliner
This commit is contained in:
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.isReleaseCoroutines
|
||||
import org.jetbrains.kotlin.coroutines.isSuspendLambda
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
|
||||
@@ -41,6 +42,8 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
|
||||
|
||||
abstract val isBoundCallableReference: Boolean
|
||||
|
||||
abstract val isSuspend: Boolean
|
||||
|
||||
abstract val lambdaClassType: Type
|
||||
|
||||
abstract val invokeMethod: Method
|
||||
@@ -108,6 +111,8 @@ class DefaultLambda(
|
||||
var originalBoundReceiverType: Type? = null
|
||||
private set
|
||||
|
||||
override val isSuspend = parameterDescriptor.isSuspendLambda
|
||||
|
||||
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
|
||||
val classReader = buildClassReaderByInternalName(sourceCompiler.state, lambdaClassType.internalName)
|
||||
var isPropertyReference = false
|
||||
@@ -218,6 +223,8 @@ class PsiExpressionLambda(
|
||||
|
||||
private val labels: Set<String>
|
||||
|
||||
override val isSuspend: Boolean
|
||||
|
||||
var closure: CalculatedClosure
|
||||
private set
|
||||
|
||||
@@ -253,6 +260,7 @@ class PsiExpressionLambda(
|
||||
|
||||
labels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor)
|
||||
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
|
||||
isSuspend = invokeMethodDescriptor.isSuspend
|
||||
}
|
||||
|
||||
override val capturedVars: List<CapturedParamDesc> by lazy {
|
||||
|
||||
@@ -234,7 +234,7 @@ class MethodInliner(
|
||||
// we should create additional parameter for continuation.
|
||||
var coroutineDesc = desc
|
||||
val actualInvokeDescriptor: FunctionDescriptor
|
||||
if (info.invokeMethodDescriptor.isSuspend) {
|
||||
if (info.isSuspend) {
|
||||
actualInvokeDescriptor = (info as ExpressionLambda).getInlineSuspendLambdaViewDescriptor()
|
||||
val parametersSize = actualInvokeDescriptor.valueParameters.size +
|
||||
(if (actualInvokeDescriptor.extensionReceiverParameter != null) 1 else 0)
|
||||
@@ -700,7 +700,7 @@ class MethodInliner(
|
||||
// 3) it is passed to invoke of lambda
|
||||
private fun replaceContinuationAccessesWithFakeContinuationsIfNeeded(processingNode: MethodNode) {
|
||||
val lambdaInfo = inliningContext.lambdaInfo ?: return
|
||||
if (!lambdaInfo.invokeMethodDescriptor.isSuspend) return
|
||||
if (!lambdaInfo.isSuspend) return
|
||||
val sources = analyzeMethodNodeBeforeInline(processingNode)
|
||||
val cfg = ControlFlowGraph.build(processingNode)
|
||||
val aload0s = processingNode.instructions.asSequence().filter { it.opcode == Opcodes.ALOAD && it.safeAs<VarInsnNode>()?.`var` == 0 }
|
||||
|
||||
+1
-1
@@ -279,7 +279,7 @@ class SurroundSuspendLambdaCallsWithSuspendMarkersMethodVisitor(
|
||||
|
||||
private fun FunctionalArgument.isSuspendLambda(): Boolean =
|
||||
(this is NonInlineableArgumentForInlineableParameterCalledInSuspend && isSuspend) ||
|
||||
(this is PsiExpressionLambda && invokeMethodDescriptor.isSuspend)
|
||||
(this is PsiExpressionLambda && isSuspend)
|
||||
|
||||
fun surroundInvokesWithSuspendMarkers(
|
||||
methodNode: MethodNode,
|
||||
|
||||
+3
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.toKotlinType
|
||||
import org.jetbrains.kotlin.ir.util.dump
|
||||
import org.jetbrains.kotlin.ir.util.getArgumentsWithIr
|
||||
import org.jetbrains.kotlin.ir.util.isSuspend
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
@@ -150,6 +151,8 @@ class IrExpressionLambdaImpl(
|
||||
override val isExtensionLambda: Boolean
|
||||
) : ExpressionLambda(isCrossInline), IrExpressionLambda {
|
||||
|
||||
override val isSuspend: Boolean = function.isSuspend
|
||||
|
||||
override fun isReturnFromMe(labelName: String): Boolean {
|
||||
return false //always false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user