use of soot.jimple.spark.pag.Node in project soot by Sable.
the class PtInsNode method do_before_propagation.
@Override
public void do_before_propagation() {
// if ( complex_cons == null )
do_pts_interval_merge();
// if ( !(me instanceof LocalVarNode) )
do_flow_edge_interval_merge();
// This pointer filter, please read the comments at this line in file FullSensitiveNode.java
Node wrappedNode = getWrappedNode();
if (wrappedNode instanceof LocalVarNode && ((LocalVarNode) wrappedNode).isThisPtr()) {
SootMethod func = ((LocalVarNode) wrappedNode).getMethod();
if (!func.isConstructor()) {
// We don't process the specialinvoke call edge
SootClass defClass = func.getDeclaringClass();
Hierarchy typeHierarchy = Scene.v().getActiveHierarchy();
for (Iterator<AllocNode> it = new_pts.keySet().iterator(); it.hasNext(); ) {
AllocNode obj = it.next();
if (obj.getType() instanceof RefType) {
SootClass sc = ((RefType) obj.getType()).getSootClass();
if (defClass != sc) {
try {
SootMethod rt_func = typeHierarchy.resolveConcreteDispatch(sc, func);
if (rt_func != func) {
it.remove();
// Also preclude it from propagation again
pt_objs.put(obj, (PtInsIntervalManager) deadManager);
}
} catch (RuntimeException e) {
// If the input program has a wrong type cast, resolveConcreteDispatch fails and it goes here
// We simply ignore this error
}
}
}
}
}
}
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class SparkLibraryHelper method caseArrayType.
/**
* A new local array will be created and connected to
* {@link SparkLibraryHelper#node} of type {@link ArrayType}. For this new
* local an allocation edge to a new array of its declared type will be
* added. If the {@link ArrayType#getElementType()} is still an array an
* allocation to a new array of this element type will be made and stored
* until the element type is a {@link RefType}. If this is the case an
* allocation to {@link AnySubType} of {@link ArrayType#baseType} will be
* made.
*/
@Override
public void caseArrayType(ArrayType type) {
Node array = node;
for (Type t = type; t instanceof ArrayType; t = ((ArrayType) t).getElementType()) {
ArrayType at = (ArrayType) t;
if (at.baseType instanceof RefType) {
// var tmpArray;
LocalVarNode localArray = pag.makeLocalVarNode(new Object(), t, method);
// x = tmpArray;
pag.addEdge(localArray, array);
// new T[]
AllocNode newArray = pag.makeAllocNode(new Object(), at, method);
// tmpArray = new T[]
pag.addEdge(newArray, localArray);
// tmpArray[i]
FieldRefNode arrayRef = pag.makeFieldRefNode(localArray, ArrayElement.v());
// var tmp
LocalVarNode local = pag.makeLocalVarNode(new Object(), at.getElementType(), method);
// tmpArray[i] = tmp
pag.addEdge(local, arrayRef);
// x = tmp
array = local;
if (at.numDimensions == 1) {
// new T()
AllocNode alloc = pag.makeAllocNode(new Object(), AnySubType.v((RefType) at.baseType), method);
// tmp = new T()
pag.addEdge(alloc, local);
}
}
}
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class TypeManager method makeTypeMask.
public final void makeTypeMask() {
RefType.v("java.lang.Class");
typeMask = new LargeNumberedMap<Type, BitVector>(Scene.v().getTypeNumberer());
if (fh == null)
return;
int numTypes = Scene.v().getTypeNumberer().size();
if (pag.getOpts().verbose())
logger.debug("" + "Total types: " + numTypes);
// **
initClass2allocs();
makeClassTypeMask(Scene.v().getSootClass("java.lang.Object"));
BitVector visitedTypes = new BitVector();
{
Iterator<Type> it = typeMask.keyIterator();
while (it.hasNext()) {
Type t = it.next();
visitedTypes.set(t.getNumber());
}
}
// **
ArrayNumberer<AllocNode> allocNodes = pag.getAllocNodeNumberer();
for (Type t : Scene.v().getTypeNumberer()) {
if (!(t instanceof RefLikeType))
continue;
if (t instanceof AnySubType)
continue;
if (isUnresolved(t))
continue;
// **
if (t instanceof RefType && !t.equals(RefType.v("java.lang.Object")) && !t.equals(RefType.v("java.io.Serializable")) && !t.equals(RefType.v("java.lang.Cloneable"))) {
SootClass sc = ((RefType) t).getSootClass();
if (sc.isInterface()) {
makeMaskOfInterface(sc);
}
if (!visitedTypes.get(t.getNumber()) && !((RefType) t).getSootClass().isPhantom()) {
makeClassTypeMask(((RefType) t).getSootClass());
}
continue;
}
// **
BitVector mask = new BitVector(allocNodes.size());
for (Node n : allocNodes) {
if (castNeverFails(n.getType(), t)) {
mask.set(n.getNumber());
}
}
typeMask.put(t, mask);
}
allocNodeListener = pag.allocNodeListener();
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class PtSensVisitor method hasNonEmptyIntersection.
/**
* Tests if two containers have contain same things.
* Can be used to answer the alias query.
*/
public boolean hasNonEmptyIntersection(PtSensVisitor<VarType> other) {
// Using table view for comparison, that's faster
for (Map.Entry<Node, List<VarType>> entry : tableView.entrySet()) {
Node var = entry.getKey();
List<VarType> list1 = entry.getValue();
List<VarType> list2 = other.getCSList(var);
if (list1.size() == 0 || list2.size() == 0)
continue;
for (VarType cv1 : list1) {
for (VarType cv2 : list2) if (cv1.intersect(cv2))
return true;
}
}
return false;
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class FullSensitiveNode method injectPts.
/**
* We transfer the SPARK results to current pointer if this pointer is not involved in the geometric analysis.
* Note that, the unreachable objects will not be inserted.
*/
@Override
public void injectPts() {
final GeomPointsTo geomPTA = (GeomPointsTo) Scene.v().getPointsToAnalysis();
pt_objs = new HashMap<AllocNode, GeometricManager>();
me.getP2Set().forall(new P2SetVisitor() {
@Override
public void visit(Node n) {
if (geomPTA.isValidGeometricNode(n))
pt_objs.put((AllocNode) n, (GeometricManager) stubManager);
}
});
new_pts = null;
}
Aggregations