All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.jimple.infoflow.solver.gc.SolverReferenceCounter Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
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();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy