Refactoring + synced vtable for DFG and for bitcode
This commit is contained in:
+12
-7
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.backend.konan.*
|
|||||||
import org.jetbrains.kotlin.backend.konan.irasdescriptors.*
|
import org.jetbrains.kotlin.backend.konan.irasdescriptors.*
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.functionName
|
import org.jetbrains.kotlin.backend.konan.llvm.functionName
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.localHash
|
import org.jetbrains.kotlin.backend.konan.llvm.localHash
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||||
import org.jetbrains.kotlin.ir.util.simpleFunctions
|
import org.jetbrains.kotlin.ir.util.simpleFunctions
|
||||||
|
|
||||||
@@ -49,15 +50,19 @@ internal class OverriddenFunctionDescriptor(
|
|||||||
&& descriptor.target.overrides(overriddenDescriptor)
|
&& descriptor.target.overrides(overriddenDescriptor)
|
||||||
&& descriptor.bridgeDirectionsTo(overriddenDescriptor).allNotNeeded()
|
&& descriptor.bridgeDirectionsTo(overriddenDescriptor).allNotNeeded()
|
||||||
|
|
||||||
fun getImplementation(context: Context): SimpleFunctionDescriptor {
|
fun getImplementation(context: Context): SimpleFunctionDescriptor? {
|
||||||
val target = descriptor.target
|
val target = descriptor.target
|
||||||
if (!needBridge) return target
|
val implementation = if (!needBridge)
|
||||||
val bridgeOwner = if (inheritsBridge) {
|
target
|
||||||
target // Bridge is inherited from superclass.
|
else {
|
||||||
} else {
|
val bridgeOwner = if (inheritsBridge) {
|
||||||
descriptor
|
target // Bridge is inherited from superclass.
|
||||||
|
} else {
|
||||||
|
descriptor
|
||||||
|
}
|
||||||
|
context.specialDeclarationsFactory.getBridgeDescriptor(OverriddenFunctionDescriptor(bridgeOwner, overriddenDescriptor))
|
||||||
}
|
}
|
||||||
return context.specialDeclarationsFactory.getBridgeDescriptor(OverriddenFunctionDescriptor(bridgeOwner, overriddenDescriptor))
|
return if (implementation.modality == Modality.ABSTRACT) null else implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
|||||||
+2
-6
@@ -200,7 +200,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
// 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 {
|
||||||
val implementation = it.implementation
|
val implementation = it.implementation
|
||||||
if (implementation.isExternalObjCClassMethod() || implementation.modality == Modality.ABSTRACT) {
|
if (implementation == null || implementation.isExternalObjCClassMethod()) {
|
||||||
NullPointer(int8Type)
|
NullPointer(int8Type)
|
||||||
} else {
|
} else {
|
||||||
implementation.entryPointAddress
|
implementation.entryPointAddress
|
||||||
@@ -220,11 +220,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
|
|
||||||
// TODO: compile-time resolution limits binary compatibility
|
// TODO: compile-time resolution limits binary compatibility
|
||||||
val implementation = it.implementation
|
val implementation = it.implementation
|
||||||
val methodEntryPoint = if (implementation.modality == Modality.ABSTRACT) {
|
val methodEntryPoint = implementation?.entryPointAddress
|
||||||
null
|
|
||||||
} else {
|
|
||||||
implementation.entryPointAddress
|
|
||||||
}
|
|
||||||
MethodTableRecord(nameSignature, methodEntryPoint)
|
MethodTableRecord(nameSignature, methodEntryPoint)
|
||||||
}.sortedBy { it.nameSignature.value }
|
}.sortedBy { it.nameSignature.value }
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -1178,9 +1178,11 @@ internal object DFGSerializer {
|
|||||||
allTypes.forEach {
|
allTypes.forEach {
|
||||||
println(it)
|
println(it)
|
||||||
println(" SUPER TYPES:")
|
println(" SUPER TYPES:")
|
||||||
it.superTypes.forEach {
|
it.superTypes.forEach { println(" $it") }
|
||||||
println(" $it")
|
println(" VTABLE:")
|
||||||
}
|
it.vtable.forEach { println(" $it") }
|
||||||
|
println(" ITABLE:")
|
||||||
|
it.itable.forEach { t, u -> println(" $t: $u") }
|
||||||
}
|
}
|
||||||
|
|
||||||
functions.forEach {
|
functions.forEach {
|
||||||
|
|||||||
+4
-9
@@ -483,16 +483,11 @@ internal object DataFlowIR {
|
|||||||
Type.Public(name.localHash.value, isFinal, isAbstract, module, symbolTableIndex, takeName { name })
|
Type.Public(name.localHash.value, isFinal, isAbstract, module, symbolTableIndex, takeName { name })
|
||||||
else
|
else
|
||||||
Type.Private(privateTypeIndex++, isFinal, isAbstract, module, symbolTableIndex, takeName { name })
|
Type.Private(privateTypeIndex++, isFinal, isAbstract, module, symbolTableIndex, takeName { name })
|
||||||
if (!descriptor.isInterface) {
|
if (!isAbstract) {
|
||||||
val vtableBuilder = context.getVtableBuilder(descriptor)
|
val vtableBuilder = context.getVtableBuilder(descriptor)
|
||||||
type.vtable += vtableBuilder.vtableEntries.map { mapFunction(it.getImplementation(context)) }
|
type.vtable += vtableBuilder.vtableEntries.map { mapFunction(it.getImplementation(context)!!) }
|
||||||
if (!isAbstract) {
|
vtableBuilder.methodTableEntries.forEach {
|
||||||
vtableBuilder.methodTableEntries.forEach {
|
type.itable[it.overriddenDescriptor.functionName.localHash.value] = mapFunction(it.getImplementation(context)!!)
|
||||||
type.itable.put(
|
|
||||||
it.overriddenDescriptor.functionName.localHash.value,
|
|
||||||
mapFunction(it.getImplementation(context))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
classMap.put(descriptor, type)
|
classMap.put(descriptor, type)
|
||||||
|
|||||||
Reference in New Issue
Block a user