[JVM] Slightly rewrite mergeControlFlowEdge in FastStackAnalyzer

This change is supposed to show how similar
`mergeControlFlowEdge` methods are, and maybe
we should combine them.
This commit is contained in:
Ivan Kylchik
2023-09-05 18:10:29 +02:00
committed by Space Team
parent 6f8e243f0b
commit 0e9d884b0b
@@ -139,12 +139,16 @@ internal open class FastStackAnalyzer<V : Value, F : Frame<V>>(
}
override fun mergeControlFlowEdge(dest: Int, frame: F, canReuse: Boolean) {
val destFrame = getFrame(dest)
if (destFrame == null) {
// Don't have to visit same instruction multiple times - we care only about "initial" stack state.
setFrame(dest, newFrame(frame.locals, frame.maxStackSize).apply { init(frame) })
updateQueue(true, dest)
val oldFrame = getFrame(dest)
val changes = when {
// Don't have to visit the same instruction multiple times - we care only about "initial" stack state.
oldFrame == null -> {
setFrame(dest, newFrame(frame.locals, frame.maxStackSize).apply { init(frame) })
true
}
else -> false
}
updateQueue(changes, dest)
}
}