use of com.jopdesign.common.code.ControlFlowGraph 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.ControlFlowGraph in project jop by jop-devel.
the class JavaOneProcessPerSupergraphTranslator method computeMethodNestingDepths.
private void computeMethodNestingDepths() throws BadGraphException {
this.methodMNDs = new HashMap<MethodInfo, Integer>();
/* for super graph nodes in topological order */
for (ContextCFG n : superGraph.topologicalOrderIterator().getTopologicalTraversal()) {
MethodInfo methodInvoked = n.getCfg().getMethodInfo();
int maxCaller = 0;
for (Pair<SuperGraph.SuperInvokeEdge, SuperGraph.SuperReturnEdge> callSite : superGraph.getCallSitesInvoking(n)) {
ControlFlowGraph.InvokeNode callSiteNode = callSite.first().getInvokeNode();
ControlFlowGraph cfgInvoker = callSiteNode.invokerFlowGraph();
int callerRootDepth = methodMNDs.get(cfgInvoker.getMethodInfo());
int nestingDepth = cfgInvoker.getLoopColoring().getLoopColor(callSiteNode).size();
maxCaller = Math.max(maxCaller, callerRootDepth + nestingDepth);
}
Integer oldValue = methodMNDs.get(methodInvoked);
if (oldValue == null)
oldValue = 0;
methodMNDs.put(methodInvoked, Math.max(oldValue, maxCaller));
}
if (config.debug)
MiscUtils.printMap(System.out, methodMNDs, 30, 0);
}
use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.
the class JavaTranslator method translateMethod.
protected void translateMethod(TemplateBuilder tb, SubAutomaton methodAutomaton, int mId, MethodInfo mi, InvokeBuilder invokeBuilder) {
/* get flow graph */
ControlFlowGraph cfg = project.getFlowGraph(mi);
MethodBuilder mBuilder = new MethodBuilder(this, tb, invokeBuilder, methodAutomaton, mId, cfg);
mBuilder.build();
}
use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.
the class WCAInvoker method updateWCEP.
private void updateWCEP() {
if (!provideWCAExecCount)
return;
execCounts.clear();
for (MethodInfo root : getWcaTargets()) {
execCounts.put(root, 1L);
}
NodeVisitor<ExecutionContext> visitor = new NodeVisitor<ExecutionContext>() {
@Override
public boolean visitNode(ExecutionContext context) {
MethodInfo method = context.getMethodInfo();
MethodCode code = method.getCode();
long ec = getExecCount(method);
// skip methods which are not on the WCET path.. we can ship iterating over the childs too..
if (ec == 0)
return false;
// iterate over all blocks in the CFG, find all invokes and add block execution counts to invokees
ControlFlowGraph cfg = method.getCode().getControlFlowGraph(false);
for (CFGNode node : cfg.getGraph().vertexSet()) {
if (node instanceof InvokeNode) {
InvokeNode inv = (InvokeNode) node;
long ef = getExecFrequency(method, node);
for (MethodInfo invokee : inv.getImplementingMethods()) {
addExecCount(invokee, ec * ef);
}
} else if (node instanceof BasicBlockNode) {
// check if we have a JVM invoke here (or an invoke not in a dedicated node..)
for (InstructionHandle ih : node.getBasicBlock().getInstructions()) {
if (!code.isInvokeSite(ih))
continue;
long ef = getExecFrequency(method, node);
for (MethodInfo invokee : method.getAppInfo().findImplementations(code.getInvokeSite(ih))) {
addExecCount(invokee, ec * ef);
}
}
}
}
return true;
}
};
TopologicalTraverser<ExecutionContext, ContextEdge> topOrder = new TopologicalTraverser<ExecutionContext, ContextEdge>(wcetTool.getCallGraph().getGraph(), visitor);
topOrder.traverse();
}
use of com.jopdesign.common.code.ControlFlowGraph in project jop by jop-devel.
the class WCAInvoker method getExecFrequency.
@Override
public long getExecFrequency(MethodInfo method, InstructionHandle ih) {
ControlFlowGraph cfg = method.getCode().getControlFlowGraph(false);
BasicBlockNode block = cfg.getHandleNode(ih);
return getExecFrequency(method, block);
}
Aggregations