JVM: remove usages of trove4j
#KTI-1135
This commit is contained in:
committed by
Space Team
parent
e0b2f2040b
commit
6a0a64eb6d
@@ -12,7 +12,7 @@ dependencies {
|
||||
api(project(":compiler:serialization"))
|
||||
api(project(":compiler:backend.common.jvm"))
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
compileOnly(libs.guava)
|
||||
}
|
||||
|
||||
@@ -16,18 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import com.google.common.collect.Lists
|
||||
import com.intellij.openapi.util.Trinity
|
||||
import gnu.trove.TObjectIntHashMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import java.util.*
|
||||
|
||||
open class FrameMap : FrameMapBase<DeclarationDescriptor>()
|
||||
|
||||
open class FrameMapBase<T : Any> {
|
||||
private val myVarIndex = TObjectIntHashMap<T>()
|
||||
private val myVarSizes = TObjectIntHashMap<T>()
|
||||
private val myVarIndex = Object2IntOpenHashMap<T>()
|
||||
private val myVarSizes = Object2IntOpenHashMap<T>()
|
||||
var currentSize = 0
|
||||
private set
|
||||
|
||||
@@ -40,10 +37,10 @@ open class FrameMapBase<T : Any> {
|
||||
}
|
||||
|
||||
open fun leave(key: T): Int {
|
||||
val size = myVarSizes.get(key)
|
||||
val size = myVarSizes.getValue(key)
|
||||
currentSize -= size
|
||||
myVarSizes.remove(key)
|
||||
val oldIndex = myVarIndex.remove(key)
|
||||
myVarSizes.removeInt(key)
|
||||
val oldIndex = myVarIndex.removeInt(key)
|
||||
if (oldIndex != currentSize) {
|
||||
throw IllegalStateException("Descriptor can be left only if it is last: $key")
|
||||
}
|
||||
@@ -61,7 +58,7 @@ open class FrameMapBase<T : Any> {
|
||||
}
|
||||
|
||||
open fun getIndex(descriptor: T): Int {
|
||||
return if (myVarIndex.contains(descriptor)) myVarIndex.get(descriptor) else -1
|
||||
return if (myVarIndex.contains(descriptor)) myVarIndex.getInt(descriptor) else -1
|
||||
}
|
||||
|
||||
fun mark(): Mark {
|
||||
@@ -79,16 +76,16 @@ open class FrameMapBase<T : Any> {
|
||||
|
||||
fun dropTo() {
|
||||
val descriptorsToDrop = ArrayList<T>()
|
||||
val iterator = myVarIndex.iterator()
|
||||
val iterator = myVarIndex.object2IntEntrySet().fastIterator()
|
||||
while (iterator.hasNext()) {
|
||||
iterator.advance()
|
||||
if (iterator.value() >= myIndex) {
|
||||
descriptorsToDrop.add(iterator.key())
|
||||
val (key, value) = iterator.next()
|
||||
if (value >= myIndex) {
|
||||
descriptorsToDrop.add(key)
|
||||
}
|
||||
}
|
||||
for (declarationDescriptor in descriptorsToDrop) {
|
||||
myVarIndex.remove(declarationDescriptor)
|
||||
myVarSizes.remove(declarationDescriptor)
|
||||
myVarIndex.removeInt(declarationDescriptor)
|
||||
myVarSizes.removeInt(declarationDescriptor)
|
||||
}
|
||||
currentSize = myIndex
|
||||
}
|
||||
@@ -97,17 +94,17 @@ open class FrameMapBase<T : Any> {
|
||||
override fun toString(): String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
if (myVarIndex.size() != myVarSizes.size()) {
|
||||
if (myVarIndex.size != myVarSizes.size) {
|
||||
return "inconsistent"
|
||||
}
|
||||
|
||||
val descriptors = Lists.newArrayList<Trinity<T, Int, Int>>()
|
||||
val descriptors = mutableListOf<Triple<T, Int, Int>>()
|
||||
|
||||
for (descriptor0 in myVarIndex.keys()) {
|
||||
for (descriptor0 in myVarIndex.keys) {
|
||||
@Suppress("UNCHECKED_CAST") val descriptor = descriptor0 as T
|
||||
val varIndex = myVarIndex.get(descriptor)
|
||||
val varSize = myVarSizes.get(descriptor)
|
||||
descriptors.add(Trinity.create(descriptor, varIndex, varSize))
|
||||
val varIndex = myVarIndex.getInt(descriptor)
|
||||
val varSize = myVarSizes.getInt(descriptor)
|
||||
descriptors.add(Triple(descriptor, varIndex, varSize))
|
||||
}
|
||||
|
||||
descriptors.sortBy { left -> left.second }
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.inline
|
||||
|
||||
import gnu.trove.TIntIntHashMap
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap
|
||||
import org.jetbrains.kotlin.codegen.SourceInfo
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import java.util.*
|
||||
@@ -57,7 +57,7 @@ object SMAPBuilder {
|
||||
}
|
||||
|
||||
class SourceMapCopier(val parent: SourceMapper, private val smap: SMAP, val callSite: SourcePosition? = null) {
|
||||
private val visitedLines = TIntIntHashMap()
|
||||
private val visitedLines = Int2IntOpenHashMap()
|
||||
private var lastVisitedRange: RangeMapping? = null
|
||||
|
||||
fun mapLineNumber(lineNumber: Int): Int {
|
||||
|
||||
+3
-4
@@ -5,11 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.optimization.common
|
||||
|
||||
import gnu.trove.TIntHashSet
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
|
||||
|
||||
class ControlFlowGraph private constructor(private val insns: InsnList) {
|
||||
private val successors: Array<MutableList<Int>> = Array(insns.size()) { ArrayList(2) }
|
||||
private val predecessors: Array<MutableList<Int>> = Array(insns.size()) { ArrayList(2) }
|
||||
@@ -32,7 +31,7 @@ class ControlFlowGraph private constructor(private val insns: InsnList) {
|
||||
private val queue = IntArray(nInsns)
|
||||
private var top = 0
|
||||
|
||||
private val predecessors = Array(nInsns) { TIntHashSet() }
|
||||
private val predecessors = Array(nInsns) { IntOpenHashSet() }
|
||||
|
||||
private val AbstractInsnNode.indexOf get() = instructions.indexOf(this)
|
||||
|
||||
@@ -46,7 +45,7 @@ class ControlFlowGraph private constructor(private val insns: InsnList) {
|
||||
traverseCfg()
|
||||
|
||||
for ((i, preds) in predecessors.withIndex()) {
|
||||
for (pred in preds.toArray()) {
|
||||
for (pred in preds.toIntArray()) {
|
||||
graph.predecessors[i].add(pred)
|
||||
graph.successors[pred].add(i)
|
||||
}
|
||||
|
||||
+3
-4
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.jvm.lower
|
||||
|
||||
import gnu.trove.TObjectIntHashMap
|
||||
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.lower.at
|
||||
@@ -95,14 +94,14 @@ private class EnumClassLowering(private val context: JvmBackendContext) : ClassL
|
||||
private inner class EnumClassTransformer(private val irClass: IrClass, private val supportsEnumEntries: Boolean) {
|
||||
private val loweredEnumConstructors = hashMapOf<IrConstructorSymbol, IrConstructor>()
|
||||
private val loweredEnumConstructorParameters = hashMapOf<IrValueParameterSymbol, IrValueParameter>()
|
||||
private val enumEntryOrdinals = TObjectIntHashMap<IrEnumEntry>()
|
||||
private val enumEntryOrdinals = hashMapOf<IrEnumEntry, Int>()
|
||||
private val declarationToEnumEntry = mutableMapOf<IrDeclaration, IrEnumEntry>()
|
||||
private val enumArrayType = context.irBuiltIns.arrayClass.typeWith(irClass.defaultType) // Enum[]
|
||||
|
||||
fun run() {
|
||||
// Lower IrEnumEntry into IrField and IrClass members
|
||||
irClass.declarations.asSequence().filterIsInstance<IrEnumEntry>().withIndex().forEach { (index, enumEntry) ->
|
||||
enumEntryOrdinals.put(enumEntry, index)
|
||||
enumEntryOrdinals[enumEntry] = index
|
||||
enumEntry.correspondingClass?.let { entryClass -> declarationToEnumEntry[entryClass] = enumEntry }
|
||||
declarationToEnumEntry[buildEnumEntryField(enumEntry)] = enumEntry
|
||||
}
|
||||
@@ -307,7 +306,7 @@ private class EnumClassLowering(private val context: JvmBackendContext) : ClassL
|
||||
call.copyTypeArgumentsFrom(original)
|
||||
if (enumEntry != null) {
|
||||
call.putValueArgument(0, irString(enumEntry.name.asString()))
|
||||
call.putValueArgument(1, irInt(enumEntryOrdinals[enumEntry]))
|
||||
call.putValueArgument(1, irInt(enumEntryOrdinals[enumEntry]!!))
|
||||
} else {
|
||||
val constructor = currentScope!!.scope.scopeOwnerSymbol as IrConstructorSymbol
|
||||
call.putValueArgument(0, irGet(constructor.owner.valueParameters[0]))
|
||||
|
||||
@@ -9,9 +9,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
class CodeConformanceTest : TestCase() {
|
||||
companion object {
|
||||
@@ -221,9 +219,6 @@ class CodeConformanceTest : TestCase() {
|
||||
allowedFiles = listOf(
|
||||
"analysis/light-classes-base/src/org/jetbrains/kotlin/asJava/classes/KotlinClassInnerStuffCache.kt",
|
||||
"build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt",
|
||||
"compiler/backend/src/org/jetbrains/kotlin/codegen/FrameMap.kt",
|
||||
"compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt",
|
||||
"compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/ControlFlowGraph.kt",
|
||||
"compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/compiler/CliVirtualFileFinder.kt",
|
||||
"compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt",
|
||||
"compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/index/JvmDependenciesIndexImpl.kt",
|
||||
@@ -231,7 +226,6 @@ class CodeConformanceTest : TestCase() {
|
||||
"compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt",
|
||||
"compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt",
|
||||
"compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PreliminaryLoopVisitor.kt",
|
||||
"compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt",
|
||||
"compiler/psi/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt",
|
||||
"compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt",
|
||||
"compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.kt",
|
||||
|
||||
Reference in New Issue
Block a user