diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/invalidation.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/invalidation.kt index 1887cc5b8c2..0931b7c9bfc 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/invalidation.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/invalidation.kt @@ -6,7 +6,8 @@ package org.jetbrains.kotlin.ir.backend.js.ic import org.jetbrains.kotlin.backend.common.serialization.IdSignatureDeserializer -import org.jetbrains.kotlin.backend.common.serialization.IrLibraryFile +import org.jetbrains.kotlin.backend.common.serialization.IrLibraryBytesSource +import org.jetbrains.kotlin.backend.common.serialization.IrLibraryFileFromBytes import org.jetbrains.kotlin.backend.common.serialization.codedInputStream import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor import org.jetbrains.kotlin.config.CompilerConfiguration @@ -121,7 +122,7 @@ private fun KotlinLibrary.filesAndSigReaders(): List() @@ -39,8 +35,8 @@ class IdSignatureDeserializer(private val fileReader: IrLibraryFile, fileSymbol: } private fun deserializePublicIdSignature(proto: ProtoCommonIdSignature): IdSignature.CommonSignature { - val pkg = fileReader.deserializeFqName(proto.packageFqNameList) - val cls = fileReader.deserializeFqName(proto.declarationFqNameList) + val pkg = libraryFile.deserializeFqName(proto.packageFqNameList) + val cls = libraryFile.deserializeFqName(proto.declarationFqNameList) val memberId = if (proto.hasMemberUniqId()) proto.memberUniqId else null return IdSignature.CommonSignature(pkg, cls, memberId, proto.flags) @@ -49,7 +45,7 @@ class IdSignatureDeserializer(private val fileReader: IrLibraryFile, fileSymbol: private fun deserializeAccessorIdSignature(proto: ProtoAccessorIdSignature): IdSignature.AccessorSignature { val propertySignature = deserializeIdSignature(proto.propertySignature) require(propertySignature is IdSignature.CommonSignature) { "For public accessor corresponding property supposed to be public as well" } - val name = fileReader.deserializeString(proto.name) + val name = libraryFile.string(proto.name) val hash = proto.accessorHashId val mask = proto.flags @@ -78,9 +74,9 @@ class IdSignatureDeserializer(private val fileReader: IrLibraryFile, fileSymbol: } private fun deserializeLocalIdSignature(proto: ProtoLocalSignature): IdSignature.LocalSignature { - val localFqn = fileReader.deserializeFqName(proto.localFqNameList) + val localFqn = libraryFile.deserializeFqName(proto.localFqNameList) val localHash = if (proto.hasLocalHash()) proto.localHash else null - val description = if (proto.hasDebugInfo()) fileReader.deserializeDebugInfo(proto.debugInfo) else null + val description = if (proto.hasDebugInfo()) libraryFile.debugInfo(proto.debugInfo) else null return IdSignature.LocalSignature(localFqn, localHash, description) } @@ -105,8 +101,4 @@ class IdSignatureDeserializer(private val fileReader: IrLibraryFile, fileSymbol: fun signatureToIndexMapping(): Map { return signatureCache.entries.associate { it.value to it.key } } - - companion object { - private val extensionRegistryLite = ExtensionRegistryLite.newInstance() - } } \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt index eab40901871..f3114be1d42 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt @@ -78,7 +78,7 @@ class IrBodyDeserializer( private val builtIns: IrBuiltIns, private val allowErrorNodes: Boolean, private val irFactory: IrFactory, - private val fileReader: IrLibraryFile, + private val libraryFile: IrLibraryFile, private val declarationDeserializer: IrDeclarationDeserializer, private val statementOriginIndex: Map, private val allowErrorStatementOrigins: Boolean, // TODO: support InlinerExpressionLocationHint @@ -382,9 +382,9 @@ class IrBodyDeserializer( start: Int, end: Int, type: IrType ): IrErrorExpression { require(allowErrorNodes) { - "IrErrorExpression($start, $end, \"${fileReader.deserializeString(proto.description)}\") found but error code is not allowed" + "IrErrorExpression($start, $end, \"${libraryFile.string(proto.description)}\") found but error code is not allowed" } - return IrErrorExpressionImpl(start, end, type, fileReader.deserializeString(proto.description)) + return IrErrorExpressionImpl(start, end, type, libraryFile.string(proto.description)) } private fun deserializeErrorCallExpression( @@ -392,9 +392,9 @@ class IrBodyDeserializer( start: Int, end: Int, type: IrType ): IrErrorCallExpression { require(allowErrorNodes) { - "IrErrorCallExpressionImpl($start, $end, \"${fileReader.deserializeString(proto.description)}\") found but error code is not allowed" + "IrErrorCallExpressionImpl($start, $end, \"${libraryFile.string(proto.description)}\") found but error code is not allowed" } - return IrErrorCallExpressionImpl(start, end, type, fileReader.deserializeString(proto.description)).apply { + return IrErrorCallExpressionImpl(start, end, type, libraryFile.string(proto.description)).apply { if (proto.hasReceiver()) { explicitReceiver = deserializeExpression(proto.receiver) } @@ -672,7 +672,7 @@ class IrBodyDeserializer( } private fun deserializeLoop(proto: ProtoLoop, loop: IrLoop): IrLoop { - val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null + val label = if (proto.hasLabel()) libraryFile.string(proto.label) else null val body = if (proto.hasBody()) deserializeExpression(proto.body) else null val condition = deserializeExpression(proto.condition) @@ -713,7 +713,7 @@ class IrBodyDeserializer( start, end, type, - fileReader.deserializeString(proto.memberName), + libraryFile.string(proto.memberName), deserializeExpression(proto.receiver) ) @@ -774,7 +774,7 @@ class IrBodyDeserializer( } private fun deserializeBreak(proto: ProtoBreak, start: Int, end: Int, type: IrType): IrBreak { - val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null + val label = if (proto.hasLabel()) libraryFile.string(proto.label) else null val loopId = proto.loopId val loop = deserializeLoopHeader(loopId) { if (allowErrorLoopIndices) { @@ -790,7 +790,7 @@ class IrBodyDeserializer( } private fun deserializeContinue(proto: ProtoContinue, start: Int, end: Int, type: IrType): IrContinue { - val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null + val label = if (proto.hasLabel()) libraryFile.string(proto.label) else null val loopId = proto.loopId val loop = deserializeLoopHeader(loopId) { if (allowErrorLoopIndices) { @@ -822,7 +822,7 @@ class IrBodyDeserializer( LONG -> IrConstImpl.long(start, end, type, proto.long) STRING - -> IrConstImpl.string(start, end, type, fileReader.deserializeString(proto.string)) + -> IrConstImpl.string(start, end, type, libraryFile.string(proto.string)) FLOAT_BITS -> IrConstImpl.float(start, end, type, Float.fromBits(proto.floatBits)) DOUBLE_BITS @@ -891,7 +891,7 @@ class IrBodyDeserializer( } fun deserializeIrStatementOrigin(protoName: Int): IrStatementOrigin { - return fileReader.deserializeString(protoName).let { + return libraryFile.string(protoName).let { val componentPrefix = "COMPONENT_" when { it.startsWith(componentPrefix) -> { diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt index 078cd80e769..e67e611bd8d 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt @@ -27,8 +27,6 @@ import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.protobuf.CodedInputStream -import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite import org.jetbrains.kotlin.types.Variance import kotlin.collections.set import org.jetbrains.kotlin.backend.common.serialization.proto.IrAnonymousInit as ProtoAnonymousInit @@ -61,7 +59,7 @@ class IrDeclarationDeserializer( builtIns: IrBuiltIns, private val symbolTable: SymbolTable, val irFactory: IrFactory, - private val fileReader: IrLibraryFile, + private val libraryFile: IrLibraryFile, private val parent: IrDeclarationParent, val allowErrorNodes: Boolean, private val deserializeInlineFunctions: Boolean, @@ -81,7 +79,7 @@ class IrDeclarationDeserializer( builtIns, allowErrorNodes, irFactory, - fileReader, + libraryFile, this, statementOriginIndex + additionalStatementOriginIndex, allowErrorStatementOrigins, @@ -89,17 +87,14 @@ class IrDeclarationDeserializer( ) private fun deserializeName(index: Int): Name { - val name = fileReader.deserializeString(index) + val name = libraryFile.string(index) return Name.guessByFirstCharacter(name) } private val irTypeCache = mutableMapOf() - private fun readType(index: Int): CodedInputStream = - fileReader.type(index).codedInputStream - private fun loadTypeProto(index: Int): ProtoType { - return ProtoType.parseFrom(readType(index), extensionRegistry) + return libraryFile.type(index) } fun deserializeNullableIrType(index: Int): IrType? = if (index == -1) null else deserializeIrType(index) @@ -485,15 +480,12 @@ class IrDeclarationDeserializer( } } - private fun readBody(index: Int): CodedInputStream = - fileReader.body(index).codedInputStream - private fun loadStatementBodyProto(index: Int): ProtoStatement { - return ProtoStatement.parseFrom(readBody(index), extensionRegistry) + return libraryFile.statementBody(index) } private fun loadExpressionBodyProto(index: Int): ProtoExpression { - return ProtoExpression.parseFrom(readBody(index), extensionRegistry) + return libraryFile.expressionBody(index) } fun deserializeExpressionBody(index: Int): IrExpressionBody? { @@ -748,12 +740,10 @@ class IrDeclarationDeserializer( private val allKnownStatementOrigins = IrStatementOrigin::class.nestedClasses.toList() private val statementOriginIndex = allKnownStatementOrigins.mapNotNull { it.objectInstance as? IrStatementOriginImpl }.associateBy { it.debugName } - - private val extensionRegistry = ExtensionRegistryLite.newInstance() } fun deserializeIrDeclarationOrigin(protoName: Int): IrDeclarationOriginImpl { - val originName = fileReader.deserializeString(protoName) + val originName = libraryFile.string(protoName) return declarationOriginIndex[originName] ?: object : IrDeclarationOriginImpl(originName) {} } diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt index 11d5500fcd9..a602ba23966 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt @@ -16,15 +16,18 @@ import org.jetbrains.kotlin.ir.util.NaiveSourceBasedFileEntryImpl import org.jetbrains.kotlin.library.IrLibrary import org.jetbrains.kotlin.library.encodings.WobblyTF8 import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.protobuf.CodedInputStream import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite +import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature as ProtoIdSignature import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall as ProtoConstructorCall import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoDeclaration +import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile as ProtoFile +import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement +import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoType class IrFileDeserializer( val file: IrFile, - private val fileReader: IrLibraryFile, + private val libraryFile: IrLibraryFile, fileProto: ProtoFile, val symbolDeserializer: IrSymbolDeserializer, val declarationDeserializer: IrDeclarationDeserializer, @@ -39,12 +42,9 @@ class IrFileDeserializer( } } - private fun readDeclaration(index: Int): CodedInputStream = - fileReader.irDeclaration(index).codedInputStream - private fun loadTopLevelDeclarationProto(idSig: IdSignature): ProtoDeclaration { val idSigIndex = reversedSignatureIndex[idSig] ?: error("Not found Idx for $idSig") - return ProtoDeclaration.parseFrom(readDeclaration(idSigIndex), ExtensionRegistryLite.newInstance()) + return libraryFile.declaration(idSigIndex) } fun deserializeFileImplicitDataIfFirstUse() { @@ -58,7 +58,7 @@ class IrFileDeserializer( class FileDeserializationState( val linker: KotlinIrLinker, file: IrFile, - fileReader: IrLibraryFile, + fileReader: IrLibraryFileFromBytes, fileProto: ProtoFile, deserializeBodies: Boolean, allowErrorNodes: Boolean, @@ -139,6 +139,16 @@ class FileDeserializationState( } abstract class IrLibraryFile { + abstract fun declaration(index: Int): ProtoDeclaration + abstract fun type(index: Int): ProtoType + abstract fun signature(index: Int): ProtoIdSignature + abstract fun string(index: Int): String + abstract fun expressionBody(index: Int): ProtoExpression + abstract fun statementBody(index: Int): ProtoStatement + abstract fun debugInfo(index: Int): String? +} + +abstract class IrLibraryBytesSource { abstract fun irDeclaration(index: Int): ByteArray abstract fun type(index: Int): ByteArray abstract fun signature(index: Int): ByteArray @@ -147,7 +157,32 @@ abstract class IrLibraryFile { abstract fun debugInfo(index: Int): ByteArray? } -class IrLibraryFileFromKlib(private val klib: IrLibrary, private val fileIndex: Int) : IrLibraryFile() { +class IrLibraryFileFromBytes(private val bytesSource: IrLibraryBytesSource) : IrLibraryFile() { + + override fun declaration(index: Int): ProtoDeclaration = + ProtoDeclaration.parseFrom(bytesSource.irDeclaration(index).codedInputStream, extensionRegistryLite) + + override fun type(index: Int): ProtoType = ProtoType.parseFrom(bytesSource.type(index).codedInputStream, extensionRegistryLite) + + override fun signature(index: Int): ProtoIdSignature = + ProtoIdSignature.parseFrom(bytesSource.signature(index).codedInputStream, extensionRegistryLite) + + override fun string(index: Int): String = WobblyTF8.decode(bytesSource.string(index)) + + override fun expressionBody(index: Int): ProtoExpression = + ProtoExpression.parseFrom(bytesSource.body(index).codedInputStream, extensionRegistryLite) + + override fun statementBody(index: Int): ProtoStatement = + ProtoStatement.parseFrom(bytesSource.body(index).codedInputStream, extensionRegistryLite) + + override fun debugInfo(index: Int): String? = bytesSource.debugInfo(index)?.let { WobblyTF8.decode(it) } + + companion object { + val extensionRegistryLite: ExtensionRegistryLite = ExtensionRegistryLite.newInstance() + } +} + +class IrKlibBytesSource(private val klib: IrLibrary, private val fileIndex: Int) : IrLibraryBytesSource() { override fun irDeclaration(index: Int): ByteArray = klib.irDeclaration(index, fileIndex) override fun type(index: Int): ByteArray = klib.type(index, fileIndex) override fun signature(index: Int): ByteArray = klib.signature(index, fileIndex) @@ -156,11 +191,8 @@ class IrLibraryFileFromKlib(private val klib: IrLibrary, private val fileIndex: override fun debugInfo(index: Int): ByteArray? = klib.debugInfo(index, fileIndex) } -internal fun IrLibraryFile.deserializeString(index: Int): String = WobblyTF8.decode(string(index)) -internal fun IrLibraryFile.deserializeDebugInfo(index: Int): String? = debugInfo(index)?.let { WobblyTF8.decode(it) } - internal fun IrLibraryFile.deserializeFqName(fqn: List): String = - fqn.joinToString(".", transform = ::deserializeString) + fqn.joinToString(".", transform = ::string) fun IrLibraryFile.createFile(module: IrModuleFragment, fileProto: ProtoFile): IrFile { val fileName = fileProto.fileEntry.name diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt index 31995ad7524..95b7beeeec4 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable class IrSymbolDeserializer( val symbolTable: ReferenceSymbolTable, - val fileReader: IrLibraryFile, + val libraryFile: IrLibraryFile, val fileSymbol: IrFileSymbol, val actuals: List, val enqueueLocalTopLevelDeclaration: (IdSignature) -> Unit, @@ -103,7 +103,7 @@ class IrSymbolDeserializer( } } - val signatureDeserializer = IdSignatureDeserializer(fileReader, fileSymbol) + val signatureDeserializer = IdSignatureDeserializer(libraryFile, fileSymbol) fun deserializeIdSignature(index: Int): IdSignature { return signatureDeserializer.deserializeIdSignature(index) diff --git a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcFileDeserializer.kt b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcFileDeserializer.kt index 8a03f988ef5..4da7f83382b 100644 --- a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcFileDeserializer.kt +++ b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcFileDeserializer.kt @@ -23,13 +23,12 @@ import org.jetbrains.kotlin.library.impl.DeclarationIrTableMemoryReader import org.jetbrains.kotlin.library.impl.IrArrayMemoryReader import org.jetbrains.kotlin.library.impl.IrLongArrayMemoryReader import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoIrDeclaration import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile as ProtoIrFile class IcFileDeserializer( val linker: JsIrLinker, private val file: IrFile, - originalFileReader: IrLibraryFile, + originalFileReader: IrLibraryFileFromBytes, fileProto: ProtoIrFile, deserializeBodies: Boolean, allowErrorNodes: Boolean, @@ -115,7 +114,7 @@ class IcFileDeserializer( // IC data processing starts here - private val icFileReader = FileReaderFromSerializedIrFile(icFileData.file) + private val icFileReader = IrLibraryFileFromBytes(FileReaderFromSerializedIrFile(icFileData.file)) val symbolDeserializer = IrSymbolDeserializer( linker.symbolTable, @@ -195,8 +194,7 @@ class IcFileDeserializer( cachedDeclaration(idSig)?.let { return it } val idSigIndex = reversedSignatureIndex[idSig] ?: return null - val declarationStream = icFileReader.irDeclaration(idSigIndex).codedInputStream - val declarationProto = ProtoIrDeclaration.parseFrom(declarationStream, extensionRegistryLite) + val declarationProto = icFileReader.declaration(idSigIndex) return declarationDeserializer.deserializeDeclaration(declarationProto) } @@ -221,8 +219,7 @@ class IcFileDeserializer( } reversedSignatureIndex[maybeTopLevel]?.let { idSigIndex -> - val declarationStream = icFileReader.irDeclaration(idSigIndex).codedInputStream - val declarationProto = ProtoIrDeclaration.parseFrom(declarationStream, extensionRegistryLite) + val declarationProto = icFileReader.declaration(idSigIndex) return declarationDeserializer.deserializeDeclaration(declarationProto) } @@ -250,9 +247,7 @@ class IcFileDeserializer( } } -private val extensionRegistryLite = ExtensionRegistryLite.newInstance() - -private class FileReaderFromSerializedIrFile(val irFile: SerializedIrFile) : IrLibraryFile() { +private class FileReaderFromSerializedIrFile(val irFile: SerializedIrFile) : IrLibraryBytesSource() { private val declarationReader = DeclarationIrTableMemoryReader(irFile.declarations) private val typeReader = IrArrayMemoryReader(irFile.types) private val signatureReader = IrArrayMemoryReader(irFile.signatures) diff --git a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcModuleDeserializer.kt b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcModuleDeserializer.kt index f467cf44a07..75dea07d9c6 100644 --- a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcModuleDeserializer.kt +++ b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/IcModuleDeserializer.kt @@ -127,7 +127,7 @@ class IcModuleDeserializer( allowErrorNodes: Boolean ): IrFile { - val fileReader = IrLibraryFileFromKlib(moduleDeserializer.klib, fileIndex) + val fileReader = IrLibraryFileFromBytes(IrKlibBytesSource(moduleDeserializer.klib, fileIndex)) val file = fileReader.createFile(moduleFragment, fileProto) val fileStrategy = strategyResolver(file.fileEntry.name) diff --git a/compiler/ir/serialization.jvm/src/JvmIr.proto b/compiler/ir/serialization.jvm/src/JvmIr.proto index 49adcb4d012..0ada03f7d3f 100644 --- a/compiler/ir/serialization.jvm/src/JvmIr.proto +++ b/compiler/ir/serialization.jvm/src/JvmIr.proto @@ -16,11 +16,11 @@ message XStatementOrExpression { message AuxTables { // TODO: optimize the representation. - repeated bytes type = 1; - repeated bytes signature = 2; - repeated bytes string = 3; - repeated bytes body = 4; - repeated bytes debug_info = 5; + repeated common.serialization.proto.IrType type = 1; + repeated common.serialization.proto.IdSignature signature = 2; + repeated string string = 3; + repeated XStatementOrExpression body = 4; + repeated string debug_info = 5; } message JvmIrFile { diff --git a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIrSerializerSession.kt b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIrSerializerSession.kt index abc47026354..bb45883736c 100644 --- a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIrSerializerSession.kt +++ b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIrSerializerSession.kt @@ -54,11 +54,16 @@ class JvmIrSerializerSession( private fun serializeAuxTables(): JvmIr.AuxTables { val proto = JvmIr.AuxTables.newBuilder() - protoTypeArray.forEach { proto.addType(it.toByteString()) } - protoIdSignatureArray.forEach { proto.addSignature(it.toByteString()) } - protoStringArray.forEach { proto.addString(ByteString.copyFromUtf8(it)) } - protoBodyArray.forEach { proto.addBody(ByteString.copyFrom(it.toByteArray())) } - protoDebugInfoArray.forEach { proto.addDebugInfo(ByteString.copyFromUtf8(it)) } + protoTypeArray.forEach(proto::addType) + protoIdSignatureArray.forEach(proto::addSignature) + protoStringArray.forEach(proto::addString) + protoBodyArray.forEach { proto.addBody(it.toProto()) } + protoDebugInfoArray.forEach(proto::addDebugInfo) return proto.build() } + + fun XStatementOrExpression.toProto(): JvmIr.XStatementOrExpression = when (this) { + is XStatementOrExpression.XStatement -> JvmIr.XStatementOrExpression.newBuilder().setStatement(toProtoStatement()).build() + is XStatementOrExpression.XExpression -> JvmIr.XStatementOrExpression.newBuilder().setExpression(toProtoExpression()).build() + } } \ No newline at end of file diff --git a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/deserializeLazyDeclarations.kt b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/deserializeLazyDeclarations.kt index bc21d47a0a7..a238140a3f2 100644 --- a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/deserializeLazyDeclarations.kt +++ b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/deserializeLazyDeclarations.kt @@ -29,7 +29,11 @@ import org.jetbrains.kotlin.ir.types.IrTypeSystemContext import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid -import org.jetbrains.kotlin.protobuf.ByteString +import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature as ProtoIdSignature +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoDeclaration +import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement +import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoType fun deserializeClassFromByteArray( byteArray: ByteArray, @@ -40,7 +44,7 @@ fun deserializeClassFromByteArray( ) { val irBuiltIns = stubGenerator.irBuiltIns val symbolTable = stubGenerator.symbolTable - val irProto = JvmIr.JvmIrClass.parseFrom(byteArray) + val irProto = JvmIr.JvmIrClass.parseFrom(byteArray.codedInputStream) val irLibraryFile = IrLibraryFileFromAnnotation( irProto.auxTables.typeList, irProto.auxTables.signatureList, @@ -98,7 +102,7 @@ fun deserializeIrFileFromByteArray( ) { val irBuiltIns = stubGenerator.irBuiltIns val symbolTable = stubGenerator.symbolTable - val irProto = JvmIr.JvmIrFile.parseFrom(byteArray) + val irProto = JvmIr.JvmIrFile.parseFrom(byteArray.codedInputStream) val irLibraryFile = IrLibraryFileFromAnnotation( irProto.auxTables.typeList, irProto.auxTables.signatureList, @@ -151,21 +155,26 @@ fun deserializeIrFileFromByteArray( } private class IrLibraryFileFromAnnotation( - private val types: List, - private val signatures: List, - private val strings: List, - private val bodies: List, - private val debugInfo: List + private val types: List, + private val signatures: List, + private val strings: List, + private val bodies: List, + private val debugInfo: List ) : IrLibraryFile() { - override fun irDeclaration(index: Int): ByteArray { + override fun declaration(index: Int): ProtoDeclaration { error("This method is never supposed to be called") } - override fun type(index: Int): ByteArray = types[index].toByteArray() - override fun signature(index: Int): ByteArray = signatures[index].toByteArray() - override fun string(index: Int): ByteArray = strings[index].toByteArray() - override fun body(index: Int): ByteArray = bodies[index].toByteArray() - override fun debugInfo(index: Int): ByteArray = debugInfo[index].toByteArray() + override fun type(index: Int): ProtoType = types[index] + override fun signature(index: Int): ProtoIdSignature = signatures[index] + override fun string(index: Int): String = strings[index] + override fun debugInfo(index: Int): String = debugInfo[index] + + override fun expressionBody(index: Int): ProtoExpression = + bodies[index].also { require(it.hasExpression()) }.expression + + override fun statementBody(index: Int): ProtoStatement = + bodies[index].also { require(it.hasStatement()) }.statement } private fun referencePublicSymbol( diff --git a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/proto/JvmIr.java b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/proto/JvmIr.java index 290a6954fb3..d35d74cef56 100644 --- a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/proto/JvmIr.java +++ b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/proto/JvmIr.java @@ -598,81 +598,96 @@ public final class JvmIr { org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder { /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
      * TODO: optimize the representation.
      * 
*/ - java.util.List getTypeList(); + java.util.List + getTypeList(); /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+     * TODO: optimize the representation.
+     * 
+ */ + org.jetbrains.kotlin.backend.common.serialization.proto.IrType getType(int index); + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
      * TODO: optimize the representation.
      * 
*/ int getTypeCount(); - /** - * repeated bytes type = 1; - * - *
-     * TODO: optimize the representation.
-     * 
- */ - org.jetbrains.kotlin.protobuf.ByteString getType(int index); /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ - java.util.List getSignatureList(); + java.util.List + getSignatureList(); /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature getSignature(int index); + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ int getSignatureCount(); - /** - * repeated bytes signature = 2; - */ - org.jetbrains.kotlin.protobuf.ByteString getSignature(int index); /** - * repeated bytes string = 3; + * repeated string string = 3; */ - java.util.List getStringList(); + org.jetbrains.kotlin.protobuf.ProtocolStringList + getStringList(); /** - * repeated bytes string = 3; + * repeated string string = 3; */ int getStringCount(); /** - * repeated bytes string = 3; + * repeated string string = 3; */ - org.jetbrains.kotlin.protobuf.ByteString getString(int index); + java.lang.String getString(int index); + /** + * repeated string string = 3; + */ + org.jetbrains.kotlin.protobuf.ByteString + getStringBytes(int index); /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ - java.util.List getBodyList(); + java.util.List + getBodyList(); /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression getBody(int index); + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ int getBodyCount(); - /** - * repeated bytes body = 4; - */ - org.jetbrains.kotlin.protobuf.ByteString getBody(int index); /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - java.util.List getDebugInfoList(); + org.jetbrains.kotlin.protobuf.ProtocolStringList + getDebugInfoList(); /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ int getDebugInfoCount(); /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - org.jetbrains.kotlin.protobuf.ByteString getDebugInfo(int index); + java.lang.String getDebugInfo(int index); + /** + * repeated string debug_info = 5; + */ + org.jetbrains.kotlin.protobuf.ByteString + getDebugInfoBytes(int index); } /** * Protobuf type {@code org.jetbrains.kotlin.backend.jvm.serialization.proto.AuxTables} @@ -726,42 +741,44 @@ public final class JvmIr { } case 10: { if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - type_ = new java.util.ArrayList(); + type_ = new java.util.ArrayList(); mutable_bitField0_ |= 0x00000001; } - type_.add(input.readBytes()); + type_.add(input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IrType.PARSER, extensionRegistry)); break; } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - signature_ = new java.util.ArrayList(); + signature_ = new java.util.ArrayList(); mutable_bitField0_ |= 0x00000002; } - signature_.add(input.readBytes()); + signature_.add(input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature.PARSER, extensionRegistry)); break; } case 26: { + org.jetbrains.kotlin.protobuf.ByteString bs = input.readBytes(); if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - string_ = new java.util.ArrayList(); + string_ = new org.jetbrains.kotlin.protobuf.LazyStringArrayList(); mutable_bitField0_ |= 0x00000004; } - string_.add(input.readBytes()); + string_.add(bs); break; } case 34: { if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - body_ = new java.util.ArrayList(); + body_ = new java.util.ArrayList(); mutable_bitField0_ |= 0x00000008; } - body_.add(input.readBytes()); + body_.add(input.readMessage(org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression.PARSER, extensionRegistry)); break; } case 42: { + org.jetbrains.kotlin.protobuf.ByteString bs = input.readBytes(); if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - debugInfo_ = new java.util.ArrayList(); + debugInfo_ = new org.jetbrains.kotlin.protobuf.LazyStringArrayList(); mutable_bitField0_ |= 0x00000010; } - debugInfo_.add(input.readBytes()); + debugInfo_.add(bs); break; } } @@ -779,13 +796,13 @@ public final class JvmIr { signature_ = java.util.Collections.unmodifiableList(signature_); } if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - string_ = java.util.Collections.unmodifiableList(string_); + string_ = string_.getUnmodifiableView(); } if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { body_ = java.util.Collections.unmodifiableList(body_); } if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - debugInfo_ = java.util.Collections.unmodifiableList(debugInfo_); + debugInfo_ = debugInfo_.getUnmodifiableView(); } try { unknownFieldsCodedOutput.flush(); @@ -813,20 +830,30 @@ public final class JvmIr { } public static final int TYPE_FIELD_NUMBER = 1; - private java.util.List type_; + private java.util.List type_; /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
      * TODO: optimize the representation.
      * 
*/ - public java.util.List - getTypeList() { + public java.util.List getTypeList() { return type_; } /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+     * TODO: optimize the representation.
+     * 
+ */ + public java.util.List + getTypeOrBuilderList() { + return type_; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
      * TODO: optimize the representation.
@@ -836,110 +863,161 @@ public final class JvmIr {
       return type_.size();
     }
     /**
-     * repeated bytes type = 1;
+     * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1;
      *
      * 
      * TODO: optimize the representation.
      * 
*/ - public org.jetbrains.kotlin.protobuf.ByteString getType(int index) { + public org.jetbrains.kotlin.backend.common.serialization.proto.IrType getType(int index) { + return type_.get(index); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+     * TODO: optimize the representation.
+     * 
+ */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeOrBuilder getTypeOrBuilder( + int index) { return type_.get(index); } public static final int SIGNATURE_FIELD_NUMBER = 2; - private java.util.List signature_; + private java.util.List signature_; /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ - public java.util.List - getSignatureList() { + public java.util.List getSignatureList() { return signature_; } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public java.util.List + getSignatureOrBuilderList() { + return signature_; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ public int getSignatureCount() { return signature_.size(); } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ - public org.jetbrains.kotlin.protobuf.ByteString getSignature(int index) { + public org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature getSignature(int index) { + return signature_.get(index); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IdSignatureOrBuilder getSignatureOrBuilder( + int index) { return signature_.get(index); } public static final int STRING_FIELD_NUMBER = 3; - private java.util.List string_; + private org.jetbrains.kotlin.protobuf.LazyStringList string_; /** - * repeated bytes string = 3; + * repeated string string = 3; */ - public java.util.List + public org.jetbrains.kotlin.protobuf.ProtocolStringList getStringList() { return string_; } /** - * repeated bytes string = 3; + * repeated string string = 3; */ public int getStringCount() { return string_.size(); } /** - * repeated bytes string = 3; + * repeated string string = 3; */ - public org.jetbrains.kotlin.protobuf.ByteString getString(int index) { + public java.lang.String getString(int index) { return string_.get(index); } + /** + * repeated string string = 3; + */ + public org.jetbrains.kotlin.protobuf.ByteString + getStringBytes(int index) { + return string_.getByteString(index); + } public static final int BODY_FIELD_NUMBER = 4; - private java.util.List body_; + private java.util.List body_; /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ - public java.util.List - getBodyList() { + public java.util.List getBodyList() { return body_; } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public java.util.List + getBodyOrBuilderList() { + return body_; + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ public int getBodyCount() { return body_.size(); } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ - public org.jetbrains.kotlin.protobuf.ByteString getBody(int index) { + public org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression getBody(int index) { + return body_.get(index); + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpressionOrBuilder getBodyOrBuilder( + int index) { return body_.get(index); } public static final int DEBUG_INFO_FIELD_NUMBER = 5; - private java.util.List debugInfo_; + private org.jetbrains.kotlin.protobuf.LazyStringList debugInfo_; /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - public java.util.List + public org.jetbrains.kotlin.protobuf.ProtocolStringList getDebugInfoList() { return debugInfo_; } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ public int getDebugInfoCount() { return debugInfo_.size(); } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - public org.jetbrains.kotlin.protobuf.ByteString getDebugInfo(int index) { + public java.lang.String getDebugInfo(int index) { return debugInfo_.get(index); } + /** + * repeated string debug_info = 5; + */ + public org.jetbrains.kotlin.protobuf.ByteString + getDebugInfoBytes(int index) { + return debugInfo_.getByteString(index); + } private void initFields() { type_ = java.util.Collections.emptyList(); signature_ = java.util.Collections.emptyList(); - string_ = java.util.Collections.emptyList(); + string_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; body_ = java.util.Collections.emptyList(); - debugInfo_ = java.util.Collections.emptyList(); + debugInfo_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -947,6 +1025,24 @@ public final class JvmIr { if (isInitialized == 1) return true; if (isInitialized == 0) return false; + for (int i = 0; i < getTypeCount(); i++) { + if (!getType(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (int i = 0; i < getSignatureCount(); i++) { + if (!getSignature(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (int i = 0; i < getBodyCount(); i++) { + if (!getBody(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } memoizedIsInitialized = 1; return true; } @@ -955,19 +1051,19 @@ public final class JvmIr { throws java.io.IOException { getSerializedSize(); for (int i = 0; i < type_.size(); i++) { - output.writeBytes(1, type_.get(i)); + output.writeMessage(1, type_.get(i)); } for (int i = 0; i < signature_.size(); i++) { - output.writeBytes(2, signature_.get(i)); + output.writeMessage(2, signature_.get(i)); } for (int i = 0; i < string_.size(); i++) { - output.writeBytes(3, string_.get(i)); + output.writeBytes(3, string_.getByteString(i)); } for (int i = 0; i < body_.size(); i++) { - output.writeBytes(4, body_.get(i)); + output.writeMessage(4, body_.get(i)); } for (int i = 0; i < debugInfo_.size(); i++) { - output.writeBytes(5, debugInfo_.get(i)); + output.writeBytes(5, debugInfo_.getByteString(i)); } output.writeRawBytes(unknownFields); } @@ -978,47 +1074,32 @@ public final class JvmIr { if (size != -1) return size; size = 0; - { - int dataSize = 0; - for (int i = 0; i < type_.size(); i++) { - dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeBytesSizeNoTag(type_.get(i)); - } - size += dataSize; - size += 1 * getTypeList().size(); + for (int i = 0; i < type_.size(); i++) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeMessageSize(1, type_.get(i)); } - { - int dataSize = 0; - for (int i = 0; i < signature_.size(); i++) { - dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeBytesSizeNoTag(signature_.get(i)); - } - size += dataSize; - size += 1 * getSignatureList().size(); + for (int i = 0; i < signature_.size(); i++) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeMessageSize(2, signature_.get(i)); } { int dataSize = 0; for (int i = 0; i < string_.size(); i++) { dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeBytesSizeNoTag(string_.get(i)); + .computeBytesSizeNoTag(string_.getByteString(i)); } size += dataSize; size += 1 * getStringList().size(); } - { - int dataSize = 0; - for (int i = 0; i < body_.size(); i++) { - dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeBytesSizeNoTag(body_.get(i)); - } - size += dataSize; - size += 1 * getBodyList().size(); + for (int i = 0; i < body_.size(); i++) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeMessageSize(4, body_.get(i)); } { int dataSize = 0; for (int i = 0; i < debugInfo_.size(); i++) { dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeBytesSizeNoTag(debugInfo_.get(i)); + .computeBytesSizeNoTag(debugInfo_.getByteString(i)); } size += dataSize; size += 1 * getDebugInfoList().size(); @@ -1121,11 +1202,11 @@ public final class JvmIr { bitField0_ = (bitField0_ & ~0x00000001); signature_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000002); - string_ = java.util.Collections.emptyList(); + string_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000004); body_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000008); - debugInfo_ = java.util.Collections.emptyList(); + debugInfo_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000010); return this; } @@ -1160,7 +1241,7 @@ public final class JvmIr { } result.signature_ = signature_; if (((bitField0_ & 0x00000004) == 0x00000004)) { - string_ = java.util.Collections.unmodifiableList(string_); + string_ = string_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000004); } result.string_ = string_; @@ -1170,7 +1251,7 @@ public final class JvmIr { } result.body_ = body_; if (((bitField0_ & 0x00000010) == 0x00000010)) { - debugInfo_ = java.util.Collections.unmodifiableList(debugInfo_); + debugInfo_ = debugInfo_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000010); } result.debugInfo_ = debugInfo_; @@ -1235,6 +1316,24 @@ public final class JvmIr { } public final boolean isInitialized() { + for (int i = 0; i < getTypeCount(); i++) { + if (!getType(i).isInitialized()) { + + return false; + } + } + for (int i = 0; i < getSignatureCount(); i++) { + if (!getSignature(i).isInitialized()) { + + return false; + } + } + for (int i = 0; i < getBodyCount(); i++) { + if (!getBody(i).isInitialized()) { + + return false; + } + } return true; } @@ -1257,26 +1356,27 @@ public final class JvmIr { } private int bitField0_; - private java.util.List type_ = java.util.Collections.emptyList(); + private java.util.List type_ = + java.util.Collections.emptyList(); private void ensureTypeIsMutable() { if (!((bitField0_ & 0x00000001) == 0x00000001)) { - type_ = new java.util.ArrayList(type_); + type_ = new java.util.ArrayList(type_); bitField0_ |= 0x00000001; } } + /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
        * TODO: optimize the representation.
        * 
*/ - public java.util.List - getTypeList() { + public java.util.List getTypeList() { return java.util.Collections.unmodifiableList(type_); } /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
        * TODO: optimize the representation.
@@ -1286,65 +1386,124 @@ public final class JvmIr {
         return type_.size();
       }
       /**
-       * repeated bytes type = 1;
+       * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1;
        *
        * 
        * TODO: optimize the representation.
        * 
*/ - public org.jetbrains.kotlin.protobuf.ByteString getType(int index) { + public org.jetbrains.kotlin.backend.common.serialization.proto.IrType getType(int index) { return type_.get(index); } /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
        * TODO: optimize the representation.
        * 
*/ public Builder setType( - int index, org.jetbrains.kotlin.protobuf.ByteString value) { + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrType value) { if (value == null) { - throw new NullPointerException(); - } - ensureTypeIsMutable(); + throw new NullPointerException(); + } + ensureTypeIsMutable(); type_.set(index, value); - + return this; } /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
        * TODO: optimize the representation.
        * 
*/ - public Builder addType(org.jetbrains.kotlin.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureTypeIsMutable(); - type_.add(value); - + public Builder setType( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrType.Builder builderForValue) { + ensureTypeIsMutable(); + type_.set(index, builderForValue.build()); + return this; } /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+       * TODO: optimize the representation.
+       * 
+ */ + public Builder addType(org.jetbrains.kotlin.backend.common.serialization.proto.IrType value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypeIsMutable(); + type_.add(value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+       * TODO: optimize the representation.
+       * 
+ */ + public Builder addType( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrType value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypeIsMutable(); + type_.add(index, value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+       * TODO: optimize the representation.
+       * 
+ */ + public Builder addType( + org.jetbrains.kotlin.backend.common.serialization.proto.IrType.Builder builderForValue) { + ensureTypeIsMutable(); + type_.add(builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; + * + *
+       * TODO: optimize the representation.
+       * 
+ */ + public Builder addType( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrType.Builder builderForValue) { + ensureTypeIsMutable(); + type_.add(index, builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
        * TODO: optimize the representation.
        * 
*/ public Builder addAllType( - java.lang.Iterable values) { + java.lang.Iterable values) { ensureTypeIsMutable(); org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( values, type_); - + return this; } /** - * repeated bytes type = 1; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1; * *
        * TODO: optimize the representation.
@@ -1353,113 +1512,186 @@ public final class JvmIr {
       public Builder clearType() {
         type_ = java.util.Collections.emptyList();
         bitField0_ = (bitField0_ & ~0x00000001);
-        
+
+        return this;
+      }
+      /**
+       * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrType type = 1;
+       *
+       * 
+       * TODO: optimize the representation.
+       * 
+ */ + public Builder removeType(int index) { + ensureTypeIsMutable(); + type_.remove(index); + return this; } - private java.util.List signature_ = java.util.Collections.emptyList(); + private java.util.List signature_ = + java.util.Collections.emptyList(); private void ensureSignatureIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - signature_ = new java.util.ArrayList(signature_); + signature_ = new java.util.ArrayList(signature_); bitField0_ |= 0x00000002; } } + /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ - public java.util.List - getSignatureList() { + public java.util.List getSignatureList() { return java.util.Collections.unmodifiableList(signature_); } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ public int getSignatureCount() { return signature_.size(); } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ - public org.jetbrains.kotlin.protobuf.ByteString getSignature(int index) { + public org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature getSignature(int index) { return signature_.get(index); } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ public Builder setSignature( - int index, org.jetbrains.kotlin.protobuf.ByteString value) { + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature value) { if (value == null) { - throw new NullPointerException(); - } - ensureSignatureIsMutable(); + throw new NullPointerException(); + } + ensureSignatureIsMutable(); signature_.set(index, value); - + return this; } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ - public Builder addSignature(org.jetbrains.kotlin.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureSignatureIsMutable(); - signature_.add(value); - + public Builder setSignature( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature.Builder builderForValue) { + ensureSignatureIsMutable(); + signature_.set(index, builderForValue.build()); + return this; } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public Builder addSignature(org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSignatureIsMutable(); + signature_.add(value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public Builder addSignature( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSignatureIsMutable(); + signature_.add(index, value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public Builder addSignature( + org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature.Builder builderForValue) { + ensureSignatureIsMutable(); + signature_.add(builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public Builder addSignature( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature.Builder builderForValue) { + ensureSignatureIsMutable(); + signature_.add(index, builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ public Builder addAllSignature( - java.lang.Iterable values) { + java.lang.Iterable values) { ensureSignatureIsMutable(); org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( values, signature_); - + return this; } /** - * repeated bytes signature = 2; + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; */ public Builder clearSignature() { signature_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000002); - + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature signature = 2; + */ + public Builder removeSignature(int index) { + ensureSignatureIsMutable(); + signature_.remove(index); + return this; } - private java.util.List string_ = java.util.Collections.emptyList(); + private org.jetbrains.kotlin.protobuf.LazyStringList string_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; private void ensureStringIsMutable() { if (!((bitField0_ & 0x00000004) == 0x00000004)) { - string_ = new java.util.ArrayList(string_); + string_ = new org.jetbrains.kotlin.protobuf.LazyStringArrayList(string_); bitField0_ |= 0x00000004; } } /** - * repeated bytes string = 3; + * repeated string string = 3; */ - public java.util.List + public org.jetbrains.kotlin.protobuf.ProtocolStringList getStringList() { - return java.util.Collections.unmodifiableList(string_); + return string_.getUnmodifiableView(); } /** - * repeated bytes string = 3; + * repeated string string = 3; */ public int getStringCount() { return string_.size(); } /** - * repeated bytes string = 3; + * repeated string string = 3; */ - public org.jetbrains.kotlin.protobuf.ByteString getString(int index) { + public java.lang.String getString(int index) { return string_.get(index); } /** - * repeated bytes string = 3; + * repeated string string = 3; + */ + public org.jetbrains.kotlin.protobuf.ByteString + getStringBytes(int index) { + return string_.getByteString(index); + } + /** + * repeated string string = 3; */ public Builder setString( - int index, org.jetbrains.kotlin.protobuf.ByteString value) { + int index, java.lang.String value) { if (value == null) { throw new NullPointerException(); } @@ -1469,9 +1701,10 @@ public final class JvmIr { return this; } /** - * repeated bytes string = 3; + * repeated string string = 3; */ - public Builder addString(org.jetbrains.kotlin.protobuf.ByteString value) { + public Builder addString( + java.lang.String value) { if (value == null) { throw new NullPointerException(); } @@ -1481,10 +1714,10 @@ public final class JvmIr { return this; } /** - * repeated bytes string = 3; + * repeated string string = 3; */ public Builder addAllString( - java.lang.Iterable values) { + java.lang.Iterable values) { ensureStringIsMutable(); org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( values, string_); @@ -1492,118 +1725,191 @@ public final class JvmIr { return this; } /** - * repeated bytes string = 3; + * repeated string string = 3; */ public Builder clearString() { - string_ = java.util.Collections.emptyList(); + string_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000004); return this; } + /** + * repeated string string = 3; + */ + public Builder addStringBytes( + org.jetbrains.kotlin.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStringIsMutable(); + string_.add(value); + + return this; + } - private java.util.List body_ = java.util.Collections.emptyList(); + private java.util.List body_ = + java.util.Collections.emptyList(); private void ensureBodyIsMutable() { if (!((bitField0_ & 0x00000008) == 0x00000008)) { - body_ = new java.util.ArrayList(body_); + body_ = new java.util.ArrayList(body_); bitField0_ |= 0x00000008; } } + /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ - public java.util.List - getBodyList() { + public java.util.List getBodyList() { return java.util.Collections.unmodifiableList(body_); } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ public int getBodyCount() { return body_.size(); } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ - public org.jetbrains.kotlin.protobuf.ByteString getBody(int index) { + public org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression getBody(int index) { return body_.get(index); } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ public Builder setBody( - int index, org.jetbrains.kotlin.protobuf.ByteString value) { + int index, org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression value) { if (value == null) { - throw new NullPointerException(); - } - ensureBodyIsMutable(); + throw new NullPointerException(); + } + ensureBodyIsMutable(); body_.set(index, value); - + return this; } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ - public Builder addBody(org.jetbrains.kotlin.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureBodyIsMutable(); - body_.add(value); - + public Builder setBody( + int index, org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression.Builder builderForValue) { + ensureBodyIsMutable(); + body_.set(index, builderForValue.build()); + return this; } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public Builder addBody(org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBodyIsMutable(); + body_.add(value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public Builder addBody( + int index, org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBodyIsMutable(); + body_.add(index, value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public Builder addBody( + org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression.Builder builderForValue) { + ensureBodyIsMutable(); + body_.add(builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public Builder addBody( + int index, org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr.XStatementOrExpression.Builder builderForValue) { + ensureBodyIsMutable(); + body_.add(index, builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ public Builder addAllBody( - java.lang.Iterable values) { + java.lang.Iterable values) { ensureBodyIsMutable(); org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( values, body_); - + return this; } /** - * repeated bytes body = 4; + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; */ public Builder clearBody() { body_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000008); - + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.jvm.serialization.proto.XStatementOrExpression body = 4; + */ + public Builder removeBody(int index) { + ensureBodyIsMutable(); + body_.remove(index); + return this; } - private java.util.List debugInfo_ = java.util.Collections.emptyList(); + private org.jetbrains.kotlin.protobuf.LazyStringList debugInfo_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; private void ensureDebugInfoIsMutable() { if (!((bitField0_ & 0x00000010) == 0x00000010)) { - debugInfo_ = new java.util.ArrayList(debugInfo_); + debugInfo_ = new org.jetbrains.kotlin.protobuf.LazyStringArrayList(debugInfo_); bitField0_ |= 0x00000010; } } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - public java.util.List + public org.jetbrains.kotlin.protobuf.ProtocolStringList getDebugInfoList() { - return java.util.Collections.unmodifiableList(debugInfo_); + return debugInfo_.getUnmodifiableView(); } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ public int getDebugInfoCount() { return debugInfo_.size(); } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - public org.jetbrains.kotlin.protobuf.ByteString getDebugInfo(int index) { + public java.lang.String getDebugInfo(int index) { return debugInfo_.get(index); } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; + */ + public org.jetbrains.kotlin.protobuf.ByteString + getDebugInfoBytes(int index) { + return debugInfo_.getByteString(index); + } + /** + * repeated string debug_info = 5; */ public Builder setDebugInfo( - int index, org.jetbrains.kotlin.protobuf.ByteString value) { + int index, java.lang.String value) { if (value == null) { throw new NullPointerException(); } @@ -1613,9 +1919,10 @@ public final class JvmIr { return this; } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ - public Builder addDebugInfo(org.jetbrains.kotlin.protobuf.ByteString value) { + public Builder addDebugInfo( + java.lang.String value) { if (value == null) { throw new NullPointerException(); } @@ -1625,10 +1932,10 @@ public final class JvmIr { return this; } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ public Builder addAllDebugInfo( - java.lang.Iterable values) { + java.lang.Iterable values) { ensureDebugInfoIsMutable(); org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( values, debugInfo_); @@ -1636,14 +1943,27 @@ public final class JvmIr { return this; } /** - * repeated bytes debug_info = 5; + * repeated string debug_info = 5; */ public Builder clearDebugInfo() { - debugInfo_ = java.util.Collections.emptyList(); + debugInfo_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000010); return this; } + /** + * repeated string debug_info = 5; + */ + public Builder addDebugInfoBytes( + org.jetbrains.kotlin.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDebugInfoIsMutable(); + debugInfo_.add(value); + + return this; + } // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.jvm.serialization.proto.AuxTables) } @@ -1988,6 +2308,10 @@ public final class JvmIr { return false; } } + if (!getAuxTables().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -2242,6 +2566,10 @@ public final class JvmIr { return false; } } + if (!getAuxTables().isInitialized()) { + + return false; + } return true; } @@ -2835,6 +3163,10 @@ public final class JvmIr { memoizedIsInitialized = 0; return false; } + if (!getAuxTables().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } memoizedIsInitialized = 1; return true; } @@ -3024,6 +3356,10 @@ public final class JvmIr { return false; } + if (!getAuxTables().isInitialized()) { + + return false; + } return true; }