Fix exception after combination of while (true) + stack-spilling
FixStack transformation divides on phases: - Fixing stack before break/continue - Fixing stack for inline markers/try-catch blocks After the first stage all ALWAYS_TRUE markers are replaced with simple GOTO's and if we're skipping break/continue edges we won't reach the code after while (true) statement. At the same time it's fine to not to skip them in the second phase as the stack for them is already corrected in the first phase #KT-19475 Fixed
This commit is contained in:
+5
-7
@@ -32,7 +32,8 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
internal class FixStackAnalyzer(
|
||||
owner: String,
|
||||
val method: MethodNode,
|
||||
val context: FixStackContext
|
||||
val context: FixStackContext,
|
||||
private val skipBreakContinueGotoEdges: Boolean = true
|
||||
) {
|
||||
companion object {
|
||||
// Stack size is always non-negative
|
||||
@@ -65,17 +66,14 @@ internal class FixStackAnalyzer(
|
||||
}
|
||||
}
|
||||
|
||||
private val analyzer = InternalAnalyzer(owner, method, context)
|
||||
private val analyzer = InternalAnalyzer(owner)
|
||||
|
||||
private class InternalAnalyzer(
|
||||
owner: String,
|
||||
method: MethodNode,
|
||||
val context: FixStackContext
|
||||
) : MethodAnalyzer<BasicValue>(owner, method, OptimizationBasicInterpreter()) {
|
||||
private inner class InternalAnalyzer(owner: String) : MethodAnalyzer<BasicValue>(owner, method, OptimizationBasicInterpreter()) {
|
||||
val spilledStacks = hashMapOf<AbstractInsnNode, List<BasicValue>>()
|
||||
var maxExtraStackSize = 0; private set
|
||||
|
||||
override fun visitControlFlowEdge(insn: Int, successor: Int): Boolean {
|
||||
if (!skipBreakContinueGotoEdges) return true
|
||||
val insnNode = instructions[insn]
|
||||
return !(insnNode is JumpInsnNode && context.breakContinueGotoNodes.contains(insnNode))
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class FixStackMethodTransformer : MethodTransformer() {
|
||||
}
|
||||
|
||||
private fun analyzeAndTransformSaveRestoreStack(context: FixStackContext, internalClassName: String, methodNode: MethodNode) {
|
||||
val analyzer = FixStackAnalyzer(internalClassName, methodNode, context)
|
||||
val analyzer = FixStackAnalyzer(internalClassName, methodNode, context, skipBreakContinueGotoEdges = false)
|
||||
analyzer.analyze()
|
||||
|
||||
val actions = arrayListOf<() -> Unit>()
|
||||
|
||||
Reference in New Issue
Block a user