use of com.jopdesign.common.code.ExecutionContext in project jop by jop-devel.
the class ExecFrequencyAnalysis method getExecCount.
////////////////////////////////////////////////////////////////////////////////////
// Query the analysis results
////////////////////////////////////////////////////////////////////////////////////
@Override
public long getExecCount(MethodInfo methodInfo) {
long count = 0;
for (ExecutionContext ec : callGraph.getNodes(methodInfo)) {
Long c = nodeCount.get(ec);
count += c;
}
return count;
}
use of com.jopdesign.common.code.ExecutionContext in project jop by jop-devel.
the class DFATool method runLocalAnalysis.
public <K, V> Map runLocalAnalysis(Analysis<K, V> localAnalysis, ExecutionContext scope) {
Interpreter<K, V> interpreter = new Interpreter<K, V>(localAnalysis, this);
if (scope == null)
throw new AssertionError("No such method: " + scope);
Context context = new Context();
MethodCode entryCode = scope.getMethodInfo().getCode();
context.stackPtr = entryCode.getMaxLocals();
context.setMethodInfo(scope.getMethodInfo());
context.setCallString(scope.getCallString());
localAnalysis.initialize(scope.getMethodInfo(), context);
/* Here used to be a extremely-hard-to-trackdown bug!
* Without the boolean parameters, getInstructionList() will dispose
* the CFG, a very bad idea during WCET analysis which relies on
* pointer equality for CFG edges :(
*/
InstructionHandle entry = entryCode.getInstructionList(false, false).getStart();
interpreter.interpret(context, entry, new LinkedHashMap<InstructionHandle, ContextMap<K, V>>(), true);
return localAnalysis.getResult();
}
use of com.jopdesign.common.code.ExecutionContext 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.ExecutionContext 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.ExecutionContext 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