All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.jimple.toolkits.scalar.pre.NotIsolatedAnalysis Maven / Gradle / Ivy

package soot.jimple.toolkits.scalar.pre;

/*-
 * #%L
 * Soot - a J*va Optimization Framework
 * %%
 * Copyright (C) 2002 Florian Loitsch
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 2.1 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import java.util.Map;

import soot.EquivalentValue;
import soot.Unit;
import soot.toolkits.graph.DirectedGraph;
import soot.toolkits.scalar.ArrayPackedSet;
import soot.toolkits.scalar.BackwardFlowAnalysis;
import soot.toolkits.scalar.BoundedFlowSet;
import soot.toolkits.scalar.CollectionFlowUniverse;
import soot.toolkits.scalar.FlowSet;

/**
 * Performs a Not-Isolated-analysis on the given graph, which is basically the same as an Isolated-analysis (we just return
 * the complement, as it's easier to calculate it). A computation is isolated, if it can only be used at the current
 * computation-point. In other words: if the result of the computation will not be used later on the computation is
 * isolated.
* The Latest-analysis helps us in finding isolated computations, as they show us points, where a precedent computation can't * be used anymore. In completely other words: we search the interval "latest"-"computation". a computation in this interval * would not be isolated. */ public class NotIsolatedAnalysis extends BackwardFlowAnalysis> { private LatestComputation unitToLatest; private Map unitToGen; private FlowSet set; /** * Automatically performs the Isolation-analysis on the graph dg using the Latest-computation * latest.
* the equivRhsMap is only here to avoid doing these things again... * * @param dg * a ExceptionalUnitGraph * @param latest * the latest-computation of the same graph. * @param equivRhsMap * the rhs of each unit (if assignment-stmt). */ public NotIsolatedAnalysis(DirectedGraph dg, LatestComputation latest, Map equivRhsMap) { this(dg, latest, equivRhsMap, new ArrayPackedSet(new CollectionFlowUniverse(equivRhsMap.values()))); } /** * Automatically performs the Isolation-analysis on the graph dg using the Latest-computation * latest.
* the equivRhsMap is only here to avoid doing these things again...
* the shared set allows more efficient set-operations, when this analysis is joined with other analyses/computations. * * @param dg * a ExceptionalUnitGraph * @param latest * the latest-computation of the same graph. * @param equivRhsMap * the rhs of each unit (if assignment-stmt). * @param set * the shared set. */ public NotIsolatedAnalysis(DirectedGraph dg, LatestComputation latest, Map equivRhsMap, BoundedFlowSet set) { super(dg); this.set = set; unitToGen = equivRhsMap; unitToLatest = latest; doAnalysis(); } @Override protected FlowSet newInitialFlow() { return set.emptySet(); } @Override protected FlowSet entryInitialFlow() { return newInitialFlow(); } @Override protected void flowThrough(FlowSet in, Unit unit, FlowSet out) { in.copy(out); // Perform generation EquivalentValue rhs = (EquivalentValue) unitToGen.get(unit); if (rhs != null) { out.add(rhs); } // perform kill FlowSet latest = unitToLatest.getFlowBefore(unit); out.difference(latest); } @Override protected void merge(FlowSet inSet1, FlowSet inSet2, FlowSet outSet) { inSet1.union(inSet2, outSet); } @Override protected void copy(FlowSet sourceSet, FlowSet destSet) { sourceSet.copy(destSet); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy