| 1 19 20 25 26 27 package soot.jimple.toolkits.scalar.pre; 28 import soot.*; 29 import soot.toolkits.scalar.*; 30 import soot.toolkits.graph.*; 31 import soot.jimple.toolkits.scalar.*; 32 import soot.jimple.*; 33 import java.util.*; 34 import soot.util.*; 35 36 44 public class DelayabilityAnalysis extends ForwardFlowAnalysis { 45 private EarliestnessComputation earliest; 46 private Map unitToKillValue; 47 private BoundedFlowSet set; 48 49 52 public DelayabilityAnalysis(DirectedGraph dg) { 53 54 super(dg); 55 throw new RuntimeException ("Don't use this Constructor!"); 56 } 57 58 68 public DelayabilityAnalysis(DirectedGraph dg, EarliestnessComputation 69 earliest, Map equivRhsMap) { 70 this(dg, earliest, equivRhsMap, new 71 ArrayPackedSet(new CollectionFlowUniverse(equivRhsMap.values()))); 72 } 73 74 88 public DelayabilityAnalysis(DirectedGraph dg, EarliestnessComputation 89 earliest, Map equivRhsMap, BoundedFlowSet set) { 90 super(dg); 91 UnitGraph g = (UnitGraph)dg; 92 this.set = set; 93 unitToKillValue = equivRhsMap; 94 this.earliest = earliest; 95 96 doAnalysis(); 97 { Iterator unitIt = g.iterator(); 99 while (unitIt.hasNext()) { 100 Unit currentUnit = (Unit)unitIt.next(); 101 FlowSet beforeSet = (FlowSet)getFlowBefore(currentUnit); 102 beforeSet.union((FlowSet)earliest.getFlowBefore(currentUnit)); 103 } 104 } 105 } 106 107 protected Object newInitialFlow() { 108 return set.topSet(); 109 } 110 111 protected Object entryInitialFlow() { 112 return set.emptySet(); 113 } 114 115 protected void flowThrough(Object inValue, Object unit, Object outValue) { 116 FlowSet in = (FlowSet) inValue, out = (FlowSet) outValue; 117 118 in.copy(out); 119 120 out.union((FlowSet)earliest.getFlowBefore((Unit)unit)); 122 123 { 124 Unit u = (Unit)unit; 125 EquivalentValue equiVal = (EquivalentValue)unitToKillValue.get(u); 126 if (equiVal != null) 127 out.remove(equiVal); 128 } 129 } 130 131 protected void merge(Object in1, Object in2, Object out) { 132 FlowSet inSet1 = (FlowSet) in1; 133 FlowSet inSet2 = (FlowSet) in2; 134 135 FlowSet outSet = (FlowSet) out; 136 137 inSet1.intersection(inSet2, outSet); 138 } 139 140 protected void copy(Object source, Object dest) { 141 FlowSet sourceSet = (FlowSet) source; 142 FlowSet destSet = (FlowSet) dest; 143 144 sourceSet.copy(destSet); 145 } 146 } 147 148 | Popular Tags |