Removed debug output
This commit is contained in:
+6
-64
@@ -50,9 +50,7 @@ internal class OverriddenFunctionDescriptor(val descriptor: FunctionDescriptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val context: Context) {
|
internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val context: Context) {
|
||||||
val vtableEntries: List<OverriddenFunctionDescriptor> /*by lazy*/ get() {
|
val vtableEntries: List<OverriddenFunctionDescriptor> by lazy {
|
||||||
|
|
||||||
println("VTABLE_ENTRIES class: $classDescriptor")
|
|
||||||
|
|
||||||
assert(!classDescriptor.isInterface)
|
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.
|
// Add all possible (descriptor, overriddenDescriptor) edges for now, redundant will be removed later.
|
||||||
methods.mapTo(newVtableSlots) { OverriddenFunctionDescriptor(it, it) }
|
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) }
|
.filterNot { inheritedVtableSlotsSet.contains(it.descriptor to it.bridgeDirections) }
|
||||||
.distinctBy { it.descriptor to it.bridgeDirections }
|
.distinctBy { it.descriptor to it.bridgeDirections }
|
||||||
.filter { it.descriptor.isOverridable }
|
.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()
|
|
||||||
|
|
||||||
|
inheritedVtableSlots + filteredNewVtableSlots.sortedBy { it.overriddenDescriptor.functionName.localHash.value }
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun vtableIndex(function: FunctionDescriptor): Int {
|
fun vtableIndex(function: FunctionDescriptor): Int {
|
||||||
val target = function.target
|
val bridgeDirections = function.target.bridgeDirectionsTo(function.original)
|
||||||
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 index = vtableEntries.indexOfFirst { it.descriptor == function.original && it.bridgeDirections == bridgeDirections }
|
val index = vtableEntries.indexOfFirst { it.descriptor == function.original && it.bridgeDirections == bridgeDirections }
|
||||||
if (index < 0) throw Error(function.toString() + " not in vtable of " + classDescriptor.toString())
|
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<OverriddenFunctionDescriptor>
|
private val ClassDescriptor.contributedMethodsWithOverridden: List<OverriddenFunctionDescriptor>
|
||||||
@@ -146,26 +104,10 @@ internal class ClassVtablesBuilder(val classDescriptor: ClassDescriptor, val con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val methodTableEntries: List<OverriddenFunctionDescriptor> /*by lazy*/ get() {
|
val methodTableEntries: List<OverriddenFunctionDescriptor> by lazy {
|
||||||
assert(!classDescriptor.isAbstract())
|
assert(!classDescriptor.isAbstract())
|
||||||
|
|
||||||
println("METHOD_TABLE_ENTRIES: class = $this")
|
classDescriptor.contributedMethodsWithOverridden.filter { it.canBeCalledVirtually }
|
||||||
|
|
||||||
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
|
|
||||||
// TODO: probably method table should contain all accessible methods to improve binary compatibility
|
// TODO: probably method table should contain all accessible methods to improve binary compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-2
@@ -338,8 +338,6 @@ private class DeclarationsGeneratorVisitor(override val context: Context) :
|
|||||||
LLVMAddFunction(context.llvmModule, symbolName, llvmFunctionType)!!
|
LLVMAddFunction(context.llvmModule, symbolName, llvmFunctionType)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
println("ZZZ: $descriptor")
|
|
||||||
|
|
||||||
this.functions[descriptor] = FunctionLlvmDeclarations(llvmFunction)
|
this.functions[descriptor] = FunctionLlvmDeclarations(llvmFunction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-14
@@ -122,7 +122,6 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
val fieldsPtr = staticData.placeGlobalConstArray("kfields:$className",
|
val fieldsPtr = staticData.placeGlobalConstArray("kfields:$className",
|
||||||
runtime.fieldTableRecordType, fields)
|
runtime.fieldTableRecordType, fields)
|
||||||
|
|
||||||
println("GEN_TABLES: class = $classDesc")
|
|
||||||
val methods = if (classDesc.isAbstract()) {
|
val methods = if (classDesc.isAbstract()) {
|
||||||
emptyList()
|
emptyList()
|
||||||
} else {
|
} 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")
|
throw AssertionError("Duplicate method table entry: functionName = '$functionName', hash = '${nameSignature.value}', entry1 = $previous, entry2 = $it")
|
||||||
|
|
||||||
// TODO: compile-time resolution limits binary compatibility
|
// TODO: compile-time resolution limits binary compatibility
|
||||||
val implementation = it.implementation
|
val methodEntryPoint = it.implementation.entryPointAddress
|
||||||
println("METHOD_TABLE: function = $functionName")
|
|
||||||
println("METHOD_TABLE: impl = $implementation")
|
|
||||||
val methodEntryPoint = implementation.entryPointAddress
|
|
||||||
MethodTableRecord(nameSignature, methodEntryPoint)
|
MethodTableRecord(nameSignature, methodEntryPoint)
|
||||||
}.sortedBy { it.nameSignature.value }
|
}.sortedBy { it.nameSignature.value }
|
||||||
}
|
}
|
||||||
@@ -159,11 +155,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
typeInfo
|
typeInfo
|
||||||
} else {
|
} else {
|
||||||
// TODO: compile-time resolution limits binary compatibility
|
// TODO: compile-time resolution limits binary compatibility
|
||||||
val vtableEntries = context.getVtableBuilder(classDesc).vtableEntries.map {
|
val vtableEntries = context.getVtableBuilder(classDesc).vtableEntries.map { it.implementation.entryPointAddress }
|
||||||
val implementation = it.implementation
|
|
||||||
println("RAW_VTABLE: impl = $implementation")
|
|
||||||
implementation.entryPointAddress
|
|
||||||
}
|
|
||||||
val vtable = ConstArray(int8TypePtr, vtableEntries)
|
val vtable = ConstArray(int8TypePtr, vtableEntries)
|
||||||
Struct(typeInfo, vtable)
|
Struct(typeInfo, vtable)
|
||||||
}
|
}
|
||||||
@@ -176,10 +168,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
|
|
||||||
internal val OverriddenFunctionDescriptor.implementation: FunctionDescriptor
|
internal val OverriddenFunctionDescriptor.implementation: FunctionDescriptor
|
||||||
get() {
|
get() {
|
||||||
println("IMPLEMENTATION fun: ${descriptor}")
|
|
||||||
println("IMPLEMENTATION overridden: ${overriddenDescriptor}")
|
|
||||||
val target = descriptor.target
|
val target = descriptor.target
|
||||||
println("IMPLEMENTATION target: ${target}")
|
|
||||||
if (!needBridge) return target
|
if (!needBridge) return target
|
||||||
val bridgeOwner = if (!descriptor.kind.isReal
|
val bridgeOwner = if (!descriptor.kind.isReal
|
||||||
&& OverridingUtil.overrides(target, overriddenDescriptor)
|
&& OverridingUtil.overrides(target, overriddenDescriptor)
|
||||||
@@ -188,7 +177,6 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
} else {
|
} else {
|
||||||
descriptor
|
descriptor
|
||||||
}
|
}
|
||||||
println("IMPLEMENTATION owner: ${bridgeOwner}")
|
|
||||||
return context.specialDescriptorsFactory.getBridgeDescriptor(OverriddenFunctionDescriptor(bridgeOwner, overriddenDescriptor))
|
return context.specialDescriptorsFactory.getBridgeDescriptor(OverriddenFunctionDescriptor(bridgeOwner, overriddenDescriptor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -163,13 +163,6 @@ internal class BridgesBuilding(val context: Context) : ClassLoweringPass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildBridge(descriptor: OverriddenFunctionDescriptor, irClass: IrClass) {
|
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 bridgeDescriptor = context.specialDescriptorsFactory.getBridgeDescriptor(descriptor)
|
||||||
val target = descriptor.descriptor.target
|
val target = descriptor.descriptor.target
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user