[KLIB] Keep order of constant properties depending on backend

- Fix K/N performance regression
This commit is contained in:
Roman Artemev
2019-12-02 14:37:58 +03:00
committed by romanart
parent 6ef3831f14
commit ca0bff75cd
2 changed files with 8 additions and 2 deletions
@@ -1269,6 +1269,7 @@ open class IrFileSerializer(
open fun backendSpecificExplicitRoot(declaration: IrFunction) = false
open fun backendSpecificExplicitRoot(declaration: IrClass) = false
open fun keepOrderOfProperties(property: IrProperty): Boolean = !property.isConst
fun serializeIrFile(file: IrFile): SerializedIrFile {
val topLevelDeclarations = mutableListOf<SerializedDeclaration>()
@@ -1297,7 +1298,7 @@ open class IrFileSerializer(
// Make sure that all top level properties are initialized on library's load.
file.declarations
.filterIsInstance<IrProperty>()
.filter { it.backingField?.initializer != null }
.filter { it.backingField?.initializer != null && keepOrderOfProperties(it) }
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
// TODO: Konan specific
@@ -8,9 +8,14 @@ package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
import org.jetbrains.kotlin.backend.common.LoggingContext
import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
import org.jetbrains.kotlin.ir.declarations.IrProperty
class JsIrFileSerializer(
logger: LoggingContext,
declarationTable: DeclarationTable,
bodiesOnlyForInlines: Boolean = false
) : IrFileSerializer(logger, declarationTable, bodiesOnlyForInlines)
) : IrFileSerializer(logger, declarationTable, bodiesOnlyForInlines) {
// Temporary keep order of any property, even of constants
override fun keepOrderOfProperties(property: IrProperty): Boolean = true
}