Search in sources :

Example 1 with ContextInsensitiveBuilder

use of soot.jimple.spark.builder.ContextInsensitiveBuilder in project soot by Sable.

the class SparkTransformer method internalTransform.

protected void internalTransform(String phaseName, Map<String, String> options) {
    SparkOptions opts = new SparkOptions(options);
    final String output_dir = SourceLocator.v().getOutputDir();
    // Build pointer assignment graph
    ContextInsensitiveBuilder b = new ContextInsensitiveBuilder();
    if (opts.pre_jimplify())
        b.preJimplify();
    if (opts.force_gc())
        doGC();
    Date startBuild = new Date();
    final PAG pag = b.setup(opts);
    b.build();
    Date endBuild = new Date();
    reportTime("Pointer Assignment Graph", startBuild, endBuild);
    if (opts.force_gc())
        doGC();
    // Build type masks
    Date startTM = new Date();
    pag.getTypeManager().makeTypeMask();
    Date endTM = new Date();
    reportTime("Type masks", startTM, endTM);
    if (opts.force_gc())
        doGC();
    if (opts.verbose()) {
        logger.debug("VarNodes: " + pag.getVarNodeNumberer().size());
        logger.debug("FieldRefNodes: " + pag.getFieldRefNodeNumberer().size());
        logger.debug("AllocNodes: " + pag.getAllocNodeNumberer().size());
    }
    // Simplify pag
    Date startSimplify = new Date();
    // these option interdependencies more cleanly would be nice...
    if ((opts.simplify_sccs() && !opts.on_fly_cg()) || opts.vta()) {
        new SCCCollapser(pag, opts.ignore_types_for_sccs()).collapse();
    }
    if (opts.simplify_offline() && !opts.on_fly_cg()) {
        new EBBCollapser(pag).collapse();
    }
    if (true || opts.simplify_sccs() || opts.vta() || opts.simplify_offline()) {
        pag.cleanUpMerges();
    }
    Date endSimplify = new Date();
    reportTime("Pointer Graph simplified", startSimplify, endSimplify);
    if (opts.force_gc())
        doGC();
    // Dump pag
    PAGDumper dumper = null;
    if (opts.dump_pag() || opts.dump_solution()) {
        dumper = new PAGDumper(pag, output_dir);
    }
    if (opts.dump_pag())
        dumper.dump();
    // Propagate
    Date startProp = new Date();
    propagatePAG(opts, pag);
    Date endProp = new Date();
    reportTime("Propagation", startProp, endProp);
    reportTime("Solution found", startSimplify, endProp);
    if (opts.force_gc())
        doGC();
    if (!opts.on_fly_cg() || opts.vta()) {
        CallGraphBuilder cgb = new CallGraphBuilder(pag);
        cgb.build();
    }
    if (opts.verbose()) {
        logger.debug("[Spark] Number of reachable methods: " + Scene.v().getReachableMethods().size());
    }
    if (opts.set_mass())
        findSetMass(pag);
    if (opts.dump_answer())
        new ReachingTypeDumper(pag, output_dir).dump();
    if (opts.dump_solution())
        dumper.dumpPointsToSets();
    if (opts.dump_html())
        new PAG2HTML(pag, output_dir).dump();
    Scene.v().setPointsToAnalysis(pag);
    if (opts.add_tags()) {
        addTags(pag);
    }
    if (opts.geom_pta()) {
        if (opts.simplify_offline() || opts.simplify_sccs()) {
            logger.debug("" + "Please turn off the simplify-offline and simplify-sccs to run the geometric points-to analysis");
            logger.debug("Now, we keep the SPARK result for querying.");
        } else {
            // We perform the geometric points-to analysis
            GeomPointsTo geomPTA = (GeomPointsTo) pag;
            geomPTA.parametrize(endProp.getTime() - startSimplify.getTime());
            geomPTA.solve();
        }
    }
    if (opts.cs_demand()) {
        // replace by demand-driven refinement-based context-sensitive analysis
        Date startOnDemand = new Date();
        PointsToAnalysis onDemandAnalysis = DemandCSPointsTo.makeWithBudget(opts.traversal(), opts.passes(), opts.lazy_pts());
        Date endOndemand = new Date();
        reportTime("Initialized on-demand refinement-based context-sensitive analysis", startOnDemand, endOndemand);
        Scene.v().setPointsToAnalysis(onDemandAnalysis);
    }
}
Also used : PAGDumper(soot.jimple.spark.pag.PAGDumper) GeomPointsTo(soot.jimple.spark.geom.geomPA.GeomPointsTo) EBBCollapser(soot.jimple.spark.solver.EBBCollapser) ContextInsensitiveBuilder(soot.jimple.spark.builder.ContextInsensitiveBuilder) ReachingTypeDumper(soot.jimple.ReachingTypeDumper) Date(java.util.Date) SparkOptions(soot.options.SparkOptions) CallGraphBuilder(soot.jimple.toolkits.callgraph.CallGraphBuilder) PAG(soot.jimple.spark.pag.PAG) PAG2HTML(soot.jimple.spark.pag.PAG2HTML) SCCCollapser(soot.jimple.spark.solver.SCCCollapser) PointsToAnalysis(soot.PointsToAnalysis)

Aggregations

Date (java.util.Date)1 PointsToAnalysis (soot.PointsToAnalysis)1 ReachingTypeDumper (soot.jimple.ReachingTypeDumper)1 ContextInsensitiveBuilder (soot.jimple.spark.builder.ContextInsensitiveBuilder)1 GeomPointsTo (soot.jimple.spark.geom.geomPA.GeomPointsTo)1 PAG (soot.jimple.spark.pag.PAG)1 PAG2HTML (soot.jimple.spark.pag.PAG2HTML)1 PAGDumper (soot.jimple.spark.pag.PAGDumper)1 EBBCollapser (soot.jimple.spark.solver.EBBCollapser)1 SCCCollapser (soot.jimple.spark.solver.SCCCollapser)1 CallGraphBuilder (soot.jimple.toolkits.callgraph.CallGraphBuilder)1 SparkOptions (soot.options.SparkOptions)1