Sort fields by size (#3597)
This commit is contained in:
+4
-2
@@ -5,10 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.descriptors
|
||||
|
||||
import llvm.LLVMStoreSizeOfType
|
||||
import org.jetbrains.kotlin.backend.common.ir.simpleFunctions
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.functionName
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.llvmType
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.localHash
|
||||
import org.jetbrains.kotlin.backend.konan.lower.bridgeTarget
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
@@ -439,7 +441,7 @@ internal class ClassLayoutBuilder(val irClass: IrClass, val context: Context) {
|
||||
if (irClass.hasAnnotation(FqName.fromSegments(listOf("kotlin", "native", "internal", "NoReorderFields"))))
|
||||
return fields
|
||||
|
||||
return fields.sortedBy { it.fqNameForIrSerialization.localHash.value }
|
||||
return fields.sortedByDescending{ LLVMStoreSizeOfType(context.llvm.runtime.targetData, it.type.llvmType(context)) }
|
||||
}
|
||||
|
||||
private val IrClass.sortedOverridableOrOverridingMethods: List<IrSimpleFunction>
|
||||
@@ -451,4 +453,4 @@ internal class ClassLayoutBuilder(val irClass: IrClass, val context: Context) {
|
||||
private val functionIds = mutableMapOf<IrFunction, Long>()
|
||||
|
||||
private val IrFunction.uniqueId get() = functionIds.getOrPut(this) { functionName.localHash.value }
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -554,6 +554,7 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
|
||||
val llvmInt64 = int64Type
|
||||
val llvmFloat = floatType
|
||||
val llvmDouble = doubleType
|
||||
val llvmVector128 = vector128Type
|
||||
}
|
||||
|
||||
class IrStaticInitializer(val file: IrFile, val initializer: LLVMValueRef)
|
||||
|
||||
+1
@@ -219,6 +219,7 @@ internal fun IrType.llvmType(context:Context): LLVMTypeRef = context.debugInfo.l
|
||||
PrimitiveBinaryType.LONG -> context.llvm.llvmInt64
|
||||
PrimitiveBinaryType.FLOAT -> context.llvm.llvmFloat
|
||||
PrimitiveBinaryType.DOUBLE -> context.llvm.llvmDouble
|
||||
PrimitiveBinaryType.VECTOR128 -> context.llvm.llvmVector128
|
||||
else -> context.debugInfo.otherLlvmType
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user