[FIR] Don't keep ref to whole class proto
Store module name only
This commit is contained in:
committed by
teamcityserver
parent
a121061df7
commit
617d99faac
+3
-1
@@ -215,7 +215,9 @@ fun deserializeClassToSymbol(
|
|||||||
|
|
||||||
it.sourceElement = containerSource
|
it.sourceElement = containerSource
|
||||||
|
|
||||||
it.proto = FirClassProto(classProto, nameResolver)
|
classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)?.let { idx ->
|
||||||
|
it.moduleName = nameResolver.getString(idx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import org.jetbrains.kotlin.ir.types.IrType
|
|||||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||||
import org.jetbrains.kotlin.ir.util.isFakeOverride
|
import org.jetbrains.kotlin.ir.util.isFakeOverride
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class Fir2IrLazyClass(
|
class Fir2IrLazyClass(
|
||||||
@@ -204,11 +202,8 @@ class Fir2IrLazyClass(
|
|||||||
get() = null
|
get() = null
|
||||||
set(_) = error("We should never need to store metadata of external declarations.")
|
set(_) = error("We should never need to store metadata of external declarations.")
|
||||||
|
|
||||||
override val classProto: ProtoBuf.Class?
|
override val moduleName: String?
|
||||||
get() = fir.proto?.classProto
|
get() = fir.moduleName
|
||||||
|
|
||||||
override val nameResolver: NameResolver?
|
|
||||||
get() = fir.proto?.nameResolver
|
|
||||||
|
|
||||||
private fun FirNamedFunctionSymbol.isAbstractMethodOfAny(): Boolean {
|
private fun FirNamedFunctionSymbol.isAbstractMethodOfAny(): Boolean {
|
||||||
val fir = fir
|
val fir = fir
|
||||||
|
|||||||
@@ -184,11 +184,9 @@ private object SourceElementKey : FirDeclarationDataKey()
|
|||||||
|
|
||||||
var FirRegularClass.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey)
|
var FirRegularClass.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey)
|
||||||
|
|
||||||
private object ClassProtoKey : FirDeclarationDataKey()
|
private object ModuleNameKey : FirDeclarationDataKey()
|
||||||
|
|
||||||
class FirClassProto(val classProto: ProtoBuf.Class, val nameResolver: NameResolver)
|
var FirRegularClass.moduleName: String? by FirDeclarationDataRegistry.data(ModuleNameKey)
|
||||||
|
|
||||||
var FirRegularClass.proto: FirClassProto? by FirDeclarationDataRegistry.data(ClassProtoKey)
|
|
||||||
|
|
||||||
var FirTypeAlias.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey)
|
var FirTypeAlias.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey)
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -499,13 +499,15 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
|||||||
var current: IrDeclarationParent? = function.parent
|
var current: IrDeclarationParent? = function.parent
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
when (current) {
|
when (current) {
|
||||||
is IrMaybeDeserializedClass -> {
|
is IrLazyClass -> {
|
||||||
val classProto = current.classProto ?: return null
|
val classProto = current.classProto ?: return null
|
||||||
val nameResolver = current.nameResolver ?: return null
|
val nameResolver = current.nameResolver ?: return null
|
||||||
return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)
|
return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)
|
||||||
?.let(nameResolver::getString)
|
?.let(nameResolver::getString)
|
||||||
?: JvmProtoBufUtil.DEFAULT_MODULE_NAME
|
?: JvmProtoBufUtil.DEFAULT_MODULE_NAME
|
||||||
}
|
}
|
||||||
|
is IrMaybeDeserializedClass ->
|
||||||
|
return current.moduleName
|
||||||
is IrExternalPackageFragment -> {
|
is IrExternalPackageFragment -> {
|
||||||
val source = current.containerSource ?: return null
|
val source = current.containerSource ?: return null
|
||||||
return (source as? JvmPackagePartSource)?.moduleName
|
return (source as? JvmPackagePartSource)?.moduleName
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class IrLazyClass(
|
|||||||
override val isFun: Boolean,
|
override val isFun: Boolean,
|
||||||
override val stubGenerator: DeclarationStubGenerator,
|
override val stubGenerator: DeclarationStubGenerator,
|
||||||
override val typeTranslator: TypeTranslator
|
override val typeTranslator: TypeTranslator
|
||||||
) : IrClass(), IrLazyDeclarationBase, IrMaybeDeserializedClass {
|
) : IrClass(), IrLazyDeclarationBase {
|
||||||
init {
|
init {
|
||||||
symbol.bind(this)
|
symbol.bind(this)
|
||||||
}
|
}
|
||||||
@@ -103,8 +103,8 @@ class IrLazyClass(
|
|||||||
|
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
|
|
||||||
override val classProto: ProtoBuf.Class? get() = (descriptor as? DeserializedClassDescriptor)?.classProto
|
val classProto: ProtoBuf.Class? get() = (descriptor as? DeserializedClassDescriptor)?.classProto
|
||||||
override val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
|
val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
|
||||||
override val source: SourceElement get() = descriptor.source
|
override val source: SourceElement get() = descriptor.source
|
||||||
|
|
||||||
override var metadata: MetadataSource?
|
override var metadata: MetadataSource?
|
||||||
|
|||||||
+1
-4
@@ -6,10 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations.lazy
|
package org.jetbrains.kotlin.ir.declarations.lazy
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
|
||||||
|
|
||||||
interface IrMaybeDeserializedClass : IrDeclaration {
|
interface IrMaybeDeserializedClass : IrDeclaration {
|
||||||
val classProto: ProtoBuf.Class?
|
val moduleName: String?
|
||||||
val nameResolver: NameResolver?
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user