Fix DUPn_Xm handling in PopBackwardPropagationTransformer
DUPn_Xm instructions implicitly depend on elements directly under stack top (which are not "copied", but still required). We can't analyze them precisely now, and should skip methods containing these instructions. Fortunately, we didn't generate these instructions under POP before, but with new range check code generation and constant conditions elimination such combination of instructions becomes possible.
This commit is contained in:
+8
@@ -33,9 +33,17 @@ import java.util.*
|
||||
class PopBackwardPropagationTransformer : MethodTransformer() {
|
||||
override fun transform(internalClassName: String, methodNode: MethodNode) {
|
||||
if (!OptimizationMethodVisitor.canBeOptimizedUsingSourceInterpreter(methodNode)) return
|
||||
if (methodNode.instructions.toArray().any { it.isUnsafeStackInsn() }) return
|
||||
Transformer(methodNode).transform()
|
||||
}
|
||||
|
||||
// TODO better stack operations analysis
|
||||
private fun AbstractInsnNode.isUnsafeStackInsn() =
|
||||
opcode == Opcodes.DUP_X1 ||
|
||||
opcode == Opcodes.DUP_X2 ||
|
||||
opcode == Opcodes.DUP2_X1 ||
|
||||
opcode == Opcodes.DUP2_X2
|
||||
|
||||
private class Transformer(val methodNode: MethodNode) {
|
||||
private interface Transformation {
|
||||
fun apply(insn: AbstractInsnNode)
|
||||
|
||||
Reference in New Issue
Block a user