[KLIB] Keep order of constant properties depending on backend
- Fix K/N performance regression
This commit is contained in:
+2
-1
@@ -1269,6 +1269,7 @@ open class IrFileSerializer(
|
|||||||
|
|
||||||
open fun backendSpecificExplicitRoot(declaration: IrFunction) = false
|
open fun backendSpecificExplicitRoot(declaration: IrFunction) = false
|
||||||
open fun backendSpecificExplicitRoot(declaration: IrClass) = false
|
open fun backendSpecificExplicitRoot(declaration: IrClass) = false
|
||||||
|
open fun keepOrderOfProperties(property: IrProperty): Boolean = !property.isConst
|
||||||
|
|
||||||
fun serializeIrFile(file: IrFile): SerializedIrFile {
|
fun serializeIrFile(file: IrFile): SerializedIrFile {
|
||||||
val topLevelDeclarations = mutableListOf<SerializedDeclaration>()
|
val topLevelDeclarations = mutableListOf<SerializedDeclaration>()
|
||||||
@@ -1297,7 +1298,7 @@ open class IrFileSerializer(
|
|||||||
// Make sure that all top level properties are initialized on library's load.
|
// Make sure that all top level properties are initialized on library's load.
|
||||||
file.declarations
|
file.declarations
|
||||||
.filterIsInstance<IrProperty>()
|
.filterIsInstance<IrProperty>()
|
||||||
.filter { it.backingField?.initializer != null }
|
.filter { it.backingField?.initializer != null && keepOrderOfProperties(it) }
|
||||||
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
|
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
|
||||||
|
|
||||||
// TODO: Konan specific
|
// TODO: Konan specific
|
||||||
|
|||||||
+6
-1
@@ -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.LoggingContext
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer
|
import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
|
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||||
|
|
||||||
class JsIrFileSerializer(
|
class JsIrFileSerializer(
|
||||||
logger: LoggingContext,
|
logger: LoggingContext,
|
||||||
declarationTable: DeclarationTable,
|
declarationTable: DeclarationTable,
|
||||||
bodiesOnlyForInlines: Boolean = false
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user