[K/N] serialize field names to caches

^KT-65443
This commit is contained in:
Johan Bay
2024-01-09 15:41:34 +01:00
committed by Space Team
parent b50111cde5
commit ac524f15d1
2 changed files with 7 additions and 6 deletions
@@ -113,7 +113,7 @@ internal object InlineFunctionBodyReferenceSerializer {
// [binaryType] is needed in case a field is of a private inline class type (which can't be deserialized).
// But it is safe to just set the field's type to the primitive type the inline class will be erased to.
class SerializedClassFieldInfo(val name: Int, val binaryType: Int, val type: Int, val flags: Int, val alignment: Int) {
class SerializedClassFieldInfo(val name: String, val binaryType: Int, val type: Int, val flags: Int, val alignment: Int) {
companion object {
const val FLAG_IS_CONST = 1
}
@@ -152,6 +152,7 @@ internal object ClassFieldsSerializer {
classFields.forEach {
+it.file.fqName
+it.file.path
it.fields.forEach { +it.name }
}
}
val size = stringTable.sizeBytes + classFields.sumOf { Int.SIZE_BYTES * (6 + it.typeParameterSigs.size + it.fields.size * 5) }
@@ -165,7 +166,7 @@ internal object ClassFieldsSerializer {
stream.writeInt(it.outerThisIndex)
stream.writeInt(it.fields.size)
it.fields.forEach { field ->
stream.writeInt(field.name)
stream.writeInt(stringTable.indices[field.name]!!)
stream.writeInt(field.binaryType)
stream.writeInt(field.type)
stream.writeInt(field.flags)
@@ -206,7 +207,7 @@ internal object ClassFieldsSerializer {
val outerThisIndex = stream.readInt()
val fieldsCount = stream.readInt()
val fields = Array(fieldsCount) {
val name = stream.readInt()
val name = stringTable[stream.readInt()]
val binaryType = stream.readInt()
val type = stream.readInt()
val flags = stream.readInt()
@@ -241,7 +241,7 @@ internal class KonanPartialModuleDeserializer(
val nameAndType = BinaryNameAndType.decode(outerProtoClass.thisReceiver.nameType)
SerializedClassFieldInfo(
name = INVALID_INDEX,
name = "",
binaryType = INVALID_INDEX,
nameAndType.typeIndex,
flags = 0,
@@ -258,7 +258,7 @@ internal class KonanPartialModuleDeserializer(
val primitiveBinaryType = field.type.computePrimitiveBinaryTypeOrNull()
SerializedClassFieldInfo(
nameAndType.nameIndex,
field.name,
primitiveBinaryType?.ordinal ?: INVALID_INDEX,
if (with(KonanManglerIr) { (classifier as? IrClassSymbol)?.owner?.isExported(compatibleMode) } == false)
INVALID_INDEX
@@ -478,7 +478,7 @@ internal class KonanPartialModuleDeserializer(
require(it.alignment == field.alignment) { "Mismatched align information for outer this" }
}
} else {
val name = fileDeserializationState.fileReader.string(field.name)
val name = field.name
val type = when {
field.type != INVALID_INDEX -> declarationDeserializer.deserializeIrType(field.type)
field.binaryType == INVALID_INDEX -> builtIns.anyNType