soot.toolkits.graph.ExceptionalUnitGraph Java Examples
The following examples show how to use
soot.toolkits.graph.ExceptionalUnitGraph.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DominatorsTagger.java From JAADAS with GNU General Public License v3.0 | 6 votes |
protected void internalTransform( Body b, String phaseName, Map opts) { MHGDominatorsFinder analysis = new MHGDominatorsFinder(new ExceptionalUnitGraph(b)); Iterator it = b.getUnits().iterator(); while (it.hasNext()){ Stmt s = (Stmt)it.next(); List dominators = analysis.getDominators(s); Iterator dIt = dominators.iterator(); while (dIt.hasNext()){ Stmt ds = (Stmt)dIt.next(); String info = ds+" dominates "+s; s.addTag(new LinkTag(info, ds, b.getMethod().getDeclaringClass().getName(), "Dominators")); } } }
Example #2
Source File: SynchronizedMethodTransformer.java From JAADAS with GNU General Public License v3.0 | 6 votes |
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { if (!b.getMethod().isSynchronized() || b.getMethod().isStatic()) return; Iterator<Unit> it = b.getUnits().snapshotIterator(); while (it.hasNext()) { Unit u = it.next(); if (u instanceof IdentityStmt) continue; // This the first real statement. If it is not a MonitorEnter // instruction, we generate one if (!(u instanceof EnterMonitorStmt)) { b.getUnits().insertBeforeNoRedirect(Jimple.v().newEnterMonitorStmt(b.getThisLocal()), u); // We also need to leave the monitor when the method terminates UnitGraph graph = new ExceptionalUnitGraph(b); for (Unit tail : graph.getTails()) b.getUnits().insertBefore(Jimple.v().newExitMonitorStmt(b.getThisLocal()), tail); } break; } }
Example #3
Source File: ContextSensitiveJimpleRepresentation.java From vasco with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns an {@link ExceptionalUnitGraph} for a given method. */ @Override public DirectedGraph<Unit> getControlFlowGraph(MethodOrMethodContext momc) { if (cfgCache.containsKey(momc.method()) == false) { cfgCache.put(momc.method(), new ExceptionalUnitGraph(momc.method().getActiveBody())); } return cfgCache.get(momc.method()); }
Example #4
Source File: VeryBusyExpsTagger.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Adds <code>StringTag</code>s and <code>ColorTag</code>s to the body * in the interest of using Eclipse to relay information to the user.<br/> * Every unit that has a busy expression flowing out of it, gets a * <code>StringTag</code> describing that fact (per expression). * If an expression that is busy out of that unit is also used within * it, then we add a <code>ColorTag</code> to that expression. * @param b the body to transform * @param phaseName the name of the phase this transform belongs to * @param options any options to this transform (in this case always empty) */ protected void internalTransform(Body b, String phaseName, Map options) { VeryBusyExpressions vbe = new SimpleVeryBusyExpressions(new ExceptionalUnitGraph(b)); for (Unit u : b.getUnits()) { for (Value v : vbe.getBusyExpressionsAfter(u)) { u.addTag(new StringTag("Busy expression: " + v, TAG_TYPE)); for (ValueBox use : u.getUseBoxes()) { if (use.getValue().equivTo(v)) use.addTag(new ColorTag(ColorTag.RED, TAG_TYPE)); } } } }
Example #5
Source File: RemoveRedundantPushStores.java From JAADAS with GNU General Public License v3.0 | 5 votes |
protected void internalTransform(Body b, String phaseName, Map<String,String> options) { // removes all redundant load-stores boolean changed = true; PatchingChain<Unit> units = b.getUnits(); while (changed) { changed = false; Unit prevprevprev = null, prevprev = null, prev = null; ExceptionalUnitGraph eug = new ExceptionalUnitGraph(b); Iterator<Unit> it = units.snapshotIterator(); while (it.hasNext()) { Unit u = it.next(); if (prev != null && prev instanceof PushInst && u instanceof StoreInst) { if (prevprev != null && prevprev instanceof StoreInst && prevprevprev != null && prevprevprev instanceof PushInst) { Local lprev = ((StoreInst)prevprev).getLocal(); Local l = ((StoreInst)u).getLocal(); if (l == lprev && eug.getSuccsOf(prevprevprev).size() == 1 && eug.getSuccsOf(prevprev).size() == 1) { fixJumps(prevprevprev, prev, b.getTraps()); fixJumps(prevprev, u, b.getTraps()); units.remove(prevprevprev); units.remove(prevprev); changed = true; break; } } } prevprevprev = prevprev; prevprev = prev; prev = u; } } // end while changes have been made }
Example #6
Source File: DefaultJimpleRepresentation.java From vasco with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns an {@link ExceptionalUnitGraph} for a given method. */ @Override public DirectedGraph<Unit> getControlFlowGraph(SootMethod method) { if (cfgCache.containsKey(method) == false) { cfgCache.put(method, new ExceptionalUnitGraph(method.getActiveBody())); } return cfgCache.get(method); }
Example #7
Source File: NullCheckEliminator.java From JAADAS with GNU General Public License v3.0 | 5 votes |
public void internalTransform(Body body, String phaseName, Map<String,String> options) { // really, the analysis should be able to use its own results to determine // that some branches are dead, but since it doesn't we just iterate. boolean changed; do { changed=false; NullnessAnalysis analysis=analysisFactory.newAnalysis(new ExceptionalUnitGraph(body)); Chain<Unit> units=body.getUnits(); Stmt s; for(s=(Stmt) units.getFirst();s!=null;s=(Stmt) units.getSuccOf(s)) { if(!(s instanceof IfStmt)) continue; IfStmt is=(IfStmt) s; Value c=is.getCondition(); if(!(c instanceof EqExpr || c instanceof NeExpr)) continue; BinopExpr e=(BinopExpr) c; Immediate i=null; if(e.getOp1() instanceof NullConstant) i=(Immediate) e.getOp2(); if(e.getOp2() instanceof NullConstant) i=(Immediate) e.getOp1(); if(i==null) continue; boolean alwaysNull = analysis.isAlwaysNullBefore(s, i); boolean alwaysNonNull = analysis.isAlwaysNonNullBefore(s, i); int elim=0; // -1 => condition is false, 1 => condition is true if(alwaysNonNull) elim=c instanceof EqExpr ? -1 : 1; if(alwaysNull) elim=c instanceof EqExpr ? 1 : -1; Stmt newstmt=null; if(elim==-1) newstmt=Jimple.v().newNopStmt(); if(elim==1) newstmt=Jimple.v().newGotoStmt(is.getTarget()); if(newstmt!=null) { units.swapWith(s,newstmt); s=newstmt; changed=true; } } } while(changed); }
Example #8
Source File: BodyTransformer.java From JAADAS with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { PackManager.v().getPack("jtp").add( new Transform("jtp.myTransform", new BodyTransformer() { protected void internalTransform(Body body, String phase, Map options) { new MyAnalysis(new ExceptionalUnitGraph(body)); // use G.v().out instead of System.out so that Soot can // redirect this output to the Eclipse console G.v().out.println(body.getMethod()); } })); soot.Main.main(args); }
Example #9
Source File: SmartLocalDefsPool.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * This method returns a fresh instance of a {@link SmartLocalDefs} analysis, based * on a freshly created {@link ExceptionalUnitGraph} for b, with standard parameters. * If the body b's modification count has not changed since the last time such an analysis * was requested for b, then the previously created analysis is returned instead. * @see Body#getModificationCount() */ public SmartLocalDefs getSmartLocalDefsFor(Body b) { Pair<Long, SmartLocalDefs> modCountAndSLD = pool.get(b); if(modCountAndSLD!=null && modCountAndSLD.o1.longValue() == b.getModificationCount()) { return modCountAndSLD.o2; } else { ExceptionalUnitGraph g = new ExceptionalUnitGraph(b); SmartLocalDefs newSLD = new SmartLocalDefs(g, new SimpleLiveLocals( g )); pool.put(b, new Pair<Long, SmartLocalDefs>(b.getModificationCount(), newSLD)); return newSLD; } }
Example #10
Source File: TrapTightener.java From JAADAS with GNU General Public License v3.0 | 4 votes |
protected void internalTransform(Body body, String phaseName, Map<String, String> options) { if (this.throwAnalysis == null) this.throwAnalysis = Scene.v().getDefaultThrowAnalysis(); if (Options.v().verbose()) G.v().out.println("[" + body.getMethod().getName() + "] Tightening trap boundaries..."); Chain<Trap> trapChain = body.getTraps(); Chain<Unit> unitChain = body.getUnits(); if (trapChain.size() > 0) { ExceptionalUnitGraph graph = new ExceptionalUnitGraph(body, throwAnalysis); Set<Unit> unitsWithMonitor = getUnitsWithMonitor(graph); for (Iterator<Trap> trapIt = trapChain.iterator(); trapIt.hasNext();) { Trap trap = trapIt.next(); boolean isCatchAll = trap.getException().getName().equals("java.lang.Throwable"); Unit firstTrappedUnit = trap.getBeginUnit(); Unit firstTrappedThrower = null; Unit firstUntrappedUnit = trap.getEndUnit(); Unit lastTrappedUnit = unitChain.getPredOf(firstUntrappedUnit); Unit lastTrappedThrower = null; for (Unit u = firstTrappedUnit; u != null && u != firstUntrappedUnit; u = unitChain.getSuccOf(u)) { if (mightThrowTo(graph, u, trap)) { firstTrappedThrower = u; break; } // If this is the catch-all block and the current unit has an, // active monitor, we need to keep the block if (isCatchAll && unitsWithMonitor.contains(u)) break; } if (firstTrappedThrower != null) { for (Unit u = lastTrappedUnit; u != null; u = unitChain.getPredOf(u)) { if (mightThrowTo(graph, u, trap)) { lastTrappedThrower = u; break; } // If this is the catch-all block and the current unit has an, // active monitor, we need to keep the block if (isCatchAll && unitsWithMonitor.contains(u)) break; } } // If no statement inside the trap can throw an exception, we // remove the // complete trap. if (firstTrappedThrower == null) trapIt.remove(); else { if (firstTrappedThrower != null && firstTrappedUnit != firstTrappedThrower) { trap.setBeginUnit(firstTrappedThrower); } if (lastTrappedThrower == null) { lastTrappedThrower = firstTrappedUnit; } if (lastTrappedUnit != lastTrappedThrower) { trap.setEndUnit(unitChain.getSuccOf(lastTrappedThrower)); } } } } }
Example #11
Source File: StringValueAnalysis.java From DroidRA with GNU Lesser General Public License v2.1 | 4 votes |
/** * Returns the string values of a variable used at a given statement. * * @param value The value or variable that should be determined. * @param stmt The statement that uses the variable whose values should be determined. * @return The set of possible values. */ @Override public Set<Object> computeVariableValues(Value value, Stmt stmt) { if (value instanceof StringConstant) { return Collections.singleton((Object) ((StringConstant) value).value.intern()); } else if (value instanceof NullConstant) { return Collections.singleton((Object) "<NULL>"); } else if (value instanceof Local) { Local local = (Local) value; ConstraintCollector constraintCollector = new ConstraintCollector(new ExceptionalUnitGraph(AnalysisParameters.v().getIcfg() .getMethodOf(stmt).getActiveBody())); LanguageConstraints.Box lcb = constraintCollector.getConstraintOfAt(local, stmt); RecursiveDAGSolverVisitorLC dagvlc = new RecursiveDAGSolverVisitorLC(5, null, new RecursiveDAGSolverVisitorLC.MethodReturnValueAnalysisInterface() { @Override public Set<Object> getMethodReturnValues(Call call) { return MethodReturnValueManager.v().getMethodReturnValues(call); } }); if (dagvlc.solve(lcb)) { // boolean flag = false; // if (dagvlc.result.size() == 0 || flag == true) { // System.out.println("ID: " + lcb.uid); // // int dbg = 10; // // while (dbg == 10) { // System.out.println("Returning " + dagvlc.result); // System.out.println("Returning.. " + lcb); // dagvlc.solve(lcb); // System.out.println("done"); // // } // } // System.out.println("Returning " + dagvlc.result); return new HashSet<Object>(dagvlc.result); } else { return Collections.singleton((Object) TOP_VALUE); } } else { return Collections.singleton((Object) TOP_VALUE); } }
Example #12
Source File: BackwardValueAnalysis.java From DroidRA with GNU Lesser General Public License v2.1 | 4 votes |
/** * Returns all assignments for a local variable. This walks the interprocedural control flow graph * back from a statement looking for all assignments to a given local variable. * * @param start The statement where the analysis should start. * @param local The local variable whose assignments should be found. * @param init A boolean that indicates whether the analysis should be initialized. This should * always be true for non-recursive calls. * @param visitedUnits The set of statements visited by the analysis. * @return The set of assignment statements for the local variable. */ protected List<DefinitionStmt> findAssignmentsForLocal(Unit start, Local local, boolean init, Set<Pair<Unit, Local>> visitedUnits) { if (logger.isDebugEnabled()) { logger.debug("Finding assignments for local " + local); } SootMethod method = AnalysisParameters.v().getIcfg().getMethodOf(start); ExceptionalUnitGraph graph = new ExceptionalUnitGraph(method.getActiveBody()); List<DefinitionStmt> result = new ArrayList<DefinitionStmt>(); Stack<Unit> stack = new Stack<Unit>(); stack.push(start); if (init) { visitedUnits.clear(); } while (!stack.empty()) { Unit current = stack.pop(); if (logger.isDebugEnabled()) { logger.debug(current + " " + current.getClass()); } Pair<Unit, Local> pair = new Pair<Unit, Local>(current, local); if (visitedUnits.contains(pair)) { continue; } visitedUnits.add(pair); if (current instanceof IdentityStmt) { IdentityStmt identityStmt = (IdentityStmt) current; // method. if (identityStmt.getLeftOp().equivTo(local)) { result.add(identityStmt); } } else if (current instanceof AssignStmt) { AssignStmt assignStmt = (AssignStmt) current; if (assignStmt.getLeftOp().equivTo(local)) { if (assignStmt.getRightOp() instanceof Local) { result.addAll(findAssignmentsForLocal(current, (Local) assignStmt.getRightOp(), false, visitedUnits)); } else { result.add(assignStmt); } // The assignment generates the local on that path. // Anything before is irrelevant. continue; } } for (Unit pred : graph.getPredsOf(current)) { stack.push(pred); } } return result; }
Example #13
Source File: ObservableDynamicICFG.java From SPDS with Eclipse Public License 2.0 | 4 votes |
private DirectedGraph<Unit> makeGraph(Body body) { return enableExceptions ? new ExceptionalUnitGraph(body, UnitThrowAnalysis.v(), true) : new BriefUnitGraph(body); }
Example #14
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG((ExceptionalUnitGraph) g); }
Example #15
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DirectedGraph buildGraph(Body b) { return new ExceptionalUnitGraph(b); }
Example #16
Source File: RegionAnalysis.java From JAADAS with GNU General Public License v3.0 | 4 votes |
private void findWeakRegions() { /* * Check to see what kind of CFG has been passed in and create * the appropriate block CFG. Note that almost all of the processing * is done on the block CFG. */ if(this.m_cfg instanceof ExceptionalUnitGraph) this.m_blockCFG = new ExceptionalBlockGraph((ExceptionalUnitGraph)this.m_cfg); else if(this.m_cfg instanceof EnhancedUnitGraph) this.m_blockCFG = new EnhancedBlockGraph((EnhancedUnitGraph)this.m_cfg); else if(this.m_cfg instanceof BriefUnitGraph) this.m_blockCFG = new BriefBlockGraph((BriefUnitGraph)this.m_cfg); else throw new RuntimeException("Unsupported CFG passed into the RegionAnalyis constructor!"); this.m_dom = new MHGDominatorTree<Block>(new MHGDominatorsFinder<Block>(this.m_blockCFG)); try{ this.m_pdom = new MHGDominatorTree<Block>(new MHGPostDominatorsFinder<Block>(m_blockCFG)); if(Options.v().verbose()) G.v().out.println("[RegionAnalysis] PostDominator tree: "); this.m_regCount = -1; /* * If a Brief graph or Exceptional graph is used, the CFG might be multi-headed and/or * multi-tailed, which in turn, could result in a post-dominator forest instead of tree. * If the post-dominator tree has multiple heads, the weakRegionDFS does not work correctly * because it is designed based on the assumption that there is an auxiliary STOP node in the * CFG that post-dominates all other nodes. In fact, most of the CFG algorithms augment * the control flow graph with two nodes: ENTRY and EXIT (or START and STOP) nodes. We have * not added these nodes since the CFG here is created from the Jimple code and to be * consistent we'd have to transform the code to reflect these nodes. Instead, we implemted * the EnhancedUnitGraph (EnhancedBlockGraph) which is guaranteed to be single-headed single-tailed. * But note that EnhancedUnitGraph represents exceptional flow differently. * * */ if(this.m_blockCFG.getHeads().size() == 1) { this.m_regCount++; this.m_regions.put(this.m_regCount, this.createRegion(this.m_regCount)); this.weakRegionDFS2(this.m_blockCFG.getHeads().get(0), this.m_regCount); } else if(this.m_blockCFG.getTails().size() == 1) { this.m_regCount++; this.m_regions.put(this.m_regCount, this.createRegion(this.m_regCount)); this.weakRegionDFS(this.m_blockCFG.getTails().get(0), this.m_regCount); } else { if(Options.v().verbose()) G.v().out.println("WARNING: RegionAnalysis: the CFG is multi-headed and tailed, so, the results of this analysis might not be reliable!"); for(int i = 0; i < this.m_blockCFG.getTails().size(); i++) { this.m_regCount++; this.m_regions.put(this.m_regCount, this.createRegion(this.m_regCount)); this.weakRegionDFS(this.m_blockCFG.getTails().get(i), this.m_regCount); } //throw new RuntimeException("RegionAnalysis: cannot properly deal with multi-headed and tailed CFG!"); } } catch(RuntimeException e) { G.v().out.println("[RegionAnalysis] Exception in findWeakRegions: " + e); } }
Example #17
Source File: DexReturnValuePropagator.java From JAADAS with GNU General Public License v3.0 | 4 votes |
@Override protected void internalTransform(Body body, String phaseName, Map<String, String> options) { ExceptionalUnitGraph graph = new ExceptionalUnitGraph(body, DalvikThrowAnalysis.v(), true); LocalDefs localDefs = LocalDefs.Factory.newLocalDefs(graph); LocalUses localUses = null; LocalCreation localCreation = null; // If a return statement's operand has only one definition and this is // a copy statement, we take the original operand for (Unit u : body.getUnits()) if (u instanceof ReturnStmt) { ReturnStmt retStmt = (ReturnStmt) u; if (retStmt.getOp() instanceof Local) { List<Unit> defs = localDefs.getDefsOfAt((Local) retStmt.getOp(), retStmt); if (defs.size() == 1 && defs.get(0) instanceof AssignStmt) { AssignStmt assign = (AssignStmt) defs.get(0); final Value rightOp = assign.getRightOp(); final Value leftOp = assign.getLeftOp(); // Copy over the left side if it is a local if (rightOp instanceof Local) { // We must make sure that the definition we propagate to // the return statement is not overwritten in between // a = 1; b = a; a = 3; return b; may not be translated // to return a; if (!isRedefined((Local) rightOp, u, assign, graph)) retStmt.setOp(rightOp); } else if (rightOp instanceof Constant) { retStmt.setOp(rightOp); } // If this is a field access which has no other uses, // we rename the local to help splitting else if (rightOp instanceof FieldRef) { if (localUses == null) localUses = LocalUses.Factory.newLocalUses(body, localDefs); if (localUses.getUsesOf(assign).size() == 1) { if (localCreation == null) localCreation = new LocalCreation(body.getLocals(), "ret"); Local newLocal = localCreation.newLocal(leftOp.getType()); assign.setLeftOp(newLocal); retStmt.setOp(newLocal); } } } } } }
Example #18
Source File: AbstractJimpleBasedICFG.java From JAADAS with GNU General Public License v3.0 | 4 votes |
protected DirectedGraph<Unit> makeGraph(Body body) { return new ExceptionalUnitGraph(body, UnitThrowAnalysis.v() ,true); }
Example #19
Source File: UnreachableCodeEliminator.java From JAADAS with GNU General Public License v3.0 | 4 votes |
protected void internalTransform(Body body, String phaseName, Map<String,String> options) { if (Options.v().verbose()) { G.v().out.println("[" + body.getMethod().getName() + "] Eliminating unreachable code..."); } // Force a conservative ExceptionalUnitGraph() which // necessarily includes an edge from every trapped Unit to // its handler, so that we retain Traps in the case where // trapped units remain, but the default ThrowAnalysis // says that none of them can throw the caught exception. if (this.throwAnalysis == null) this.throwAnalysis = PhaseOptions.getBoolean(options, "remove-unreachable-traps", true) ? Scene.v().getDefaultThrowAnalysis() : PedanticThrowAnalysis.v(); ExceptionalUnitGraph graph = new ExceptionalUnitGraph(body, throwAnalysis, false); Chain<Unit> units = body.getUnits(); int numPruned = units.size(); Set<Unit> reachable = units.isEmpty() ? Collections.<Unit>emptySet() : reachable(units.getFirst(), graph) ; // Now eliminate empty traps. (and unreachable handlers) // // For the most part, this is an atavism, an an artifact of // pre-ExceptionalUnitGraph code, when the only way for a trap to // become unreachable was if all its trapped units were removed, and // the stmtIt loop did not remove Traps as it removed handler units. // We've left this separate test for empty traps here, even though // most such traps would already have been eliminated by the preceding // loop, because in arbitrary bytecode you could have // handler unit that was still reachable by normal control flow, even // though it no longer trapped any units (though such code is unlikely // to occur in practice, and certainly no in code generated from Java // source. for ( Iterator<Trap> it = body.getTraps().iterator(); it.hasNext(); ) { Trap trap = it.next(); if ( (trap.getBeginUnit() == trap.getEndUnit()) || !reachable.contains(trap.getHandlerUnit()) ) { it.remove(); } } // We must make sure that the end units of all traps which are still // alive are kept in the code for (Trap t : body.getTraps()) if (t.getEndUnit() == body.getUnits().getLast()) reachable.add(t.getEndUnit()); units.retainAll(reachable); numPruned -= units.size(); if (Options.v().verbose()) { G.v().out.println("[" + body.getMethod().getName() + "] Removed " + numPruned + " statements..."); } }
Example #20
Source File: LoopFinder.java From JAADAS with GNU General Public License v3.0 | 4 votes |
protected void internalTransform (Body b, String phaseName, Map options){ g = new ExceptionalUnitGraph(b); MHGDominatorsFinder a = new MHGDominatorsFinder(g); loops = new HashMap<Stmt, List<Stmt>>(); Iterator<Unit> stmtsIt = b.getUnits().iterator(); while (stmtsIt.hasNext()){ Stmt s = (Stmt)stmtsIt.next(); List<Unit> succs = g.getSuccsOf(s); Collection<Unit> dominaters = (Collection<Unit>)a.getDominators(s); ArrayList<Stmt> headers = new ArrayList<Stmt>(); Iterator<Unit> succsIt = succs.iterator(); while (succsIt.hasNext()){ Stmt succ = (Stmt)succsIt.next(); if (dominaters.contains(succ)){ //header succeeds and dominates s, we have a loop headers.add(succ); } } Iterator<Stmt> headersIt = headers.iterator(); while (headersIt.hasNext()){ Stmt header = headersIt.next(); List<Stmt> loopBody = getLoopBodyFor(header, s); // for now just print out loops as sets of stmts //System.out.println("FOUND LOOP: Header: "+header+" Body: "+loopBody); if (loops.containsKey(header)){ // merge bodies List<Stmt> lb1 = loops.get(header); loops.put(header, union(lb1, loopBody)); } else { loops.put(header, loopBody); } } } }
Example #21
Source File: ArrayIndexLivenessAnalysis.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public ArrayIndexLivenessAnalysis(DirectedGraph dg, boolean takeFieldRef, boolean takeArrayRef, boolean takeCSE, boolean takeRectArray) { super(dg); fieldin = takeFieldRef; arrayin = takeArrayRef; csin = takeCSE; rectarray = takeRectArray; if (Options.v().debug()) G.v().out.println("Enter ArrayIndexLivenessAnalysis"); eug = (ExceptionalUnitGraph)dg; retrieveAllArrayLocals(eug.getBody(), fullSet); /* compute gen set, kill set, and condition set */ genOfUnit = new HashMap<Stmt, HashSet<Object>>(eug.size()*2+1); absGenOfUnit = new HashMap<Stmt, HashSet<Value>>(eug.size()*2+1); killOfUnit = new HashMap<Stmt, HashSet<Value>>(eug.size()*2+1); conditionOfGen = new HashMap<Stmt, HashSet<Value>>(eug.size()*2+1); if (fieldin) { localToFieldRef = new HashMap<Object, HashSet<Value>>(); fieldToFieldRef = new HashMap<Object, HashSet<Value>>(); allFieldRefs = new HashSet<Value>(); } if (arrayin) { localToArrayRef = new HashMap(); allArrayRefs = new HashSet(); killArrayRelated = new HashMap<DefinitionStmt, Value>(); killAllArrayRef = new HashMap<DefinitionStmt, Boolean>(); if (rectarray) { multiarraylocals = new HashSet<Local>(); retrieveMultiArrayLocals(eug.getBody(), multiarraylocals); } } if (csin) { localToExpr = new HashMap<Value, HashSet<Value>>(); } getAllRelatedMaps(eug.getBody()); getGenAndKillSet(eug.getBody(), absGenOfUnit, genOfUnit, killOfUnit, conditionOfGen); doAnalysis(); if (Options.v().debug()) G.v().out.println("Leave ArrayIndexLivenessAnalysis"); }
Example #22
Source File: BodyTransformer.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public MyAnalysis(ExceptionalUnitGraph exceptionalUnitGraph) { //doAnalysis(); }
Example #23
Source File: TrapTightener.java From JAADAS with GNU General Public License v3.0 | 3 votes |
/** * A utility routine which determines if a particular {@link Unit} might * throw an exception to a particular {@link Trap}, according to the * information supplied by a particular control flow graph. * * @param g * The control flow graph providing information about exceptions. * @param u * The unit being inquired about. * @param t * The trap being inquired about. * @return <tt>true</tt> if <tt>u</tt> might throw an exception caught by * <tt>t</tt>, according to <tt>g</tt. */ protected boolean mightThrowTo(ExceptionalUnitGraph g, Unit u, Trap t) { for (ExceptionDest dest : g.getExceptionDests(u)) { if (dest.getTrap() == t) { return true; } } return false; }
Example #24
Source File: LocalDefs.java From JAADAS with GNU General Public License v3.0 | 2 votes |
/** * Creates a new LocalDefs analysis based on a {@code ExceptionalUnitGraph} * If you don't trust the input you should set <code>expectUndefined</code> * to <code>true</code> * * @see soot.toolkits.graph.ExceptionalUnitGraph#ExceptionalUnitGraph(Body) * @param body * @param expectUndefinedUses if you expect uses of locals that are undefined * @return a new LocalDefs instance */ public static LocalDefs newLocalDefs(Body body, boolean expectUndefined) { return newLocalDefs(new ExceptionalUnitGraph(body), expectUndefined); }