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