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 45 public class LatestComputation { 46 private Map unitToLatest; 47 48 49 60 public LatestComputation(UnitGraph unitGraph, DelayabilityAnalysis delayed, 61 Map equivRhsMap) { 62 this(unitGraph, delayed, equivRhsMap, new 63 ArrayPackedSet(new CollectionFlowUniverse(equivRhsMap.values()))); 64 } 65 66 80 public LatestComputation(UnitGraph unitGraph, DelayabilityAnalysis delayed, 81 Map equivRhsMap, BoundedFlowSet set) { 82 unitToLatest = new HashMap(unitGraph.size() + 1, 0.7f); 83 84 Iterator unitIt = unitGraph.iterator(); 85 while (unitIt.hasNext()) { 86 87 Unit currentUnit = (Unit)unitIt.next(); 88 89 93 94 FlowSet delaySet = (FlowSet)delayed.getFlowBefore(currentUnit); 95 96 97 FlowSet succCompSet = (FlowSet)set.topSet(); 98 List succList = unitGraph.getSuccsOf(currentUnit); 99 Iterator succIt = succList.iterator(); 100 while(succIt.hasNext()) { 101 Unit successor = (Unit)succIt.next(); 102 succCompSet.intersection((FlowSet)delayed.getFlowBefore(successor), 103 succCompSet); 104 } 105 107 if (equivRhsMap.get(currentUnit) != null) 108 succCompSet.remove(equivRhsMap.get(currentUnit)); 109 110 111 FlowSet latest = (FlowSet)delaySet.emptySet(); 112 delaySet.difference(succCompSet, latest); 113 114 unitToLatest.put(currentUnit, latest); 115 } 116 } 117 118 125 public Object getFlowBefore(Object node) { 126 return unitToLatest.get(node); 127 } 128 } 129 | Popular Tags |