Remove cycle check and resolvedCall from 'preformInline' method

This commit is contained in:
Mikhael Bogdanov
2017-06-21 14:47:22 +02:00
parent 4711e2f9da
commit 0e2bd46124
@@ -51,6 +51,8 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionLiteral import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionLiteral
import org.jetbrains.kotlin.types.expressions.LabelResolver import org.jetbrains.kotlin.types.expressions.LabelResolver
import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Opcodes
@@ -157,18 +159,13 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
} }
fun performInline( fun performInline(
resolvedCall: ResolvedCall<*>?, typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
callDefault: Boolean, callDefault: Boolean,
codegen: BaseExpressionCodegen codegen: BaseExpressionCodegen
) { ) {
if (!state.inlineCycleReporter.enterIntoInlining(resolvedCall)) {
generateStub(resolvedCall, codegen)
return
}
var nodeAndSmap: SMAPAndMethodNode? = null var nodeAndSmap: SMAPAndMethodNode? = null
try { try {
nodeAndSmap = createInlineMethodNode(functionDescriptor, jvmSignature, callDefault, resolvedCall, state, sourceCompiler) nodeAndSmap = createInlineMethodNode(functionDescriptor, jvmSignature, callDefault, typeArguments, state, sourceCompiler)
endCall(inlineCall(nodeAndSmap, callDefault)) endCall(inlineCall(nodeAndSmap, callDefault))
} }
catch (e: CompilationException) { catch (e: CompilationException) {
@@ -180,9 +177,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
catch (e: Exception) { catch (e: Exception) {
throw throwCompilationException(nodeAndSmap, e, true) throw throwCompilationException(nodeAndSmap, e, true)
} }
finally {
state.inlineCycleReporter.exitFromInliningOf(resolvedCall)
}
} }
private fun canSkipStackSpillingOnInline(methodNode: MethodNode): Boolean { private fun canSkipStackSpillingOnInline(methodNode: MethodNode): Boolean {
@@ -475,17 +469,15 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
functionDescriptor: FunctionDescriptor, functionDescriptor: FunctionDescriptor,
jvmSignature: JvmMethodSignature, jvmSignature: JvmMethodSignature,
callDefault: Boolean, callDefault: Boolean,
resolvedCall: ResolvedCall<*>?, typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
state: GenerationState, state: GenerationState,
sourceCompilerForInline: SourceCompilerForInline sourceCompilerForInline: SourceCompilerForInline
): SMAPAndMethodNode { ): SMAPAndMethodNode {
when { when {
isSpecialEnumMethod(functionDescriptor) -> { isSpecialEnumMethod(functionDescriptor) -> {
val arguments = resolvedCall!!.typeArguments
val node = createSpecialEnumMethodBody( val node = createSpecialEnumMethodBody(
functionDescriptor.name.asString(), functionDescriptor.name.asString(),
arguments.keys.single().defaultType, typeArguments!!.keys.single().defaultType,
state.typeMapper state.typeMapper
) )
return SMAPAndMethodNode(node, SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1)) return SMAPAndMethodNode(node, SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1))
@@ -674,7 +666,15 @@ class PsiInlineCodegen(
callDefault: Boolean, callDefault: Boolean,
codegen: ExpressionCodegen codegen: ExpressionCodegen
) { ) {
performInline(resolvedCall, callDefault, codegen) if (!state.inlineCycleReporter.enterIntoInlining(resolvedCall)) {
generateStub(resolvedCall, codegen)
return
}
try {
performInline(resolvedCall?.typeArguments, callDefault, codegen)
} finally {
state.inlineCycleReporter.exitFromInliningOf(resolvedCall)
}
} }
override fun processAndPutHiddenParameters(justProcess: Boolean) { override fun processAndPutHiddenParameters(justProcess: Boolean) {