diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/ClassVtablesBuilder.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/ClassVtablesBuilder.kt index 3d81aafd28f..7fa24dcc83f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/ClassVtablesBuilder.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/ClassVtablesBuilder.kt @@ -50,9 +50,7 @@ internal class OverriddenFunctionDescriptor(val descriptor: FunctionDescriptor, } internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val context: Context) { - val vtableEntries: List /*by lazy*/ get() { - - println("VTABLE_ENTRIES class: $classDescriptor") + val vtableEntries: List by lazy { assert(!classDescriptor.isInterface) @@ -75,17 +73,6 @@ internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val con } } - println("VTABLE_ENTRIES inherited vtable:") - inheritedVtableSlots.forEach { - println(" VTABLE_ENTRIES descriptor: ${it.descriptor}") - println(" VTABLE_ENTRIES overriddenDescriptor: ${it.overriddenDescriptor}") - println(" VTABLE_ENTRIES needBridge: ${it.needBridge}") - if (it.needBridge) - println(" VTABLE_ENTRIES bridgeDirections: ${it.bridgeDirections.toString()}") - } - println() - - // Add all possible (descriptor, overriddenDescriptor) edges for now, redundant will be removed later. methods.mapTo(newVtableSlots) { OverriddenFunctionDescriptor(it, it) } @@ -95,44 +82,15 @@ internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val con .filterNot { inheritedVtableSlotsSet.contains(it.descriptor to it.bridgeDirections) } .distinctBy { it.descriptor to it.bridgeDirections } .filter { it.descriptor.isOverridable } - println("VTABLE_ENTRIES new vtable:") - filteredNewVtableSlots.forEach { - println(" VTABLE_ENTRIES descriptor: ${it.descriptor}") - println(" VTABLE_ENTRIES overriddenDescriptor: ${it.overriddenDescriptor}") - println(" VTABLE_ENTRIES needBridge: ${it.needBridge}") - if (it.needBridge) - println(" VTABLE_ENTRIES bridgeDirections: ${it.bridgeDirections.toString()}") - } - println() - - val list = inheritedVtableSlots + filteredNewVtableSlots.sortedBy { it.overriddenDescriptor.functionName.localHash.value } - - println("VTABLE_ENTRIES vtable:") - list.forEach { - println(" VTABLE_ENTRIES descriptor: ${it.descriptor}") - println(" VTABLE_ENTRIES overriddenDescriptor: ${it.overriddenDescriptor}") - println(" VTABLE_ENTRIES needBridge: ${it.needBridge}") - if (it.needBridge) - println(" VTABLE_ENTRIES bridgeDirections: ${it.bridgeDirections.toString()}") - } - println() - println() - - - return list + inheritedVtableSlots + filteredNewVtableSlots.sortedBy { it.overriddenDescriptor.functionName.localHash.value } } fun vtableIndex(function: FunctionDescriptor): Int { - val target = function.target - val bridgeDirections = target.bridgeDirectionsTo(function.original) - println("VTABLE_INDEX function: $function") - println("VTABLE_INDEX original: ${function.original}") - println("VTABLE_INDEX target: ${target}") - println("VTABLE_INDEX bridgeDirections: ${target.bridgeDirectionsTo(function.original).toString()}") + val bridgeDirections = function.target.bridgeDirectionsTo(function.original) val index = vtableEntries.indexOfFirst { it.descriptor == function.original && it.bridgeDirections == bridgeDirections } if (index < 0) throw Error(function.toString() + " not in vtable of " + classDescriptor.toString()) - return index.apply { println("VTABLE_INDEX index: $this"); println() } + return index } private val ClassDescriptor.contributedMethodsWithOverridden: List @@ -146,26 +104,10 @@ internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val con } } - val methodTableEntries: List /*by lazy*/ get() { + val methodTableEntries: List by lazy { assert(!classDescriptor.isAbstract()) - println("METHOD_TABLE_ENTRIES: class = $this") - - val contributedMethodsWithOverridden = classDescriptor.contributedMethodsWithOverridden - println("METHOD_TABLE_ENTRIES: contributed methods") - contributedMethodsWithOverridden.forEach { - println(" METHOD_TABLE_ENTRIES: descriptor = ${it.descriptor}") - println(" METHOD_TABLE_ENTRIES: overriddenDescriptor = ${it.overriddenDescriptor}") - println(" METHOD_TABLE_ENTRIES: overriddenDescriptor.isOverridable = ${it.overriddenDescriptor.isOverridable}") - } - val result = contributedMethodsWithOverridden.filter { it.canBeCalledVirtually } - - println("METHOD_TABLE_ENTRIES: result") - result.forEach { - println(" METHOD_TABLE_ENTRIES: descriptor = ${it.descriptor}") - println(" METHOD_TABLE_ENTRIES: overriddenDescriptor = ${it.overriddenDescriptor}") - } - return result + classDescriptor.contributedMethodsWithOverridden.filter { it.canBeCalledVirtually } // TODO: probably method table should contain all accessible methods to improve binary compatibility } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt index d760fc9527a..4d04a43dbad 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt @@ -338,8 +338,6 @@ private class DeclarationsGeneratorVisitor(override val context: Context) : LLVMAddFunction(context.llvmModule, symbolName, llvmFunctionType)!! } - println("ZZZ: $descriptor") - this.functions[descriptor] = FunctionLlvmDeclarations(llvmFunction) } } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt index b28da83f736..2d5ed88f957 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt @@ -122,7 +122,6 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils { val fieldsPtr = staticData.placeGlobalConstArray("kfields:$className", runtime.fieldTableRecordType, fields) - println("GEN_TABLES: class = $classDesc") val methods = if (classDesc.isAbstract()) { emptyList() } else { @@ -135,10 +134,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils { throw AssertionError("Duplicate method table entry: functionName = '$functionName', hash = '${nameSignature.value}', entry1 = $previous, entry2 = $it") // TODO: compile-time resolution limits binary compatibility - val implementation = it.implementation - println("METHOD_TABLE: function = $functionName") - println("METHOD_TABLE: impl = $implementation") - val methodEntryPoint = implementation.entryPointAddress + val methodEntryPoint = it.implementation.entryPointAddress MethodTableRecord(nameSignature, methodEntryPoint) }.sortedBy { it.nameSignature.value } } @@ -159,11 +155,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils { typeInfo } else { // TODO: compile-time resolution limits binary compatibility - val vtableEntries = context.getVtableBuilder(classDesc).vtableEntries.map { - val implementation = it.implementation - println("RAW_VTABLE: impl = $implementation") - implementation.entryPointAddress - } + val vtableEntries = context.getVtableBuilder(classDesc).vtableEntries.map { it.implementation.entryPointAddress } val vtable = ConstArray(int8TypePtr, vtableEntries) Struct(typeInfo, vtable) } @@ -176,10 +168,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils { internal val OverriddenFunctionDescriptor.implementation: FunctionDescriptor get() { - println("IMPLEMENTATION fun: ${descriptor}") - println("IMPLEMENTATION overridden: ${overriddenDescriptor}") val target = descriptor.target - println("IMPLEMENTATION target: ${target}") if (!needBridge) return target val bridgeOwner = if (!descriptor.kind.isReal && OverridingUtil.overrides(target, overriddenDescriptor) @@ -188,7 +177,6 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils { } else { descriptor } - println("IMPLEMENTATION owner: ${bridgeOwner}") return context.specialDescriptorsFactory.getBridgeDescriptor(OverriddenFunctionDescriptor(bridgeOwner, overriddenDescriptor)) } } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BridgesBuilding.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BridgesBuilding.kt index 4038668fb71..53cdee93a18 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BridgesBuilding.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BridgesBuilding.kt @@ -163,13 +163,6 @@ internal class BridgesBuilding(val context: Context) : ClassLoweringPass { } private fun buildBridge(descriptor: OverriddenFunctionDescriptor, irClass: IrClass) { - - println("BUILD_BRIDGE fun: ${descriptor.descriptor}") - println("BUILD_BRIDGE kind: ${descriptor.descriptor.kind}") - println("BUILD_BRIDGE target: ${descriptor.descriptor.target}") - println("BUILD_BRIDGE overridden: ${descriptor.overriddenDescriptor}") - println() - val bridgeDescriptor = context.specialDescriptorsFactory.getBridgeDescriptor(descriptor) val target = descriptor.descriptor.target