soot.jimple.infoflow.solver.gc.SolverReferenceCounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of soot-infoflow Show documentation
Show all versions of soot-infoflow Show documentation
Soot extending data flow tracking components for Java
package soot.jimple.infoflow.solver.gc;
import soot.SootMethod;
import soot.jimple.infoflow.collect.MyConcurrentHashMap;
import soot.jimple.infoflow.collect.MyConcurrentHashMap.IValueFactory;
import soot.jimple.infoflow.solver.fastSolver.FastSolverLinkedNode;
public class SolverReferenceCounter> {
private final IValueFactory> counterFactory = new IValueFactory>() {
@Override
public GCCounter createValue() {
return new GCCounter();
}
};
private final MyConcurrentHashMap, GCCounter> countingMap = new MyConcurrentHashMap<>();
private GCCounter getCounter(GCContext context) {
return countingMap.putIfAbsentElseGet(context, counterFactory);
}
public void incTasks(D context, SootMethod method) {
GCContext gccontext = new GCContext<>(context, method);
GCCounter ctr = getCounter(gccontext);
ctr.incTasks();
}
public void decTasks(D context, SootMethod method) {
GCContext gccontext = new GCContext<>(context, method);
decTasks(gccontext);
}
public void decTasks(GCContext gccontext) {
GCCounter ctr = getCounter(gccontext);
if (ctr != null)
ctr.decTasks();
}
public void addCallee(D context, SootMethod method, D calleeContext, SootMethod calleeMethod) {
GCContext gccontext = new GCContext<>(context, method);
GCContext calleeGCContext = new GCContext(calleeContext, calleeMethod);
GCCounter ctr = getCounter(gccontext);
GCCounter ctrCallee = getCounter(calleeGCContext);
ctr.addCallee(ctrCallee);
}
public boolean canGC(GCContext gccontext) {
GCCounter ctr = getCounter(gccontext);
return ctr == null || ctr.canGC();
}
}