JVM: move callSiteFile to InlineCallSiteInfo

This commit is contained in:
pyos
2021-06-08 13:21:04 +02:00
committed by max-kammerer
parent 6c1a5e1211
commit b136acb185
8 changed files with 24 additions and 49 deletions
@@ -48,7 +48,7 @@ class IrInlineCodegen(
if (info.generateAssertField) {
// May be inlining code into `<clinit>`, in which case it's too late to modify the IR and
// `generateAssertFieldIfNeeded` will return a statement for which we need to emit bytecode.
val isClInit = info.callSiteInfo.functionName == "<clinit>"
val isClInit = info.callSiteInfo.method.name == "<clinit>"
codegen.classCodegen.generateAssertFieldIfNeeded(isClInit)?.accept(codegen, BlockInfo())?.discard()
}
}
@@ -46,19 +46,15 @@ class IrSourceCompilerForInline(
override val callElementText: String
get() = ir2string(callElement)
override val callsiteFile: PsiFile?
get() = codegen.irFunction.fileParent.getKtFile()
override val inlineCallSiteInfo: InlineCallSiteInfo
get() {
val root = generateSequence(codegen) { it.inlinedInto }.last()
return InlineCallSiteInfo(
root.classCodegen.type.internalName,
root.signature.asmMethod.name,
root.signature.asmMethod.descriptor,
root.signature.asmMethod,
root.irFunction.isInlineOrInsideInline(),
root.irFunction.isSuspend,
findElement()?.let { CodegenUtil.getLineNumberForElement(it, false) } ?: 0
root.irFunction.fileParent.getKtFile(),
callElement.psiElement?.let { CodegenUtil.getLineNumberForElement(it, false) } ?: 0
)
}
@@ -141,8 +137,6 @@ class IrSourceCompilerForInline(
.at(callElement.symbol.owner as IrDeclaration)
.report(SUSPENSION_POINT_INSIDE_MONITOR, stackTraceElement)
}
private fun findElement() = callElement.psiElement as? KtElement
}
private tailrec fun IrDeclaration.isInlineOrInsideInline(): Boolean {