[K/N] deserialize inline functions for header klibs
For header klibs the indices in the cache for the function bodies are wrong so we instead deserialize the inline functions up-front. ^KT-65443
This commit is contained in:
+4
-1
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.objcinterop.IrObjCOverridabilityCondition
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
|
import org.jetbrains.kotlin.library.isHeader
|
||||||
import org.jetbrains.kotlin.library.metadata.DeserializedKlibModuleOrigin
|
import org.jetbrains.kotlin.library.metadata.DeserializedKlibModuleOrigin
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibModuleOrigin
|
import org.jetbrains.kotlin.library.metadata.KlibModuleOrigin
|
||||||
import org.jetbrains.kotlin.library.metadata.isFromInteropLibrary
|
import org.jetbrains.kotlin.library.metadata.isFromInteropLibrary
|
||||||
@@ -180,7 +181,9 @@ internal fun PsiToIrContext.psiToIr(
|
|||||||
val kotlinLibrary = (dependency.getCapability(KlibModuleOrigin.CAPABILITY) as? DeserializedKlibModuleOrigin)?.library
|
val kotlinLibrary = (dependency.getCapability(KlibModuleOrigin.CAPABILITY) as? DeserializedKlibModuleOrigin)?.library
|
||||||
val isFullyCachedLibrary = kotlinLibrary != null &&
|
val isFullyCachedLibrary = kotlinLibrary != null &&
|
||||||
config.cachedLibraries.isLibraryCached(kotlinLibrary) && kotlinLibrary != config.libraryToCache?.klib
|
config.cachedLibraries.isLibraryCached(kotlinLibrary) && kotlinLibrary != config.libraryToCache?.klib
|
||||||
if (isProducingLibrary || isFullyCachedLibrary)
|
if (isFullyCachedLibrary && kotlinLibrary?.isHeader == true)
|
||||||
|
linker.deserializeHeadersWithInlineBodies(dependency, kotlinLibrary)
|
||||||
|
else if (isProducingLibrary || isFullyCachedLibrary)
|
||||||
linker.deserializeOnlyHeaderModule(dependency, kotlinLibrary)
|
linker.deserializeOnlyHeaderModule(dependency, kotlinLibrary)
|
||||||
else
|
else
|
||||||
linker.deserializeIrModuleHeader(dependency, kotlinLibrary, dependency.name.asString())
|
linker.deserializeIrModuleHeader(dependency, kotlinLibrary, dependency.name.asString())
|
||||||
|
|||||||
+2
-2
@@ -38,7 +38,8 @@ internal class NativeInlineFunctionResolver(override val context: Context, val g
|
|||||||
val packageFragment = function.getPackageFragment()
|
val packageFragment = function.getPackageFragment()
|
||||||
val moduleDeserializer = context.irLinker.getCachedDeclarationModuleDeserializer(function)
|
val moduleDeserializer = context.irLinker.getCachedDeclarationModuleDeserializer(function)
|
||||||
val irFile: IrFile
|
val irFile: IrFile
|
||||||
val (possiblyLoweredFunction, shouldLower) = if (moduleDeserializer != null) {
|
val functionIsCached = moduleDeserializer != null && function.body == null
|
||||||
|
val (possiblyLoweredFunction, shouldLower) = if (functionIsCached) {
|
||||||
// The function is cached, get its body from the IR linker.
|
// The function is cached, get its body from the IR linker.
|
||||||
val (firstAccess, deserializedInlineFunction) = moduleDeserializer.deserializeInlineFunction(function)
|
val (firstAccess, deserializedInlineFunction) = moduleDeserializer.deserializeInlineFunction(function)
|
||||||
generationState.inlineFunctionOrigins[function] = deserializedInlineFunction
|
generationState.inlineFunctionOrigins[function] = deserializedInlineFunction
|
||||||
@@ -57,7 +58,6 @@ internal class NativeInlineFunctionResolver(override val context: Context, val g
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldLower) {
|
if (shouldLower) {
|
||||||
val functionIsCached = moduleDeserializer != null
|
|
||||||
lower(possiblyLoweredFunction, irFile, functionIsCached)
|
lower(possiblyLoweredFunction, irFile, functionIsCached)
|
||||||
if (!functionIsCached) {
|
if (!functionIsCached) {
|
||||||
generationState.inlineFunctionOrigins[function] =
|
generationState.inlineFunctionOrigins[function] =
|
||||||
|
|||||||
Reference in New Issue
Block a user