Search in sources :

Example 26 with CFGNode

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

the class ConstantCache method build.

public ConstantCache build() {
    List<MethodInfo> methods = project.getCallGraph().getReachableImplementations(project.getTargetMethod());
    for (int i = methods.size() - 1; i >= 0; i--) {
        MethodInfo mi = methods.get(i);
        ControlFlowGraph cfg = project.getFlowGraph(mi);
        for (CFGNode n : cfg.vertexSet()) {
            BasicBlock bb = n.getBasicBlock();
            if (bb == null)
                continue;
            for (InstructionHandle ii : bb.getInstructions()) {
                extractConstantAddresses(cfg, ii);
            }
        }
    }
    return this;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) BasicBlock(com.jopdesign.common.code.BasicBlock) MethodInfo(com.jopdesign.common.MethodInfo) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Example 27 with CFGNode

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

the class RecursiveWcetAnalysis method edgeToNodeFlow.

public static Map<CFGNode, Long> edgeToNodeFlow(DirectedGraph<CFGNode, ControlFlowGraph.CFGEdge> graph, Map<ControlFlowGraph.CFGEdge, Long> cfgEdgeFlow) {
    HashMap<CFGNode, Long> nodeFlow = new HashMap<CFGNode, Long>();
    for (CFGNode n : graph.vertexSet()) {
        if (// ENTRY and DEAD CODE (no flow)
        graph.inDegreeOf(n) == 0)
            // ENTRY and DEAD CODE (no flow)
            nodeFlow.put(n, 0L);
        else {
            long flow = 0;
            for (ControlFlowGraph.CFGEdge inEdge : graph.incomingEdgesOf(n)) {
                flow += cfgEdgeFlow.get(inEdge);
            }
            nodeFlow.put(n, flow);
        }
    }
    return nodeFlow;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) HashMap(java.util.HashMap) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph)

Example 28 with CFGNode

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

the class TreeAnalysis method computeWCET.

public long computeWCET(MethodInfo targetMethod) {
    this.methodWCET = new HashMap<MethodInfo, Long>();
    List<MethodInfo> reachable = project.getCallGraph().getReachableImplementations(targetMethod);
    Collections.reverse(reachable);
    for (MethodInfo mi : reachable) {
        ControlFlowGraph cfg = project.getFlowGraph(mi);
        Map<CFGNode, Long> localCost = new HashMap<CFGNode, Long>();
        LocalCostVisitor lcv = new LocalCostVisitor(new AnalysisContextCallString(CallString.EMPTY), project);
        for (CFGNode n : cfg.vertexSet()) {
            localCost.put(n, lcv.computeCost(n).getCost());
        }
        ProgressMeasure<CFGNode, ControlFlowGraph.CFGEdge> pm = new ProgressMeasure<CFGNode, ControlFlowGraph.CFGEdge>(cfg.getGraph(), cfg.getLoopColoring(), extractUBs(cfg.buildLoopBoundMap()), localCost);
        long wcet = pm.getMaxProgress().get(cfg.getExit());
        methodWCET.put(mi, wcet);
    }
    return methodWCET.get(targetMethod);
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) HashMap(java.util.HashMap) ProgressMeasure(com.jopdesign.common.graphutils.ProgressMeasure) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Aggregations

CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)28 MethodInfo (com.jopdesign.common.MethodInfo)13 ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)13 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)10 LoopBound (com.jopdesign.common.code.LoopBound)7 ExecutionContext (com.jopdesign.common.code.ExecutionContext)6 HashMap (java.util.HashMap)6 InstructionHandle (org.apache.bcel.generic.InstructionHandle)6 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)5 InvokeNode (com.jopdesign.common.code.ControlFlowGraph.InvokeNode)4 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 BasicBlock (com.jopdesign.common.code.BasicBlock)3 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)3 LinkedHashSet (java.util.LinkedHashSet)3 Set (java.util.Set)3 ClassInfo (com.jopdesign.common.ClassInfo)2 MethodCode (com.jopdesign.common.MethodCode)2 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)2