Search in sources :

Example 16 with P2SetVisitor

use of soot.jimple.spark.sets.P2SetVisitor in project soot by Sable.

the class PropIter method handleStores.

protected final boolean handleStores(VarNode src) {
    boolean ret = false;
    final PointsToSetInternal srcSet = src.getP2Set();
    if (srcSet.isEmpty())
        return false;
    Node[] storeTargets = pag.storeLookup(src);
    for (Node element : storeTargets) {
        final FieldRefNode fr = (FieldRefNode) element;
        final SparkField f = fr.getField();
        ret = fr.getBase().getP2Set().forall(new P2SetVisitor() {

            public final void visit(Node n) {
                AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, f);
                if (nDotF.makeP2Set().addAll(srcSet, null)) {
                    returnValue = true;
                }
            }
        }) | ret;
    }
    return ret;
}
Also used : FieldRefNode(soot.jimple.spark.pag.FieldRefNode) AllocDotField(soot.jimple.spark.pag.AllocDotField) AllocNode(soot.jimple.spark.pag.AllocNode) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) SparkField(soot.jimple.spark.pag.SparkField) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 17 with P2SetVisitor

use of soot.jimple.spark.sets.P2SetVisitor in project soot by Sable.

the class PropIter method handleLoads.

protected final boolean handleLoads(FieldRefNode src) {
    boolean ret = false;
    final Node[] loadTargets = pag.loadLookup(src);
    final SparkField f = src.getField();
    ret = src.getBase().getP2Set().forall(new P2SetVisitor() {

        public final void visit(Node n) {
            AllocDotField nDotF = ((AllocNode) n).dot(f);
            if (nDotF == null)
                return;
            PointsToSetInternal set = nDotF.getP2Set();
            if (set.isEmpty())
                return;
            for (Node element : loadTargets) {
                VarNode target = (VarNode) element;
                if (target.makeP2Set().addAll(set, null)) {
                    returnValue = true;
                }
            }
        }
    }) | ret;
    return ret;
}
Also used : VarNode(soot.jimple.spark.pag.VarNode) AllocDotField(soot.jimple.spark.pag.AllocDotField) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) SparkField(soot.jimple.spark.pag.SparkField) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 18 with P2SetVisitor

use of soot.jimple.spark.sets.P2SetVisitor in project soot by Sable.

the class PropIter method handleNewInstances.

protected final boolean handleNewInstances(final NewInstanceNode src) {
    boolean ret = false;
    final Node[] newInstances = pag.assignInstanceLookup(src);
    for (final Node instance : newInstances) {
        ret = src.getP2Set().forall(new P2SetVisitor() {

            @Override
            public void visit(Node n) {
                if (n instanceof ClassConstantNode) {
                    ClassConstantNode ccn = (ClassConstantNode) n;
                    Type ccnType = ccn.getClassConstant().toSootType();
                    // If the referenced class has not been loaded, we do
                    // this now
                    SootClass targetClass = ((RefType) ccnType).getSootClass();
                    if (targetClass.resolvingLevel() == SootClass.DANGLING)
                        Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES);
                    instance.makeP2Set().add(pag.makeAllocNode(src.getValue(), ccnType, ccn.getMethod()));
                }
            }
        });
    }
    return ret;
}
Also used : RefType(soot.RefType) RefType(soot.RefType) Type(soot.Type) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) SootClass(soot.SootClass) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 19 with P2SetVisitor

use of soot.jimple.spark.sets.P2SetVisitor in project soot by Sable.

the class PropWorklist method handleFieldRefNode.

/**
 * Propagates new points-to information of node src to all its successors.
 */
protected final void handleFieldRefNode(FieldRefNode src, final HashSet<Object[]> edgesToPropagate) {
    final Node[] loadTargets = pag.loadLookup(src);
    if (loadTargets.length == 0)
        return;
    final SparkField field = src.getField();
    src.getBase().getP2Set().forall(new P2SetVisitor() {

        public final void visit(Node n) {
            AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, field);
            if (nDotF != null) {
                PointsToSetInternal p2Set = nDotF.getP2Set();
                if (!p2Set.getNewSet().isEmpty()) {
                    for (Node element : loadTargets) {
                        Object[] pair = { p2Set, element };
                        edgesToPropagate.add(pair);
                    }
                }
            }
        }
    });
}
Also used : AllocDotField(soot.jimple.spark.pag.AllocDotField) AllocNode(soot.jimple.spark.pag.AllocNode) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) SparkField(soot.jimple.spark.pag.SparkField) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 20 with P2SetVisitor

