diff --git a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationProblem.java b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationProblem.java index cdea96897..bd6e14cfe 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationProblem.java +++ b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationProblem.java @@ -12,8 +12,6 @@ package com.ibm.wala.dataflow.IFDS; import java.util.Collection; -import com.ibm.wala.util.collections.Pair; - /** * * Representation of a Dyck-language graph reachability problem for the @@ -41,10 +39,9 @@ public interface TabulationProblem { public IFlowFunctionMap getFunctionMap(); /** - * Define the set of facts that are live on entry to the analysis. Each fact represents a dataflow - * factoid number (Integer) at a particular supergraph node (T). + * Define the set of path edges to start propagation with. */ - public Collection> initialSeeds(); + public Collection> initialSeeds(); /** * Special case: if supportsMerge(), then the problem is not really IFDS diff --git a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationSolver.java b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationSolver.java index a9ec3818d..bded7eca3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationSolver.java +++ b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/TabulationSolver.java @@ -29,7 +29,6 @@ import com.ibm.wala.util.collections.HashMapFactory; import com.ibm.wala.util.collections.HashSetFactory; import com.ibm.wala.util.collections.Heap; import com.ibm.wala.util.collections.Iterator2Collection; -import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.collections.ToStringComparator; import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.heapTrace.HeapTracer; @@ -188,8 +187,8 @@ public class TabulationSolver { * Start tabulation with the initial seeds. */ protected void initialize() { - for (Pair seed : problem.initialSeeds()) { - propagate(seed.fst, seed.snd, seed.fst, seed.snd); + for (PathEdge seed : problem.initialSeeds()) { + propagate(seed.entry, seed.d1, seed.target, seed.d2); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/MethodEntryStatement.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/MethodEntryStatement.java index b07e08274..f94102ad8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/MethodEntryStatement.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/MethodEntryStatement.java @@ -13,11 +13,12 @@ package com.ibm.wala.ipa.slicer; import com.ibm.wala.ipa.callgraph.CGNode; /** - * A statement representing method entry, used for managing - * control dependence + * A statement representing method entry, used for managing control dependence. + * + * This is also used as a dummy entry for starting propagation to a seed statement. * * @author sjfink - * + * */ public class MethodEntryStatement extends Statement { @@ -31,7 +32,7 @@ public class MethodEntryStatement extends Statement { return false; } if (getClass().equals(obj.getClass())) { - MethodEntryStatement other = (MethodEntryStatement)obj; + MethodEntryStatement other = (MethodEntryStatement) obj; return getNode().equals(other.getNode()); } else { return false; @@ -40,12 +41,12 @@ public class MethodEntryStatement extends Statement { @Override public Kind getKind() { - return Kind.METHOD_ENTRY; + return Kind.METHOD_ENTRY; } @Override public int hashCode() { - return getKind().hashCode() + 9901*getNode().hashCode(); + return getKind().hashCode() + 9901 * getNode().hashCode(); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/PDG.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/PDG.java index 2cc5564b8..1264acd71 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/PDG.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/PDG.java @@ -119,14 +119,11 @@ public class PDG implements NumberedGraph { private boolean isPopulated = false; /** - * @param mod - * the set of heap locations which may be written (transitively) by this node. These are logically return - * values in the SDG. - * @param ref - * the set of heap locations which may be read (transitively) by this node. These are logically parameters - * in the SDG. - * @throws IllegalArgumentException - * if node is null + * @param mod the set of heap locations which may be written (transitively) by this node. These are logically return + * values in the SDG. + * @param ref the set of heap locations which may be read (transitively) by this node. These are logically parameters + * in the SDG. + * @throws IllegalArgumentException if node is null */ public PDG(final CGNode node, PointerAnalysis pa, Map> mod, Map> ref, DataDependenceOptions dOptions, ControlDependenceOptions cOptions, @@ -135,14 +132,11 @@ public class PDG implements NumberedGraph { } /** - * @param mod - * the set of heap locations which may be written (transitively) by this node. These are logically return - * values in the SDG. - * @param ref - * the set of heap locations which may be read (transitively) by this node. These are logically parameters - * in the SDG. - * @throws IllegalArgumentException - * if node is null + * @param mod the set of heap locations which may be written (transitively) by this node. These are logically return + * values in the SDG. + * @param ref the set of heap locations which may be read (transitively) by this node. These are logically parameters + * in the SDG. + * @throws IllegalArgumentException if node is null */ public PDG(final CGNode node, PointerAnalysis pa, Map> mod, Map> ref, DataDependenceOptions dOptions, ControlDependenceOptions cOptions, @@ -448,7 +442,7 @@ public class PDG implements NumberedGraph { Assertions.UNREACHABLE(); } // TODO: this is overly conservative. deal with catch blocks? - for (IntIterator ii = getPEIs(ir).intIterator(); ii.hasNext(); ) { + for (IntIterator ii = getPEIs(ir).intIterator(); ii.hasNext();) { int index = ii.next(); SSAInstruction pei = ir.getInstructions()[index]; if (dOptions.isTerminateAtCast() && (pei instanceof SSACheckCastInstruction)) { @@ -720,7 +714,8 @@ public class PDG implements NumberedGraph { return ssaInstruction2Statement(node, s, instructionIndices); } - public static synchronized Statement ssaInstruction2Statement(CGNode node, SSAInstruction s, Map instructionIndices) { + public static synchronized Statement ssaInstruction2Statement(CGNode node, SSAInstruction s, + Map instructionIndices) { assert s != null; if (s instanceof SSAPhiInstruction) { SSAPhiInstruction phi = (SSAPhiInstruction) s; @@ -800,17 +795,14 @@ public class PDG implements NumberedGraph { createCalleeParams(ref); createReturnStatements(); - if (!cOptions.equals(ControlDependenceOptions.NONE)) { - delegate.addNode(new MethodEntryStatement(node)); - } + delegate.addNode(new MethodEntryStatement(node)); } /** * create nodes representing defs of the return values * - * @param mod - * the set of heap locations which may be written (transitively) by this node. These are logically - * parameters in the SDG. + * @param mod the set of heap locations which may be written (transitively) by this node. These are logically + * parameters in the SDG. * @param dOptions */ private void createReturnStatements() { @@ -839,9 +831,8 @@ public class PDG implements NumberedGraph { /** * create nodes representing defs of formal parameters * - * @param ref - * the set of heap locations which may be read (transitively) by this node. These are logically parameters - * in the SDG. + * @param ref the set of heap locations which may be read (transitively) by this node. These are logically parameters + * in the SDG. */ private void createCalleeParams(Map> ref) { ArrayList list = new ArrayList(); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/SDGSupergraph.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/SDGSupergraph.java index 541a6bb1a..2fb053121 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/SDGSupergraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/SDGSupergraph.java @@ -178,7 +178,7 @@ class SDGSupergraph implements ISupergraph { */ public Statement getMainEntry() { Assertions.productionAssertion(!backward, "todo: support backward"); - return srcStatement; + return new MethodEntryStatement(srcStatement.getNode()); } /* @@ -188,7 +188,7 @@ class SDGSupergraph implements ISupergraph { // We pretend that sink is the "main exit" .. we don't care about // flow past the sink. Assertions.productionAssertion(backward, "todo: support forward"); - return srcStatement; + return new MethodEntryStatement(srcStatement.getNode()); } /* diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/Slicer.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/Slicer.java index 37548e6b3..7b6e3ffa8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/Slicer.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/Slicer.java @@ -18,6 +18,7 @@ import com.ibm.wala.dataflow.IFDS.BackwardsSupergraph; import com.ibm.wala.dataflow.IFDS.IFlowFunctionMap; import com.ibm.wala.dataflow.IFDS.IMergeFunction; import com.ibm.wala.dataflow.IFDS.ISupergraph; +import com.ibm.wala.dataflow.IFDS.PathEdge; import com.ibm.wala.dataflow.IFDS.TabulationDomain; import com.ibm.wala.dataflow.IFDS.TabulationProblem; import com.ibm.wala.dataflow.IFDS.TabulationResult; @@ -28,7 +29,6 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.modref.ModRef; import com.ibm.wala.util.collections.HashSetFactory; import com.ibm.wala.util.collections.Iterator2Collection; -import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.debug.Assertions; /** @@ -419,8 +419,8 @@ public class Slicer { return supergraph; } - public Collection> initialSeeds() { - Pair seed = Pair.make(src, 0); + public Collection> initialSeeds() { + PathEdge seed = PathEdge.createPathEdge(new MethodEntryStatement(src.getNode()), 0, src, 0); return Collections.singleton(seed); } }