a small optimization to eager construction; implement a few more methods

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2378 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2008-01-11 20:19:09 +00:00
parent 0daaa48d6a
commit b9f03da7f6
1 changed files with 20 additions and 10 deletions

View File

@ -114,6 +114,11 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
private final ModRef modRef;
/**
* Have we eagerly populated all nodes of this SDG?
*/
private boolean eagerComputed = false;
public SDG(final CallGraph cg, PointerAnalysis pa, DataDependenceOptions dOptions, ControlDependenceOptions cOptions) {
this(cg, pa, ModRef.make(), dOptions, cOptions, null);
}
@ -155,10 +160,13 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
* force eager construction of the entire SDG
*/
private void eagerConstruction() {
// Assertions.UNREACHABLE();
computeAllPDGs();
for (PDG pdg : pdgMap.values()) {
addPDGStatementNodes(pdg.getCallGraphNode());
// Assertions.UNREACHABLE();
if (!eagerComputed) {
eagerComputed = true;
computeAllPDGs();
for (PDG pdg : pdgMap.values()) {
addPDGStatementNodes(pdg.getCallGraphNode());
}
}
}
@ -194,20 +202,22 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
@Override
public boolean containsNode(Statement N) {
Assertions.UNREACHABLE();
// this may be bad. Are you sure you want to call this?
eagerConstruction();
return super.containsNode(N);
}
@Override
public int getMaxNumber() {
// this may be bad. Are you sure you want to call this?
// this may be bad. Are you sure you want to call this?
eagerConstruction();
return super.getMaxNumber();
}
@Override
public Statement getNode(int number) {
Assertions.UNREACHABLE();
// this may be bad. Are you sure you want to call this?
eagerConstruction();
return super.getNode(number);
}
@ -321,12 +331,12 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
int parameterIndex = pac.getValueNumber() - 1;
Collection<Statement> result = HashSetFactory.make(5);
if (!dOptions.equals(DataDependenceOptions.NONE)) {
if (dOptions.isTerminateAtCast() && !pac.getNode().getMethod().isStatic() && pac.getValueNumber() == 1) {
// a virtual dispatch is just like a cast. No flow.
// a virtual dispatch is just like a cast. No flow.
return EmptyIterator.instance();
}
// data dependence predecessors
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
CGNode caller = it.next();