JVM_IR: remove ExpressionCodegen.inlinedInto
This commit is contained in:
+4
-8
@@ -139,7 +139,6 @@ class ExpressionCodegen(
|
|||||||
override val frameMap: IrFrameMap,
|
override val frameMap: IrFrameMap,
|
||||||
val mv: InstructionAdapter,
|
val mv: InstructionAdapter,
|
||||||
val classCodegen: ClassCodegen,
|
val classCodegen: ClassCodegen,
|
||||||
val inlinedInto: ExpressionCodegen?,
|
|
||||||
val smap: SourceMapper,
|
val smap: SourceMapper,
|
||||||
val reifiedTypeParametersUsages: ReifiedTypeParametersUsages,
|
val reifiedTypeParametersUsages: ReifiedTypeParametersUsages,
|
||||||
) : IrElementVisitor<PromisedValue, BlockInfo>, BaseExpressionCodegen {
|
) : IrElementVisitor<PromisedValue, BlockInfo>, BaseExpressionCodegen {
|
||||||
@@ -148,11 +147,8 @@ class ExpressionCodegen(
|
|||||||
|
|
||||||
var finallyDepth = 0
|
var finallyDepth = 0
|
||||||
|
|
||||||
val inlineRoot: ExpressionCodegen
|
|
||||||
get() = inlinedInto ?: this
|
|
||||||
|
|
||||||
val enclosingFunctionForLocalObjects: IrFunction
|
val enclosingFunctionForLocalObjects: IrFunction
|
||||||
get() = generateSequence(inlineRoot.irFunction) { context.enclosingMethodOverride[it] }.last()
|
get() = generateSequence(irFunction) { context.enclosingMethodOverride[it] }.last()
|
||||||
|
|
||||||
val context = classCodegen.context
|
val context = classCodegen.context
|
||||||
val typeMapper = context.typeMapper
|
val typeMapper = context.typeMapper
|
||||||
@@ -292,9 +288,9 @@ class ExpressionCodegen(
|
|||||||
if (state.isParamAssertionsDisabled)
|
if (state.isParamAssertionsDisabled)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (inlinedInto != null ||
|
if ((DescriptorVisibilities.isPrivate(irFunction.visibility) && !shouldGenerateNonNullAssertionsForPrivateFun(irFunction)) ||
|
||||||
(DescriptorVisibilities.isPrivate(irFunction.visibility) && !shouldGenerateNonNullAssertionsForPrivateFun(irFunction)) ||
|
|
||||||
irFunction.origin.isSynthetic ||
|
irFunction.origin.isSynthetic ||
|
||||||
|
irFunction.origin == JvmLoweredDeclarationOrigin.INLINE_LAMBDA ||
|
||||||
// TODO: refine this condition to not generate nullability assertions on parameters
|
// TODO: refine this condition to not generate nullability assertions on parameters
|
||||||
// corresponding to captured variables and anonymous object super constructor arguments
|
// corresponding to captured variables and anonymous object super constructor arguments
|
||||||
(irFunction is IrConstructor && irFunction.parentAsClass.isAnonymousObject) ||
|
(irFunction is IrConstructor && irFunction.parentAsClass.isAnonymousObject) ||
|
||||||
@@ -1526,7 +1522,7 @@ class ExpressionCodegen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val isFinallyMarkerRequired: Boolean
|
val isFinallyMarkerRequired: Boolean
|
||||||
get() = irFunction.isInline || inlinedInto != null
|
get() = irFunction.isInline || irFunction.origin == JvmLoweredDeclarationOrigin.INLINE_LAMBDA
|
||||||
|
|
||||||
val IrType.isReifiedTypeParameter: Boolean
|
val IrType.isReifiedTypeParameter: Boolean
|
||||||
get() = this.classifierOrNull?.safeAs<IrTypeParameterSymbol>()?.owner?.isReified == true
|
get() = this.classifierOrNull?.safeAs<IrTypeParameterSymbol>()?.owner?.isReified == true
|
||||||
|
|||||||
+3
-6
@@ -39,16 +39,15 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg
|
|||||||
private val context = classCodegen.context
|
private val context = classCodegen.context
|
||||||
|
|
||||||
fun generate(
|
fun generate(
|
||||||
inlinedInto: ExpressionCodegen? = null,
|
|
||||||
reifiedTypeParameters: ReifiedTypeParametersUsages = classCodegen.reifiedTypeParametersUsages
|
reifiedTypeParameters: ReifiedTypeParametersUsages = classCodegen.reifiedTypeParametersUsages
|
||||||
): SMAPAndMethodNode =
|
): SMAPAndMethodNode =
|
||||||
try {
|
try {
|
||||||
doGenerate(inlinedInto, reifiedTypeParameters)
|
doGenerate(reifiedTypeParameters)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
throw RuntimeException("Exception while generating code for:\n${irFunction.dump()}", e)
|
throw RuntimeException("Exception while generating code for:\n${irFunction.dump()}", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doGenerate(inlinedInto: ExpressionCodegen?, reifiedTypeParameters: ReifiedTypeParametersUsages): SMAPAndMethodNode {
|
private fun doGenerate(reifiedTypeParameters: ReifiedTypeParametersUsages): SMAPAndMethodNode {
|
||||||
val signature = context.methodSignatureMapper.mapSignatureWithGeneric(irFunction)
|
val signature = context.methodSignatureMapper.mapSignatureWithGeneric(irFunction)
|
||||||
val flags = irFunction.calculateMethodFlags()
|
val flags = irFunction.calculateMethodFlags()
|
||||||
val isSynthetic = flags.and(Opcodes.ACC_SYNTHETIC) != 0
|
val isSynthetic = flags.and(Opcodes.ACC_SYNTHETIC) != 0
|
||||||
@@ -116,9 +115,7 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg
|
|||||||
context.state.globalInlineContext.enterDeclaration(irFunction.suspendFunctionOriginal().toIrBasedDescriptor())
|
context.state.globalInlineContext.enterDeclaration(irFunction.suspendFunctionOriginal().toIrBasedDescriptor())
|
||||||
try {
|
try {
|
||||||
val adapter = InstructionAdapter(methodVisitor)
|
val adapter = InstructionAdapter(methodVisitor)
|
||||||
ExpressionCodegen(
|
ExpressionCodegen(irFunction, signature, frameMap, adapter, classCodegen, sourceMapper, reifiedTypeParameters).generate()
|
||||||
irFunction, signature, frameMap, adapter, classCodegen, inlinedInto, sourceMapper, reifiedTypeParameters
|
|
||||||
).generate()
|
|
||||||
} finally {
|
} finally {
|
||||||
context.state.globalInlineContext.exitDeclaration()
|
context.state.globalInlineContext.exitDeclaration()
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -42,12 +42,11 @@ class IrSourceCompilerForInline(
|
|||||||
|
|
||||||
override val inlineCallSiteInfo: InlineCallSiteInfo
|
override val inlineCallSiteInfo: InlineCallSiteInfo
|
||||||
get() {
|
get() {
|
||||||
val root = codegen.inlineRoot
|
val rootFunction = codegen.enclosingFunctionForLocalObjects
|
||||||
val rootFunction = root.enclosingFunctionForLocalObjects
|
|
||||||
return InlineCallSiteInfo(
|
return InlineCallSiteInfo(
|
||||||
root.classCodegen.type.internalName,
|
codegen.classCodegen.type.internalName,
|
||||||
if (rootFunction === root.irFunction)
|
if (rootFunction === codegen.irFunction)
|
||||||
root.signature.asmMethod
|
codegen.signature.asmMethod
|
||||||
else
|
else
|
||||||
codegen.methodSignatureMapper.mapAsmMethod(rootFunction),
|
codegen.methodSignatureMapper.mapAsmMethod(rootFunction),
|
||||||
rootFunction.inlineScopeVisibility,
|
rootFunction.inlineScopeVisibility,
|
||||||
@@ -66,7 +65,7 @@ class IrSourceCompilerForInline(
|
|||||||
reifiedTypeParameters.addUsedReifiedParameter(typeParameter.name.asString())
|
reifiedTypeParameters.addUsedReifiedParameter(typeParameter.name.asString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FunctionCodegen(lambdaInfo.function, codegen.classCodegen).generate(codegen.inlineRoot, reifiedTypeParameters)
|
return FunctionCodegen(lambdaInfo.function, codegen.classCodegen).generate(reifiedTypeParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun compileInlineFunction(jvmSignature: JvmMethodSignature): SMAPAndMethodNode {
|
override fun compileInlineFunction(jvmSignature: JvmMethodSignature): SMAPAndMethodNode {
|
||||||
@@ -100,7 +99,7 @@ class IrSourceCompilerForInline(
|
|||||||
override fun generateFinallyBlocks(finallyNode: MethodNode, curFinallyDepth: Int, returnType: Type, afterReturnLabel: Label, target: Label?) {
|
override fun generateFinallyBlocks(finallyNode: MethodNode, curFinallyDepth: Int, returnType: Type, afterReturnLabel: Label, target: Label?) {
|
||||||
ExpressionCodegen(
|
ExpressionCodegen(
|
||||||
codegen.irFunction, codegen.signature, codegen.frameMap, InstructionAdapter(finallyNode), codegen.classCodegen,
|
codegen.irFunction, codegen.signature, codegen.frameMap, InstructionAdapter(finallyNode), codegen.classCodegen,
|
||||||
codegen.inlinedInto, codegen.smap, codegen.reifiedTypeParametersUsages
|
codegen.smap, codegen.reifiedTypeParametersUsages
|
||||||
).also {
|
).also {
|
||||||
it.finallyDepth = curFinallyDepth
|
it.finallyDepth = curFinallyDepth
|
||||||
}.generateFinallyBlocksIfNeeded(returnType, afterReturnLabel, data, target)
|
}.generateFinallyBlocksIfNeeded(returnType, afterReturnLabel, data, target)
|
||||||
|
|||||||
Reference in New Issue
Block a user