Package soot.options

Examples of soot.options.SparkOptions


    public SparkTransformer( Singletons.Global g ) {}
    public static SparkTransformer v() { return G.v().soot_jimple_spark_SparkTransformer(); }

    protected void internalTransform( String phaseName, Map 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() ) {
            G.v().out.println( "VarNodes: "+pag.getVarNodeNumberer().size() );
            G.v().out.println( "FieldRefNodes: "+pag.getFieldRefNodeNumberer().size() );
            G.v().out.println( "AllocNodes: "+pag.getAllocNodeNumberer().size() );
        }

        // Simplify pag
        Date startSimplify = new Date();

        // We only simplify if on_fly_cg is false. But, if vta is true, it
        // overrides on_fly_cg, so we can still simplify. Something to handle
        // 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();
        final Propagator[] propagator = new Propagator[1];
        switch( opts.propagator() ) {
            case SparkOptions.propagator_iter:
                propagator[0] = new PropIter( pag );
                break;
            case SparkOptions.propagator_worklist:
                propagator[0] = new PropWorklist( pag );
                break;
            case SparkOptions.propagator_cycle:
                propagator[0] = new PropCycle( pag );
                break;
            case SparkOptions.propagator_merge:
                propagator[0] = new PropMerge( pag );
                break;
            case SparkOptions.propagator_alias:
                propagator[0] = new PropAlias( pag );
                break;
            case SparkOptions.propagator_none:
                break;
            default:
                throw new RuntimeException();
        }
        if( propagator[0] != null ) propagator[0].propagate();
        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() ) {
            G.v().out.println( "[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.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);
        }
    }
View Full Code Here


    if (!(pta instanceof PAG))
    {
       throw new RuntimeException("You must use Spark for points-to analysis when computing MHP information!");
    }
    PAG pag = (PAG) pta;
    SparkOptions so = pag.getOpts();
    if(so.rta())
       throw new RuntimeException("MHP cannot be calculated using RTA due to incomplete call graph");

    CallGraph callGraph = Scene.v().getCallGraph();

    // Get a call graph trimmed to contain only the relevant methods (non-lib, non-native)
//    G.v().out.println("    MHP: PegCallGraph");
    PegCallGraph pecg = new PegCallGraph(callGraph);
     
      // Find allocation nodes that are run more than once
      // Also find methods that are run more than once
//    G.v().out.println("    MHP: AllocNodesFinder");
    AllocNodesFinder anf = new AllocNodesFinder(pecg, callGraph, (PAG) pta);
    Set<AllocNode> multiRunAllocNodes = anf.getMultiRunAllocNodes();
    Set<Object> multiCalledMethods = anf.getMultiCalledMethods();

    // Find Thread.start() and Thread.join() statements (in live code)
//    G.v().out.println("    MHP: StartJoinFinder");
    StartJoinFinder sjf = new StartJoinFinder(callGraph, (PAG) pta); // does analysis
    Map<Stmt, List<AllocNode>> startToAllocNodes = sjf.getStartToAllocNodes();
    Map<Stmt, List<SootMethod>> startToRunMethods = sjf.getStartToRunMethods();
    Map<Stmt, SootMethod> startToContainingMethod = sjf.getStartToContainingMethod();
    Map<Stmt, Stmt> startToJoin = sjf.getStartToJoin();
   
    // Build MHP Lists
//    G.v().out.println("    MHP: Building MHP Lists");
    List<AbstractRuntimeThread> runAtOnceCandidates = new ArrayList<AbstractRuntimeThread>();
    Iterator threadIt = startToRunMethods.entrySet().iterator();
    int threadNum = 0;
    while(threadIt.hasNext())
    {
      // Get list of possible Runnable.run methods (actually, a list of peg chains)
      // and a list of allocation sites for this thread start statement
      // and the thread start statement itself
      Map.Entry e = (Map.Entry) threadIt.next();
      Stmt startStmt = (Stmt) e.getKey();
      List runMethods = (List) e.getValue();
      List threadAllocNodes = startToAllocNodes.get(e.getKey());

      // Get a list of all possible unique Runnable.run methods for this thread start statement
      AbstractRuntimeThread thread = new AbstractRuntimeThread(); // provides a list interface to the methods in a thread's sub-call-graph
      thread.setStartStmt(startStmt);
//      List threadMethods = new ArrayList();
      Iterator runMethodsIt = runMethods.iterator();
      while(runMethodsIt.hasNext())
      {
        SootMethod method = (SootMethod) runMethodsIt.next();
        if(!thread.containsMethod(method))
        {
          thread.addMethod(method);
          thread.addRunMethod(method);
        }
      }
     
      // Get a list containing all methods in the call graph(s) rooted at the possible run methods for this thread start statement
      // AKA a list of all methods that might be called by the thread started here
      int methodNum = 0;
      while(methodNum < thread.methodCount()) // iterate over all methods in threadMethods, even as new methods are being added to it
      {
        Iterator succMethodsIt = pecg.getSuccsOf(thread.getMethod(methodNum)).iterator();
        while(succMethodsIt.hasNext())
        {
          SootMethod method = (SootMethod) succMethodsIt.next();
          // if all edges into this method are of Kind THREAD, ignore it
          // (because it's a run method that won't be called as part of THIS thread) THIS IS NOT OPTIMAL
          boolean ignoremethod = true;
          Iterator edgeInIt = callGraph.edgesInto(method);
          while(edgeInIt.hasNext())
          {
            Edge edge = (Edge) edgeInIt.next();
            if( edge.kind() != Kind.THREAD && thread.containsMethod(edge.src())) // called directly by any of the thread methods?
              ignoremethod = false;
          }
          if(!ignoremethod && !thread.containsMethod(method))
            thread.addMethod(method);
        }
        methodNum++;
      }
     
      // Add this list of methods to MHPLists
      MHPLists.add(thread);
      if(optionPrintDebug)
        System.out.println(thread.toString());
     
      // Find out if the "thread" in "thread.start()" could be more than one object
      boolean mayStartMultipleThreadObjects = (threadAllocNodes.size() > 1) || so.types_for_sites();
      if(!mayStartMultipleThreadObjects) // if there's only one alloc node
      {
        if(multiRunAllocNodes.contains(threadAllocNodes.iterator().next())) // but it gets run more than once
        {
          mayStartMultipleThreadObjects = true; // then "thread" in "thread.start()" could be more than one object
View Full Code Here

        sootOptions.put("set-impl", "double");
        sootOptions.put("double-set-old", "hybrid");
        sootOptions.put("double-set-new", "hybrid");

        //CHATransformer.v().transform("cg.cha", sootOptions);
        /*SparkOptions sparkOptions = */new SparkOptions(sootOptions);

        /*
         PAG analyzer = new PAG(sparkOptions);

         CallGraphBuilder builder = new CallGraphBuilder(analyzer);
View Full Code Here

TOP

Related Classes of soot.options.SparkOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.