use of soot.jimple.spark.sets.P2SetVisitor in project soot by Sable.

the class OfflineProcessor method buildImpactGraph.

/**
 * The dependence graph will be destroyed and the impact graph will be built.
 * p = q means q impacts p. Therefore, we add en edge q -> p in impact graph.
 */
protected void buildImpactGraph() {
    for (int i = 0; i < n_var; ++i) {
        varGraph.set(i, null);
    }
    queue.clear();
    for (PlainConstraint cons : geomPTA.constraints) {
        if (!cons.isActive)
            continue;
        final IVarAbstraction lhs = cons.getLHS();
        final IVarAbstraction rhs = cons.getRHS();
        final SparkField field = cons.f;
        IVarAbstraction rep;
        switch(cons.type) {
            case Constants.NEW_CONS:
                // We enqueue the pointers that are allocation result receivers
                queue.add(rhs.id);
                break;
            case Constants.ASSIGN_CONS:
                add_graph_edge(lhs.id, rhs.id);
                break;
            case Constants.LOAD_CONS:
                rep = lhs.getRepresentative();
                if (rep.hasPTResult() == false) {
                    lhs.getWrappedNode().getP2Set().forall(new P2SetVisitor() {

                        @Override
                        public void visit(Node n) {
                            IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) n, field);
                            if (padf == null || padf.reachable() == false)
                                return;
                            add_graph_edge(padf.id, rhs.id);
                        }
                    });
                } else {
                    // use geomPA
                    for (AllocNode o : rep.get_all_points_to_objects()) {
                        IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) o, field);
                        if (padf == null || padf.reachable() == false)
                            continue;
                        add_graph_edge(padf.id, rhs.id);
                    }
                }
                break;
            case Constants.STORE_CONS:
                rep = rhs.getRepresentative();
                if (rep.hasPTResult() == false) {
                    rhs.getWrappedNode().getP2Set().forall(new P2SetVisitor() {

                        @Override
                        public void visit(Node n) {
                            IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) n, field);
                            if (padf == null || padf.reachable() == false)
                                return;
                            add_graph_edge(lhs.id, padf.id);
                        }
                    });
                } else {
                    // use geomPA
                    for (AllocNode o : rep.get_all_points_to_objects()) {
                        IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) o, field);
                        if (padf == null || padf.reachable() == false)
                            continue;
                        add_graph_edge(lhs.id, padf.id);
                    }
                }
                break;
        }
    }
}
Also used : PlainConstraint(soot.jimple.spark.geom.dataRep.PlainConstraint) AllocNode(soot.jimple.spark.pag.AllocNode) SparkField(soot.jimple.spark.pag.SparkField) GlobalVarNode(soot.jimple.spark.pag.GlobalVarNode) LocalVarNode(soot.jimple.spark.pag.LocalVarNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) PlainConstraint(soot.jimple.spark.geom.dataRep.PlainConstraint) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Aggregations

P2SetVisitor (soot.jimple.spark.sets.P2SetVisitor)26 AllocNode (soot.jimple.spark.pag.AllocNode)23 Node (soot.jimple.spark.pag.Node)23 VarNode (soot.jimple.spark.pag.VarNode)18 PointsToSetInternal (soot.jimple.spark.sets.PointsToSetInternal)15 LocalVarNode (soot.jimple.spark.pag.LocalVarNode)12 FieldRefNode (soot.jimple.spark.pag.FieldRefNode)11 ClassConstantNode (soot.jimple.spark.pag.ClassConstantNode)9 AllocDotField (soot.jimple.spark.pag.AllocDotField)7 NewInstanceNode (soot.jimple.spark.pag.NewInstanceNode)7 SparkField (soot.jimple.spark.pag.SparkField)7 Type (soot.Type)6 GlobalVarNode (soot.jimple.spark.pag.GlobalVarNode)5 RefType (soot.RefType)4 SootClass (soot.SootClass)4 SootMethod (soot.SootMethod)4 Value (soot.Value)4 StringConstantNode (soot.jimple.spark.pag.StringConstantNode)4 HashSet (java.util.HashSet)3 Local (soot.Local)3