Search in sources :

Example 1 with LoopBound

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

the class JavaOneProcessPerMethodTranslator method recordLoops.

private void recordLoops(MethodInfo mi, TemplateBuilder pb) {
    ControlFlowGraph cfg = project.getFlowGraph(mi);
    for (CFGNode hol : cfg.getLoopColoring().getHeadOfLoops()) {
        LoopBound bound = hol.getLoopBound();
        int nesting = cfg.getLoopColoring().getLoopColor(hol).size();
        pb.addLoop(hol, nesting, bound);
    }
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) LoopBound(com.jopdesign.common.code.LoopBound) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph)

Example 2 with LoopBound

use of com.jopdesign.common.code.LoopBound 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 3 with LoopBound

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

the class TreeAnalysis method extractUBs.

private Map<CFGNode, Long> extractUBs(Map<CFGNode, LoopBound> loopBounds) {
    Map<CFGNode, Long> ubMap = new HashMap<CFGNode, Long>();
    for (Entry<CFGNode, LoopBound> entry : loopBounds.entrySet()) {
        MethodInfo mi = entry.getKey().getControlFlowGraph().getMethodInfo();
        ExecutionContext eCtx = new ExecutionContext(mi);
        ubMap.put(entry.getKey(), entry.getValue().getUpperBound(eCtx));
    }
    return ubMap;
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) HashMap(java.util.HashMap) LoopBound(com.jopdesign.common.code.LoopBound) MethodInfo(com.jopdesign.common.MethodInfo)

Example 4 with LoopBound

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

the class GlobalAnalysis method getLoopBounds.

/**
	 * <p>Get all loop bounds for the given segment.</p>
	 * <p>For each loop bound B for loop H relative to marker M:</p>
	 * <p>sum(M) * B &lt;= sum(continue-edges-of(H))</p>
     *
	 * @param segment
	 * @return
	 * @throws InvalidFlowFactException 
	 */
private static Iterable<LinearConstraint<SuperGraphEdge>> getLoopBounds(WCETTool wcetTool, Segment segment) throws InvalidFlowFactException {
    List<LinearConstraint<SuperGraphEdge>> constraints = new ArrayList<LinearConstraint<SuperGraphEdge>>();
    // For all CFG instances
    for (ContextCFG ccfg : segment.getCallGraphNodes()) {
        ControlFlowGraph cfg = ccfg.getCfg();
        // for all loops in the method
        LoopColoring<CFGNode, ControlFlowGraph.CFGEdge> loops = cfg.getLoopColoring();
        for (CFGNode hol : loops.getHeadOfLoops()) {
            LoopBound loopBound = wcetTool.getLoopBound(hol, ccfg.getContext().getCallString());
            if (loopBound == null) {
                throw new AppInfoError("No loop bound record for head of loop: " + hol + " : " + cfg.buildLoopBoundMap());
            }
            addLoopConstraints(constraints, segment, ccfg, hol, loops, loopBound);
        }
    }
    return constraints;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) ContextCFG(com.jopdesign.common.code.SuperGraph.ContextCFG) LoopBound(com.jopdesign.common.code.LoopBound) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) ArrayList(java.util.ArrayList) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) LinearConstraint(com.jopdesign.wcet.ipet.LinearConstraint) AppInfoError(com.jopdesign.common.misc.AppInfoError) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 5 with LoopBound

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

the class WCETTool method getLoopBound.

// TODO move somewhere else?
public LoopBound getLoopBound(CFGNode node, CallString cs) {
    LoopBound globalBound = node.getLoopBound();
    ExecutionContext eCtx = new ExecutionContext(node.getControlFlowGraph().getMethodInfo(), cs);
    if (node.getBasicBlock() != null) {
        return this.getEventHandler().dfaLoopBound(node.getBasicBlock(), eCtx, globalBound);
    } else {
        return globalBound;
    }
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) LoopBound(com.jopdesign.common.code.LoopBound)

Aggregations

LoopBound (com.jopdesign.common.code.LoopBound)12 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)7 MethodInfo (com.jopdesign.common.MethodInfo)5 ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)4 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)3 ExecutionContext (com.jopdesign.common.code.ExecutionContext)3 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)2 AppInfoError (com.jopdesign.common.misc.AppInfoError)2 SourceAnnotations (com.jopdesign.wcet.annotations.SourceAnnotations)2 ArrayList (java.util.ArrayList)2 ClassInfo (com.jopdesign.common.ClassInfo)1 MethodCode (com.jopdesign.common.MethodCode)1 BasicBlock (com.jopdesign.common.code.BasicBlock)1 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)1 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1 BadGraphError (com.jopdesign.common.misc.BadGraphError)1 BadGraphException (com.jopdesign.common.misc.BadGraphException)1 Interval (com.jopdesign.dfa.analyses.Interval)1 LoopBounds (com.jopdesign.dfa.analyses.LoopBounds)1 BadAnnotationException (com.jopdesign.wcet.annotations.BadAnnotationException)1