[JVM] Drop some excess toArray calls on instructions
This commit is contained in:
+1
-1
@@ -82,7 +82,7 @@ class UninitializedStoresProcessor(private val methodNode: MethodNode) {
|
||||
private val isInSpecialMethod = methodNode.name == "<init>" || methodNode.name == "<clinit>"
|
||||
|
||||
fun run() {
|
||||
if (methodNode.instructions.toArray().none { it.opcode == Opcodes.NEW })
|
||||
if (methodNode.instructions.none { it.opcode == Opcodes.NEW })
|
||||
return
|
||||
|
||||
val interpreter = UninitializedNewValueMarkerInterpreter(methodNode.instructions)
|
||||
|
||||
@@ -9,9 +9,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -299,7 +297,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
// Instead of checking for loops precisely, we just check if there are any backward jumps -
|
||||
// that is, a jump from instruction #i to instruction #j where j < i.
|
||||
private fun MethodNode.requiresEmptyStackOnEntry(): Boolean = tryCatchBlocks.isNotEmpty() ||
|
||||
instructions.toArray().any { isBeforeSuspendMarker(it) || isBeforeInlineSuspendMarker(it) || isBackwardsJump(it) }
|
||||
instructions.any { isBeforeSuspendMarker(it) || isBeforeInlineSuspendMarker(it) || isBackwardsJump(it) }
|
||||
|
||||
private fun MethodNode.isBackwardsJump(insn: AbstractInsnNode): Boolean = when (insn) {
|
||||
is JumpInsnNode -> isBackwardsJump(insn, insn.label)
|
||||
|
||||
+1
-2
@@ -41,8 +41,7 @@ class ConstantConditionEliminationMethodTransformer : MethodTransformer() {
|
||||
}
|
||||
|
||||
private fun MethodNode.hasOptimizableConditions(): Boolean {
|
||||
val insns = instructions.toArray()
|
||||
return insns.any { it.isIntJump() } && insns.any { it.isIntConst() }
|
||||
return instructions.any { it.isIntJump() } && instructions.any { it.isIntConst() }
|
||||
}
|
||||
|
||||
private fun AbstractInsnNode.isIntConst() =
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ class RedundantNopsCleanupMethodTransformer : MethodTransformer() {
|
||||
}
|
||||
}
|
||||
|
||||
methodNode.instructions.toArray().filter { localVarLables.contains(it) || it is LineNumberNode }
|
||||
methodNode.instructions.filter { localVarLables.contains(it) || it is LineNumberNode }
|
||||
}
|
||||
|
||||
for (i in 0..specialLabels.size - 2) {
|
||||
|
||||
+1
-2
@@ -37,8 +37,7 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
class RedundantBoxingMethodTransformer(private val generationState: GenerationState) : MethodTransformer() {
|
||||
|
||||
override fun transform(internalClassName: String, node: MethodNode) {
|
||||
val insns = node.instructions.toArray()
|
||||
if (insns.none { it.isBoxing(generationState) || it.isMethodInsnWith(Opcodes.INVOKEINTERFACE) { name == "next" } })
|
||||
if (node.instructions.none { it.isBoxing(generationState) || it.isMethodInsnWith(Opcodes.INVOKEINTERFACE) { name == "next" } })
|
||||
return
|
||||
|
||||
val interpreter = RedundantBoxingInterpreter(node, generationState)
|
||||
|
||||
@@ -175,7 +175,7 @@ private fun VarInsnNode.isSize2LoadStoreOperation() =
|
||||
opcode == LLOAD || opcode == DLOAD || opcode == LSTORE || opcode == DSTORE
|
||||
|
||||
fun MethodNode.remapLocalVariables(remapping: IntArray) {
|
||||
for (insn in instructions.toArray()) {
|
||||
for (insn in instructions) {
|
||||
when (insn) {
|
||||
is VarInsnNode ->
|
||||
insn.`var` = remapping[insn.`var`]
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ class RedundantNullCheckMethodTransformer(private val generationState: Generatio
|
||||
private var changes = false
|
||||
|
||||
fun run(): Boolean {
|
||||
if (methodNode.instructions.toArray().none { it.isOptimizable() }) return false
|
||||
if (methodNode.instructions.none { it.isOptimizable() }) return false
|
||||
|
||||
val nullabilityAssumptions = NullabilityAssumptionsBuilder().injectNullabilityAssumptions()
|
||||
|
||||
@@ -477,7 +477,7 @@ internal fun AbstractInsnNode.isCheckNotNullWithMessage() =
|
||||
}
|
||||
|
||||
fun MethodNode.usesLocalExceptParameterNullCheck(index: Int): Boolean =
|
||||
instructions.toArray().any {
|
||||
instructions.any {
|
||||
it is VarInsnNode && it.opcode == Opcodes.ALOAD && it.`var` == index && !it.isParameterCheckedForNull()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user