Update callback APIs to expose path edge structure

This commit is contained in:
Manu Sridharan 2016-08-01 17:11:52 -07:00
parent 57198a22f3
commit 2c9eec0cff
2 changed files with 39 additions and 39 deletions

View File

@ -22,8 +22,8 @@ import com.ibm.wala.util.intset.IntSet;
/**
* Utilities for dealing with tabulation with partially balanced parentheses.
*
* @param <T> type of node in the supergraph
*
* @param <T> type of node in the supergraph
* @param <P> type of a procedure (like a box in an RSM)
* @param <F> type of factoids propagated when solving this problem
*/
@ -61,7 +61,7 @@ public class PartiallyBalancedTabulationSolver<T, P, F> extends TabulationSolver
T fakeEntry = problem.getFakeEntry(retSite);
PathEdge<T> seed = PathEdge.createPathEdge(fakeEntry, d3, retSite, d3);
addSeed(seed);
newReturnExplodedEdge(n, j, retSite, d3);
newUnbalancedExplodedReturnEdge(s_p, i, n, j, seed);
}
}
} else {
@ -89,4 +89,13 @@ public class PartiallyBalancedTabulationSolver<T, P, F> extends TabulationSolver
private boolean wasUsedAsUnbalancedSeed(T s_p, int i) {
return unbalancedSeeds.contains(Pair.make(s_p, i));
}
/**
* A path edge <s_p, i> -> <n, j> was propagated, and <s_p, i> was an unbalanced seed.
* So, we added a new seed callerSeed (to some return site) in the caller. To be overridden
* in subclasses.
*/
protected void newUnbalancedExplodedReturnEdge(T s_p, int i, T n, int j, PathEdge<T> callerSeed) {
}
}

View File

@ -344,8 +344,8 @@ public class TabulationSolver<T, P, F> {
D3.foreach(new IntSetAction() {
@Override
public void act(int d3) {
newNormalExplodedEdge(edge, m, d3);
if (propagate(edge.entry, edge.d1, m, d3)) {
newNormalExplodedEdge(edge.target, edge.d2, m, d3);
}
}
});
@ -508,9 +508,8 @@ public class TabulationSolver<T, P, F> {
public void act(int d3) {
// set curPathEdge to be consistent with its setting in processCall() when applying a summary edge
curPathEdge = PathEdge.createPathEdge(s_p, d3, c, d4);
if (propagate(s_p, d3, retSite, d5)) {
newReturnExplodedEdge(edge.target, edge.d2, retSite, d5);
}
newSummaryEdge(curPathEdge, edge, retSite, d5);
propagate(s_p, d3, retSite, d5);
}
});
}
@ -574,8 +573,8 @@ public class TabulationSolver<T, P, F> {
D3.foreach(new IntSetAction() {
@Override
public void act(int d3) {
newNormalExplodedEdge(edge, m, d3);
if (propagate(edge.entry, edge.d1, m, d3)) {
newNormalExplodedEdge(edge.target, edge.d2, m, d3);
}
}
});
@ -604,8 +603,8 @@ public class TabulationSolver<T, P, F> {
public void act(int x) {
assert x >= 0;
assert edge.d1 >= 0;
newNormalExplodedEdge(edge, returnSite, x);
if (propagate(edge.entry, edge.d1, returnSite, x)) {
newNormalExplodedEdge(edge.target, edge.d2, returnSite, x);
}
}
});
@ -660,7 +659,7 @@ public class TabulationSolver<T, P, F> {
// we get reuse if we _don't_ propagate a new fact to the callee entry
final boolean gotReuse = !propagate(calleeEntry, d1, calleeEntry, d1);
recordCall(edge.target, calleeEntry, d1, gotReuse);
newCallExplodedEdge(edge.target, edge.d2, calleeEntry, d1);
newCallExplodedEdge(edge, calleeEntry, d1);
// cache the fact that we've flowed <c, d2> -> <callee, d1> by a
// call flow
callFlow.addCallEdge(callNodeNum, edge.d2, d1);
@ -696,9 +695,8 @@ public class TabulationSolver<T, P, F> {
D5.foreach(new IntSetAction() {
@Override
public void act(int d5) {
if (propagate(edge.entry, edge.d1, returnSite, d5)) {
newReturnExplodedEdge(exit, d2, returnSite, d5);
}
newSummaryEdge(edge, curSummaryEdge, returnSite, d5);
propagate(edge.entry, edge.d1, returnSite, d5);
}
});
}
@ -708,9 +706,8 @@ public class TabulationSolver<T, P, F> {
D5.foreach(new IntSetAction() {
@Override
public void act(int d5) {
if (propagate(edge.entry, edge.d1, returnSite, d5)) {
newReturnExplodedEdge(exit, d2, returnSite, d5);
}
newSummaryEdge(edge, curSummaryEdge, returnSite, d5);
propagate(edge.entry, edge.d1, returnSite, d5);
}
});
}
@ -1081,42 +1078,36 @@ public class TabulationSolver<T, P, F> {
}
/**
* Indicates that due to a path edge with destination <pred, d1> and a normal flow function application,
* a new path edge with destination <succ, d2> was created. To be overridden in subclasses. We also
* use this function to record call-to-return flow.
* Indicates that due to a path edge <s_p, d1> -> <n, d2> (the 'edge'
* parameter) and a normal flow function application, a new path edge <s_p,
* d1> -> <m, d3> was created. To be overridden in subclasses. We also use
* this function to record call-to-return flow.
*
* @param pred
* @param d1
* @param succ
* @param d2
*/
protected void newNormalExplodedEdge(T pred, int d1, T succ, int d2) {
protected void newNormalExplodedEdge(PathEdge<T> edge, T m, int d3) {
}
/**
* Indicates that due to a path edge with destination <caller, d1> and application of a call flow function,
* a new path edge with destination <calleeEntry, d2> was created. To be overridden in subclasses.
* Indicates that due to a path edge 'edge' <s_p, d1> -> <n, d2> and
* application of a call flow function, a new path edge <calleeEntry, d3> ->
* <calleeEntry, d3> was created. To be overridden in subclasses.
*
* @param caller
* @param d1
* @param calleeEntry
* @param d2
*/
protected void newCallExplodedEdge(T caller, int d1, T calleeEntry, int d2) {
protected void newCallExplodedEdge(PathEdge<T> edge, T calleeEntry, int d3) {
}
/**
* Indicates that due to a path edge with destination <exit, d1> and application of a return flow function,
* a new path edge with destination <returnSite, d2> was created. To be overridden in subclasses.
*
* @param exit
* @param d1
* @param returnSite
* @param d2
* Combines [25] and [26-28]. In the caller we have a path edge
* 'edgeToCallSite' <s_c, d3> -> <c, d4>, where c is the call site. In the
* callee, we have path edge 'calleeSummaryEdge' <s_p, d1> -> <e_p, d2>. Of
* course, there is a call edge <c, d4> -> <s_p, d1>. Finally, we have a
* return edge <e_p, d2> -> <returnSite, d5>.
*/
protected void newReturnExplodedEdge(T exit, int d1, T returnSite, int d2) {
protected void newSummaryEdge(PathEdge<T> edgeToCallSite, PathEdge<T> calleeSummaryEdge, T returnSite, int d5) {
}
}