1 19 20 25 26 27 package soot.jimple.toolkits.scalar; 28 import soot.*; 29 import soot.toolkits.scalar.*; 30 import soot.toolkits.graph.*; 31 import soot.jimple.*; 32 import java.util.*; 33 import soot.util.*; 34 35 37 public class SlowAvailableExpressions implements AvailableExpressions 38 { 39 Map unitToPairsAfter; 40 Map unitToPairsBefore; 41 42 Map unitToEquivsAfter; 43 Map unitToEquivsBefore; 44 45 46 public SlowAvailableExpressions(Body b) 47 { 48 SlowAvailableExpressionsAnalysis analysis = 49 new SlowAvailableExpressionsAnalysis(new ExceptionalUnitGraph(b)); 50 51 { 53 unitToPairsAfter = new HashMap(b.getUnits().size() * 2 + 1, 0.7f); 54 unitToPairsBefore = new HashMap(b.getUnits().size() * 2 + 1, 0.7f); 55 unitToEquivsAfter = new HashMap(b.getUnits().size() * 2 + 1, 0.7f); 56 unitToEquivsBefore = new HashMap(b.getUnits().size() * 2 + 1, 0.7f); 57 58 Iterator unitIt = b.getUnits().iterator(); 59 60 while(unitIt.hasNext()) 61 { 62 Unit s = (Unit) unitIt.next(); 63 64 FlowSet set = (FlowSet) analysis.getFlowBefore(s); 65 66 List pairsBefore = new ArrayList(); 67 List pairsAfter = new ArrayList(); 68 69 Chain equivsBefore = new HashChain(); 70 Chain equivsAfter = new HashChain(); 71 72 List setAsList = set.toList(); 73 Iterator si = setAsList.iterator(); 74 while (si.hasNext()) 75 { 76 Value v = (Value)si.next(); 77 Stmt containingStmt = (Stmt)analysis.rhsToContainingStmt.get(v); 78 UnitValueBoxPair p = new UnitValueBoxPair 79 (containingStmt, ((AssignStmt)containingStmt).getRightOpBox()); 80 EquivalentValue ev = new EquivalentValue(v); 81 pairsBefore.add(p); 82 if (!equivsBefore.contains(ev)) 83 equivsBefore.add(ev); 84 } 85 86 unitToPairsBefore.put(s, pairsBefore); 87 unitToEquivsBefore.put(s, equivsBefore); 88 89 set = (FlowSet) analysis.getFlowAfter(s); 90 setAsList = set.toList(); 91 si = setAsList.iterator(); 92 while (si.hasNext()) 93 { 94 Value v = (Value)si.next(); 95 Stmt containingStmt = (Stmt)analysis.rhsToContainingStmt.get(v); 96 UnitValueBoxPair p = new UnitValueBoxPair 97 (containingStmt, ((AssignStmt)containingStmt).getRightOpBox()); 98 EquivalentValue ev = new EquivalentValue(v); 99 pairsAfter.add(p); 100 if (!equivsAfter.contains(ev)) 101 equivsAfter.add(ev); 102 } 103 104 unitToPairsAfter.put(s, pairsAfter); 105 unitToEquivsAfter.put(s, equivsAfter); 106 } 107 } 108 } 109 110 111 public List getAvailablePairsBefore(Unit u) 112 { 113 return (List)unitToPairsBefore.get(u); 114 } 115 116 117 public List getAvailablePairsAfter(Unit u) 118 { 119 return (List)unitToPairsAfter.get(u); 120 } 121 122 123 public Chain getAvailableEquivsBefore(Unit u) 124 { 125 return (Chain)unitToEquivsBefore.get(u); 126 } 127 128 129 public Chain getAvailableEquivsAfter(Unit u) 130 { 131 return (Chain)unitToEquivsAfter.get(u); 132 } 133 } 134 | Popular Tags |