Search in sources :

Example 6 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.

the class WCAInvoker method isOnLocalWCETPath.

public boolean isOnLocalWCETPath(MethodInfo method, InstructionHandle ih) {
    ControlFlowGraph cfg = method.getCode().getControlFlowGraph(false);
    BasicBlockNode block = cfg.getHandleNode(ih, true);
    // we do not have a block.. this is some exception handling path (hopefully..)
    if (block == null) {
        return false;
    }
    for (ExecutionContext node : wcetTool.getCallGraph().getNodes(method)) {
        Long flow = wcaNodeFlow.get(node).get(block);
        if (flow > 0)
            return true;
    }
    return false;
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) BasicBlockNode(com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph)

Example 7 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.

the class ExecFrequencyAnalysis method getExecFrequency.

public long getExecFrequency(ExecutionContext context, InstructionHandle ih) {
    MethodInfo method = context.getMethodInfo();
    // By loading the CFG, loopbounds are attached to the blocks if the WCA tool is loaded
    ControlFlowGraph cfg = method.getCode().getControlFlowGraph(false);
    LoopColoring<CFGNode, CFGEdge> lc = cfg.getLoopColoring();
    BasicBlockNode node = cfg.getHandleNode(ih, true);
    if (node == null) {
        // THIS IS UNSAFE! but what can you do ...
        return 1;
    }
    long ef = 1;
    for (CFGNode hol : lc.getLoopColor(node)) {
        LoopBound lb = hol.getLoopBound();
        if (lb != null) {
            if (lb.isDefaultBound() && !analyses.isWCAMethod(method)) {
                ef *= DEFAULT_ACET_LOOP_BOUND;
            } else {
                ef *= lb.getUpperBound(context);
            }
        } else {
            ef *= DEFAULT_ACET_LOOP_BOUND;
        }
    }
    return ef;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) BasicBlockNode(com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode) LoopBound(com.jopdesign.common.code.LoopBound) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 8 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.

the class TreeAnalysis method computeProgress.

/* FIXME: filter leaf methods is really a ugly hack,
         * but needs some work to play nice with uppaal eliminate-leaf-methods optimizations
         */
public void computeProgress(MethodInfo targetMethod, CallString cs) {
    List<MethodInfo> reachable = project.getCallGraph().getReachableImplementations(targetMethod, cs);
    Collections.reverse(reachable);
    for (MethodInfo mi : reachable) {
        ControlFlowGraph cfg = project.getFlowGraph(mi);
        Map<CFGNode, Long> localProgress = new HashMap<CFGNode, Long>();
        ProgressVisitor progressVisitor = new ProgressVisitor(maxProgress);
        for (CFGNode n : cfg.vertexSet()) {
            localProgress.put(n, progressVisitor.getProgress(n));
        }
        ProgressMeasure<CFGNode, CFGEdge> pm = new ProgressMeasure<CFGNode, ControlFlowGraph.CFGEdge>(cfg.getGraph(), cfg.getLoopColoring(), extractUBs(cfg.buildLoopBoundMap()), localProgress);
        long progress = pm.getMaxProgress().get(cfg.getExit());
        /* FIXME: _UGLY_ hack */
        if (filterLeafMethods && cfg.isLeafMethod()) {
            maxProgress.put(mi, 0L);
        } else {
            maxProgress.put(mi, progress);
        }
        relativeProgress.put(mi, pm.computeRelativeProgress());
    }
    System.out.println("Progress Measure (max): " + maxProgress.get(targetMethod));
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) HashMap(java.util.HashMap) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo) ProgressMeasure(com.jopdesign.common.graphutils.ProgressMeasure) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 9 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.

the class ExecuteOnceAnalysis method isExecutedOnce.

public boolean isExecutedOnce(ExecutionContext scope, CFGNode node) {
    ControlFlowGraph cfg = node.getControlFlowGraph();
    scope = new ExecutionContext(scope.getMethodInfo());
    /* Remove call string */
    Set<MethodInfo> inLoopMethods = inLoopSet.get(scope);
    if (inLoopMethods == null) {
        Logger.getLogger("Object Cache Analysis").warning("No loop information for " + scope.getMethodInfo().getFQMethodName());
        return false;
    }
    if (!inLoopMethods.contains(cfg.getMethodInfo())) {
        return cfg.getLoopColoring().getLoopColor(node).size() == 0;
    } else {
        return false;
    }
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo)

Example 10 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.

the class ExecuteOnceAnalysis method analyze.

private void analyze() {
    inLoopSet = new HashMap<ExecutionContext, Set<MethodInfo>>();
    /* Top Down the Scope Graph */
    TopologicalOrderIterator<ExecutionContext, ContextEdge> iter = project.getCallGraph().topDownIterator();
    while (iter.hasNext()) {
        ExecutionContext scope = iter.next();
        scope = new ExecutionContext(scope.getMethodInfo());
        /* Remove call string */
        ControlFlowGraph cfg = project.getFlowGraph(scope.getMethodInfo());
        Set<MethodInfo> inLoop = new HashSet<MethodInfo>();
        for (CFGNode node : cfg.vertexSet()) {
            if (!(node instanceof ControlFlowGraph.InvokeNode))
                continue;
            ControlFlowGraph.InvokeNode iNode = (ControlFlowGraph.InvokeNode) node;
            if (!cfg.getLoopColoring().getLoopColor(node).isEmpty()) {
                for (MethodInfo impl : iNode.getImplementingMethods()) {
                    inLoop.add(impl);
                    inLoop.addAll(project.getCallGraph().getReachableImplementationsSet(impl));
                }
            }
        }
        inLoopSet.put(scope, inLoop);
    }
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) HashSet(java.util.HashSet) Set(java.util.Set) CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge) HashSet(java.util.HashSet)

Aggregations

ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)23 MethodInfo (com.jopdesign.common.MethodInfo)12 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)10 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)5 ExecutionContext (com.jopdesign.common.code.ExecutionContext)5 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)4 LoopBound (com.jopdesign.common.code.LoopBound)4 BadGraphError (com.jopdesign.common.misc.BadGraphError)3 BadGraphException (com.jopdesign.common.misc.BadGraphException)3 HashMap (java.util.HashMap)3 InstructionHandle (org.apache.bcel.generic.InstructionHandle)3 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)2 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)2 ProgressMeasure (com.jopdesign.common.graphutils.ProgressMeasure)2 ClassInfo (com.jopdesign.common.ClassInfo)1 MethodCode (com.jopdesign.common.MethodCode)1 BasicBlock (com.jopdesign.common.code.BasicBlock)1 CallString (com.jopdesign.common.code.CallString)1 InvokeNode (com.jopdesign.common.code.ControlFlowGraph.InvokeNode)1 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1