[IR] Optimize a few hot spots to reduce total CPU time
^KT-61121
This commit is contained in:
+3
-3
@@ -284,11 +284,11 @@ class FakeOverrideBuilder(
|
||||
}
|
||||
|
||||
fun provideFakeOverrides() {
|
||||
val entries = fakeOverrideCandidates.entries
|
||||
val entries = fakeOverrideCandidates.entries.toMutableList()
|
||||
while (entries.isNotEmpty()) {
|
||||
val candidate = entries.last()
|
||||
entries.remove(candidate)
|
||||
val candidate = entries.removeLast()
|
||||
provideFakeOverrides(candidate.key, candidate.value)
|
||||
}
|
||||
fakeOverrideCandidates.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,9 @@ data class File constructor(internal val javaPath: Path) {
|
||||
get() = javaPath.toAbsolutePath().toString()
|
||||
val absoluteFile: File
|
||||
get() = File(absolutePath)
|
||||
val canonicalPath: String
|
||||
get() = javaPath.toFile().canonicalPath
|
||||
val canonicalPath: String by lazy {
|
||||
javaPath.toFile().canonicalPath
|
||||
}
|
||||
val canonicalFile: File
|
||||
get() = File(canonicalPath)
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||
import org.jetbrains.kotlin.library.metadata.*
|
||||
import org.jetbrains.kotlin.library.unresolvedDependencies
|
||||
import org.jetbrains.kotlin.library.hasDependencies
|
||||
import org.jetbrains.kotlin.name.NativeForwardDeclarationKind
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.parentOrNull
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
private val ModuleDescriptorImpl.isStdlibModule
|
||||
get() = (this.klibModuleOrigin as? DeserializedKlibModuleOrigin)?.library?.unresolvedDependencies?.isEmpty() ?: false
|
||||
get() = (this.klibModuleOrigin as? DeserializedKlibModuleOrigin)?.library?.let { !it.hasDependencies } ?: false
|
||||
|
||||
class KlibMetadataModuleDescriptorFactoryImpl(
|
||||
override val descriptorFactory: KlibModuleDescriptorFactory,
|
||||
|
||||
+14
-9
@@ -91,18 +91,23 @@ class KlibResolvedModuleDescriptorsFactoryImpl(
|
||||
)
|
||||
|
||||
// Set inter-dependencies between module descriptors, add forwarding declarations module.
|
||||
val additionalDependencyModulesCopy = additionalDependencyModules.toSet()
|
||||
val friendsForNonIncludedModule = additionalDependencyModulesCopy
|
||||
val friendsForIncludedModule = buildSet<ModuleDescriptorImpl> {
|
||||
this += friendsForNonIncludedModule
|
||||
this += friendModuleDescriptors
|
||||
this += refinesModuleDescriptors
|
||||
}
|
||||
val allDependencies = moduleDescriptors + additionalDependencyModulesCopy + forwardDeclarationsModule
|
||||
for (module in moduleDescriptors) {
|
||||
val friends = additionalDependencyModules.toMutableSet()
|
||||
if (module in includedLibraryDescriptors) {
|
||||
friends.addAll(friendModuleDescriptors)
|
||||
friends.addAll(refinesModuleDescriptors)
|
||||
val friends = if (module in includedLibraryDescriptors) {
|
||||
friendsForIncludedModule
|
||||
} else {
|
||||
friendsForNonIncludedModule
|
||||
}
|
||||
|
||||
module.setDependencies(
|
||||
// Yes, just to all of them.
|
||||
moduleDescriptors + additionalDependencyModules + forwardDeclarationsModule,
|
||||
friends
|
||||
)
|
||||
// Yes, just to all of them.
|
||||
module.setDependencies(allDependencies, friends)
|
||||
}
|
||||
|
||||
return KotlinResolvedModuleDescriptors(
|
||||
|
||||
@@ -105,6 +105,9 @@ fun BaseKotlinLibrary.unresolvedDependencies(lenient: Boolean = false): List<Unr
|
||||
manifestProperties.propertyList(KLIB_PROPERTY_DEPENDS, escapeInQuotes = true)
|
||||
.map { UnresolvedLibrary(it, manifestProperties.getProperty("dependency_version_$it"), lenient = lenient) }
|
||||
|
||||
val BaseKotlinLibrary.hasDependencies: Boolean
|
||||
get() = !manifestProperties.getProperty(KLIB_PROPERTY_DEPENDS).isNullOrBlank()
|
||||
|
||||
interface KotlinLibrary : BaseKotlinLibrary, MetadataLibrary, IrLibrary
|
||||
|
||||
// TODO: should we move the below ones to Native?
|
||||
|
||||
Reference in New Issue
Block a user