JVM: remove contextKind from SourceCompilerForInline
Guess what? It's only useful for the old backend's type mapper!
This commit is contained in:
@@ -2956,7 +2956,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
? FictitiousArrayConstructor.create((ConstructorDescriptor) original) : original.getOriginal();
|
? FictitiousArrayConstructor.create((ConstructorDescriptor) original) : original.getOriginal();
|
||||||
PsiSourceCompilerForInline sourceCompiler = new PsiSourceCompilerForInline(this, callElement, functionDescriptor);
|
PsiSourceCompilerForInline sourceCompiler = new PsiSourceCompilerForInline(this, callElement, functionDescriptor);
|
||||||
|
|
||||||
JvmMethodSignature signature = typeMapper.mapSignatureWithGeneric(functionDescriptor, sourceCompiler.getContextKind());
|
JvmMethodSignature signature = typeMapper.mapSignatureWithGeneric(functionDescriptor, sourceCompiler.getContext().getContextKind());
|
||||||
if (signature.getAsmMethod().getName().contains("-") &&
|
if (signature.getAsmMethod().getName().contains("-") &&
|
||||||
!state.getConfiguration().getBoolean(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME)
|
!state.getConfiguration().getBoolean(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME)
|
||||||
) {
|
) {
|
||||||
@@ -2964,7 +2964,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
InlineClassesCodegenUtilKt.classFileContainsMethod(functionDescriptor, state, signature.getAsmMethod());
|
InlineClassesCodegenUtilKt.classFileContainsMethod(functionDescriptor, state, signature.getAsmMethod());
|
||||||
if (classFileContainsMethod != null && !classFileContainsMethod) {
|
if (classFileContainsMethod != null && !classFileContainsMethod) {
|
||||||
typeMapper.setUseOldManglingRulesForFunctionAcceptingInlineClass(true);
|
typeMapper.setUseOldManglingRulesForFunctionAcceptingInlineClass(true);
|
||||||
signature = typeMapper.mapSignatureWithGeneric(functionDescriptor, sourceCompiler.getContextKind());
|
signature = typeMapper.mapSignatureWithGeneric(functionDescriptor, sourceCompiler.getContext().getContextKind());
|
||||||
typeMapper.setUseOldManglingRulesForFunctionAcceptingInlineClass(false);
|
typeMapper.setUseOldManglingRulesForFunctionAcceptingInlineClass(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class PsiInlineCodegen(
|
|||||||
private val hiddenParameters = mutableListOf<Pair<ParameterInfo, Int>>()
|
private val hiddenParameters = mutableListOf<Pair<ParameterInfo, Int>>()
|
||||||
|
|
||||||
override fun processHiddenParameters() {
|
override fun processHiddenParameters() {
|
||||||
if (getMethodAsmFlags(functionDescriptor, sourceCompiler.contextKind, state) and Opcodes.ACC_STATIC == 0) {
|
val contextKind = (sourceCompiler as PsiSourceCompilerForInline).context.contextKind
|
||||||
|
if (getMethodAsmFlags(functionDescriptor, contextKind, state) and Opcodes.ACC_STATIC == 0) {
|
||||||
hiddenParameters += invocationParamBuilder.addNextParameter(methodOwner, false, actualDispatchReceiver) to
|
hiddenParameters += invocationParamBuilder.addNextParameter(methodOwner, false, actualDispatchReceiver) to
|
||||||
codegen.frameMap.enterTemp(methodOwner)
|
codegen.frameMap.enterTemp(methodOwner)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -46,7 +46,7 @@ class PsiSourceCompilerForInline(
|
|||||||
|
|
||||||
private val additionalInnerClasses = mutableListOf<ClassDescriptor>()
|
private val additionalInnerClasses = mutableListOf<ClassDescriptor>()
|
||||||
|
|
||||||
private val context = getContext(
|
val context = getContext(
|
||||||
functionDescriptor,
|
functionDescriptor,
|
||||||
functionDescriptor,
|
functionDescriptor,
|
||||||
codegen.state,
|
codegen.state,
|
||||||
@@ -58,9 +58,6 @@ class PsiSourceCompilerForInline(
|
|||||||
|
|
||||||
override val callsiteFile by lazy { callElement.containingFile }
|
override val callsiteFile by lazy { callElement.containingFile }
|
||||||
|
|
||||||
override val contextKind
|
|
||||||
get () = context.contextKind
|
|
||||||
|
|
||||||
override val inlineCallSiteInfo: InlineCallSiteInfo
|
override val inlineCallSiteInfo: InlineCallSiteInfo
|
||||||
get() {
|
get() {
|
||||||
var context = codegen.getContext()
|
var context = codegen.getContext()
|
||||||
@@ -226,13 +223,13 @@ class PsiSourceCompilerForInline(
|
|||||||
|
|
||||||
private fun mapDefault(): Method {
|
private fun mapDefault(): Method {
|
||||||
// This is all available in the `Callable` passed to `PsiInlineCodegen.genCallInner`, but it's not forwarded through the inliner...
|
// This is all available in the `Callable` passed to `PsiInlineCodegen.genCallInner`, but it's not forwarded through the inliner...
|
||||||
var result = state.typeMapper.mapDefaultMethod(functionDescriptor, contextKind)
|
var result = state.typeMapper.mapDefaultMethod(functionDescriptor, context.contextKind)
|
||||||
if (result.name.contains("-") &&
|
if (result.name.contains("-") &&
|
||||||
!state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME) &&
|
!state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME) &&
|
||||||
classFileContainsMethod(functionDescriptor, state, result) == false
|
classFileContainsMethod(functionDescriptor, state, result) == false
|
||||||
) {
|
) {
|
||||||
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = true
|
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = true
|
||||||
result = state.typeMapper.mapDefaultMethod(functionDescriptor, contextKind)
|
result = state.typeMapper.mapDefaultMethod(functionDescriptor, context.contextKind)
|
||||||
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = false
|
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = false
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.codegen.inline
|
|||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||||
import org.jetbrains.kotlin.codegen.BaseExpressionCodegen
|
import org.jetbrains.kotlin.codegen.BaseExpressionCodegen
|
||||||
import org.jetbrains.kotlin.codegen.OwnerKind
|
|
||||||
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
|
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
|
||||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
@@ -34,8 +33,6 @@ interface SourceCompilerForInline {
|
|||||||
|
|
||||||
val callsiteFile: PsiFile?
|
val callsiteFile: PsiFile?
|
||||||
|
|
||||||
val contextKind: OwnerKind
|
|
||||||
|
|
||||||
val inlineCallSiteInfo: InlineCallSiteInfo
|
val inlineCallSiteInfo: InlineCallSiteInfo
|
||||||
|
|
||||||
val sourceMapper: SourceMapper
|
val sourceMapper: SourceMapper
|
||||||
|
|||||||
-8
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.backend.common.ir.ir2string
|
|||||||
import org.jetbrains.kotlin.backend.jvm.ir.getKtFile
|
import org.jetbrains.kotlin.backend.jvm.ir.getKtFile
|
||||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.hasMangledReturnType
|
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.hasMangledReturnType
|
||||||
import org.jetbrains.kotlin.codegen.BaseExpressionCodegen
|
import org.jetbrains.kotlin.codegen.BaseExpressionCodegen
|
||||||
import org.jetbrains.kotlin.codegen.OwnerKind
|
|
||||||
import org.jetbrains.kotlin.codegen.inline.*
|
import org.jetbrains.kotlin.codegen.inline.*
|
||||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
@@ -51,13 +50,6 @@ class IrSourceCompilerForInline(
|
|||||||
override val callsiteFile: PsiFile?
|
override val callsiteFile: PsiFile?
|
||||||
get() = codegen.irFunction.fileParent.getKtFile()
|
get() = codegen.irFunction.fileParent.getKtFile()
|
||||||
|
|
||||||
override val contextKind: OwnerKind
|
|
||||||
get() = when (val parent = callElement.symbol.owner.parent) {
|
|
||||||
is IrPackageFragment -> OwnerKind.PACKAGE
|
|
||||||
is IrClass -> OwnerKind.IMPLEMENTATION
|
|
||||||
else -> throw AssertionError("Unexpected declaration container: $parent")
|
|
||||||
}
|
|
||||||
|
|
||||||
override val inlineCallSiteInfo: InlineCallSiteInfo
|
override val inlineCallSiteInfo: InlineCallSiteInfo
|
||||||
get() {
|
get() {
|
||||||
val root = generateSequence(codegen) { it.inlinedInto }.last()
|
val root = generateSequence(codegen) { it.inlinedInto }.last()
|
||||||
|
|||||||
Reference in New Issue
Block a user