[JVM] Reuse visitNopInsn method in all Fast...Analyzer classes
This commit is contained in:
+6
-2
@@ -103,9 +103,9 @@ abstract class FastAnalyzer<V : Value, I : Interpreter<V>, F : Frame<V>>(
|
||||
}
|
||||
}
|
||||
|
||||
protected fun processControlFlowEdge(current: F, insnNode: AbstractInsnNode, jump: Int) {
|
||||
private fun processControlFlowEdge(current: F, insnNode: AbstractInsnNode, jump: Int, canReuse: Boolean = false) {
|
||||
if (visitControlFlowEdge(insnNode, jump)) {
|
||||
mergeControlFlowEdge(jump, current)
|
||||
mergeControlFlowEdge(jump, current, canReuse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,10 @@ abstract class FastAnalyzer<V : Value, I : Interpreter<V>, F : Frame<V>>(
|
||||
}
|
||||
}
|
||||
|
||||
protected fun visitNopInsn(insnNode: AbstractInsnNode, current: F, insn: Int) {
|
||||
processControlFlowEdge(current, insnNode, insn + 1, canReuse = true)
|
||||
}
|
||||
|
||||
private fun visitOpInsn(insnNode: AbstractInsnNode, current: F, insn: Int) {
|
||||
processControlFlowEdge(current, insnNode, insn + 1)
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ class FastMethodAnalyzer<V : Value>
|
||||
insnType == AbstractInsnNode.FRAME ||
|
||||
insnOpcode == Opcodes.NOP
|
||||
) {
|
||||
mergeControlFlowEdge(insnIndex + 1, currentlyAnalyzing, canReuse = true)
|
||||
visitNopInsn(insnNode, currentlyAnalyzing, insnIndex)
|
||||
} else {
|
||||
current.init(currentlyAnalyzing).execute(insnNode, interpreter)
|
||||
visitMeaningfulInstruction(insnNode, insnType, insnOpcode, current, insnIndex)
|
||||
|
||||
+7
-6
@@ -36,7 +36,8 @@ package org.jetbrains.kotlin.codegen.optimization.fixStack
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.FastAnalyzer
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Value
|
||||
@@ -66,7 +67,11 @@ internal open class FastStackAnalyzer<V : Value, F : Frame<V>>(
|
||||
current: F,
|
||||
handler: F,
|
||||
) {
|
||||
if (insnType == AbstractInsnNode.LABEL || insnType == AbstractInsnNode.LINE || insnType == AbstractInsnNode.FRAME) {
|
||||
if (insnType == AbstractInsnNode.LABEL ||
|
||||
insnType == AbstractInsnNode.LINE ||
|
||||
insnType == AbstractInsnNode.FRAME ||
|
||||
insnOpcode == Opcodes.NOP
|
||||
) {
|
||||
visitNopInsn(insnNode, currentlyAnalyzing, insnIndex)
|
||||
} else {
|
||||
current.init(currentlyAnalyzing)
|
||||
@@ -88,10 +93,6 @@ internal open class FastStackAnalyzer<V : Value, F : Frame<V>>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun visitNopInsn(insnNode: AbstractInsnNode, f: F, insn: Int) {
|
||||
processControlFlowEdge(f, insnNode, insn + 1)
|
||||
}
|
||||
|
||||
override fun mergeControlFlowEdge(dest: Int, frame: F, canReuse: Boolean) {
|
||||
val oldFrame = getFrame(dest)
|
||||
val changes = when {
|
||||
|
||||
+6
-2
@@ -79,8 +79,12 @@ class FastStoreLoadAnalyzer<V : Value>(
|
||||
current: StoreLoadFrame<V>,
|
||||
handler: StoreLoadFrame<V>,
|
||||
) {
|
||||
if (insnType == AbstractInsnNode.LABEL || insnType == AbstractInsnNode.LINE || insnType == AbstractInsnNode.FRAME) {
|
||||
mergeControlFlowEdge(insnIndex + 1, currentlyAnalyzing)
|
||||
if (insnType == AbstractInsnNode.LABEL ||
|
||||
insnType == AbstractInsnNode.LINE ||
|
||||
insnType == AbstractInsnNode.FRAME ||
|
||||
insnOpcode == Opcodes.NOP
|
||||
) {
|
||||
visitNopInsn(insnNode, currentlyAnalyzing, insnIndex)
|
||||
} else {
|
||||
current.init(currentlyAnalyzing).execute(insnNode, interpreter)
|
||||
visitMeaningfulInstruction(insnNode, insnType, insnOpcode, current, insnIndex)
|
||||
|
||||
Reference in New Issue
Block a user