1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.nabla.forward.trimming;
18
19 import org.objectweb.asm.Opcodes;
20 import org.objectweb.asm.tree.AbstractInsnNode;
21 import org.objectweb.asm.tree.InsnList;
22 import org.objectweb.asm.tree.VarInsnNode;
23
24
25
26
27 public class SwappedDloadTrimmer extends BytecodeTrimmer {
28
29
30
31 public SwappedDloadTrimmer() {
32 super(4);
33 }
34
35
36 @Override
37 protected boolean trimWindow(final InsnList instructions,
38 final AbstractInsnNode[] window) {
39
40 if ((window[0].getOpcode() == Opcodes.DLOAD) &&
41 (window[1].getOpcode() == Opcodes.DLOAD) &&
42 (window[2].getOpcode() == Opcodes.DUP2_X2) &&
43 (window[3].getOpcode() == Opcodes.POP2)) {
44
45
46 final int tmp = ((VarInsnNode) window[0]).var;
47 ((VarInsnNode) window[0]).var = ((VarInsnNode) window[1]).var;
48 ((VarInsnNode) window[1]).var = tmp;
49
50
51 instructions.remove(window[2]);
52 instructions.remove(window[3]);
53
54
55 window[2] = window[1].getNext();
56 window[3] = (window[2] == null) ? null : window[2].getNext();
57 return true;
58
59 }
60
61
62 return false;
63
64 }
65
66 }