- Added new constructor with a SDG already built.

- Refactored scanForMod and scanForRef to use a transmitted ModRef instance, so that for instance CAst ModRef implementation can be used.

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2789 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
egeay 2008-05-07 18:25:51 +00:00
parent 0d4183b914
commit 3754daf135
1 changed files with 13 additions and 8 deletions

View File

@ -69,13 +69,20 @@ public class CISlicer {
SDG sdg = new SDG(cg, pa, modRef, dOptions, cOptions, null); SDG sdg = new SDG(cg, pa, modRef, dOptions, cOptions, null);
Map<Statement, Set<PointerKey>> mod = scanForMod(sdg, pa); Map<Statement, Set<PointerKey>> mod = scanForMod(sdg, pa, modRef);
Map<Statement, Set<PointerKey>> ref = scanForRef(sdg, pa); Map<Statement, Set<PointerKey>> ref = scanForRef(sdg, pa, modRef);
depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref)); depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref));
} }
public CISlicer(final SDG sdg, final PointerAnalysis pa, final ModRef modRef) {
Map<Statement, Set<PointerKey>> mod = scanForMod(sdg, pa, modRef);
Map<Statement, Set<PointerKey>> ref = scanForRef(sdg, pa, modRef);
depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref));
}
public Collection<Statement> computeBackwardThinSlice(Statement seed) { public Collection<Statement> computeBackwardThinSlice(Statement seed) {
Collection<Statement> slice = DFS.getReachableNodes(depGraph, Collections.singleton(seed)); Collection<Statement> slice = DFS.getReachableNodes(depGraph, Collections.singleton(seed));
return slice; return slice;
@ -89,18 +96,17 @@ public class CISlicer {
/** /**
* Compute the set of pointer keys each statement mods * Compute the set of pointer keys each statement mods
*/ */
public static Map<Statement, Set<PointerKey>> scanForMod(SDG sdg, PointerAnalysis pa) { public static Map<Statement, Set<PointerKey>> scanForMod(SDG sdg, PointerAnalysis pa, ModRef modRef) {
return scanForMod(sdg, pa, false); return scanForMod(sdg, pa, false, modRef);
} }
/** /**
* Compute the set of pointer keys each statement mods. Be careful to avoid eager PDG construction here! That means .. * Compute the set of pointer keys each statement mods. Be careful to avoid eager PDG construction here! That means ..
* don't iterate over SDG statements! * don't iterate over SDG statements!
*/ */
public static Map<Statement, Set<PointerKey>> scanForMod(SDG sdg, PointerAnalysis pa, boolean ignoreAllocHeapDefs) { public static Map<Statement, Set<PointerKey>> scanForMod(SDG sdg, PointerAnalysis pa, boolean ignoreAllocHeapDefs, ModRef modRef) {
ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel()); ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel());
Map<Statement, Set<PointerKey>> result = HashMapFactory.make(); Map<Statement, Set<PointerKey>> result = HashMapFactory.make();
ModRef modRef = ModRef.make();
for (CGNode n : sdg.getCallGraph()) { for (CGNode n : sdg.getCallGraph()) {
IR ir = n.getIR(); IR ir = n.getIR();
if (ir != null) { if (ir != null) {
@ -123,10 +129,9 @@ public class CISlicer {
* Compute the set of PointerKeys each statement refs.Be careful to avoid eager PDG construction here! That means .. * Compute the set of PointerKeys each statement refs.Be careful to avoid eager PDG construction here! That means ..
* don't iterate over SDG statements! * don't iterate over SDG statements!
*/ */
public static Map<Statement, Set<PointerKey>> scanForRef(SDG sdg, PointerAnalysis pa) { public static Map<Statement, Set<PointerKey>> scanForRef(SDG sdg, PointerAnalysis pa, ModRef modRef) {
ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel()); ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel());
Map<Statement, Set<PointerKey>> result = HashMapFactory.make(); Map<Statement, Set<PointerKey>> result = HashMapFactory.make();
ModRef modRef = ModRef.make();
for (CGNode n : sdg.getCallGraph()) { for (CGNode n : sdg.getCallGraph()) {
IR ir = n.getIR(); IR ir = n.getIR();
if (ir != null) { if (ir != null) {