From 87c46db3d5a8efef3c2665664618099ad98d9c6f Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Wed, 6 Sep 2023 11:47:31 +0200 Subject: [PATCH] [JVM] Drop `getFrame` and `setFrame` methods from `FastAnalyzer` --- .../optimization/common/FastAnalyzer.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastAnalyzer.kt index 50644a2a981..a610593ccc8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastAnalyzer.kt @@ -60,7 +60,8 @@ abstract class FastAnalyzer, F : Frame>( while (top > 0) { val insn = queue[--top] - val f = getFrame(insn)!! + @Suppress("UNCHECKED_CAST") + val f = frames[insn] as F queued[insn] = false val insnNode = method.instructions[insn] @@ -123,14 +124,14 @@ abstract class FastAnalyzer, F : Frame>( * If updated, adds the frame to the queue */ private fun mergeControlFlowEdge(dest: Int, frame: F, canReuse: Boolean = false) { - val oldFrame = getFrame(dest) + val oldFrame = frames[dest] val changes = when { canReuse && !isMergeNode[dest] -> { - setFrame(dest, frame) + frames[dest] = frame true } oldFrame == null -> { - setFrame(dest, newFrame(frame.locals, frame.maxStackSize).apply { init(frame) }) + frames[dest] = newFrame(frame.locals, frame.maxStackSize).apply { init(frame) } true } !isMergeNode[dest] -> { @@ -201,13 +202,6 @@ abstract class FastAnalyzer, F : Frame>( @Suppress("UNCHECKED_CAST") protected fun getFrame(insn: AbstractInsnNode): F? = frames[insn.indexOf()] as? F - @Suppress("UNCHECKED_CAST") - protected fun getFrame(index: Int): F? = frames[index] as? F - - protected fun setFrame(index: Int, newFrame: F) { - frames[index] = newFrame - } - private fun visitMeaningfulInstruction(insnNode: AbstractInsnNode, insnType: Int, insnOpcode: Int, current: F, insn: Int) { when { insnType == AbstractInsnNode.JUMP_INSN -> @@ -301,14 +295,14 @@ abstract class FastAnalyzer, F : Frame>( insnHandlers.add(tcb) } - protected fun updateQueue(changes: Boolean, dest: Int) { + private fun updateQueue(changes: Boolean, dest: Int) { if (changes && !queued[dest]) { queued[dest] = true queue[top++] = dest } } - protected fun F.dump(): String { + private fun Frame.dump(): String { return buildString { append("{\n") append(" locals: [\n")