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