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);
}
}
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;
}
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;
}
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 <= 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;
}
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;
}
}
Aggregations