use of soot.jimple.spark.pag.AllocNode 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.AllocNode in project soot by Sable.
the class SparkLibraryHelper method caseRefType.
/**
* A new local will be created and connected to
* {@link SparkLibraryHelper#node} of type {@link RefType}. For this new
* local an allocation edge to {@link AnySubType} of its declared type will
* be added.
*/
@Override
public void caseRefType(RefType t) {
// var tmp;
VarNode local = pag.makeLocalVarNode(new Object(), t, method);
// new T();
AllocNode alloc = pag.makeAllocNode(new Object(), AnySubType.v(t), method);
// tmp = new T();
pag.addAllocEdge(alloc, local);
// x = tmp;
pag.addEdge(local, node);
}
use of soot.jimple.spark.pag.AllocNode 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.AllocNode in project soot by Sable.
the class TypeManager method makeClassTypeMask.
private final BitVector makeClassTypeMask(SootClass clazz) {
{
BitVector cachedMask = typeMask.get(clazz.getType());
if (cachedMask != null) {
return cachedMask;
}
}
int nBits = pag.getAllocNodeNumberer().size();
final BitVector mask = new BitVector(nBits);
List<AllocNode> allocs = null;
if (clazz.isConcrete()) {
allocs = class2allocs.get(clazz);
}
if (allocs != null) {
for (AllocNode an : allocs) {
mask.set(an.getNumber());
}
}
Collection<SootClass> subclasses = fh.getSubclassesOf(clazz);
if (subclasses == Collections.EMPTY_LIST) {
for (AllocNode an : anySubtypeAllocs) {
mask.set(an.getNumber());
}
typeMask.put(clazz.getType(), mask);
return mask;
}
for (SootClass subcl : subclasses) {
mask.or(makeClassTypeMask(subcl));
}
typeMask.put(clazz.getType(), mask);
return mask;
}
use of soot.jimple.spark.pag.AllocNode 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();
}
Aggregations