use of com.jopdesign.common.MethodInfo 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.MethodInfo 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);
}
}
use of com.jopdesign.common.MethodInfo 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.MethodInfo in project jop by jop-devel.
the class MethodCacheAnalysis method checkCache.
/**
* Check that cache is big enough to hold any method possibly invoked
* Return largest method
*/
public static MethodInfo checkCache(WCETTool wcetTool, Iterable<MethodInfo> methods) throws AppInfoException {
MethodCache methodCache = wcetTool.getWCETProcessorModel().getMethodCache();
int maxWords = 0;
MethodInfo largestMethod = null;
// for (ClassInfo ci : project.getAppInfo().getClassInfos()) {
for (MethodInfo mi : methods) {
MethodCode code = mi.getCode();
if (code == null)
continue;
// FIXME: using getNumberOfBytes(false) here to be compatible to old behaviour.
// should probably be getNumberOfBytes()
int size = code.getNumberOfBytes(false);
int words = MiscUtils.bytesToWords(size);
if (!methodCache.fitsInCache(words)) {
throw new AppInfoException("Cache to small for target method: " + mi.getFQMethodName() + " / " + words + " words");
}
if (words >= maxWords) {
largestMethod = mi;
maxWords = words;
}
}
return largestMethod;
}
use of com.jopdesign.common.MethodInfo in project jop by jop-devel.
the class MethodCacheAnalysis method getInvokeReturnMissCost.
/* utility functions */
/**
* Get the maximum method cache miss penalty for invoking {@code invoked} and returning to {@code invoker}.<br/>
* Also works with virtual invokes (taking the maximum cost)
* @param invokeSite the invoke site
* @param context call context
* @return miss penalty in cycles
*/
public long getInvokeReturnMissCost(InvokeSite invokeSite, CallString context) {
ControlFlowGraph invokerCfg = wcetTool.getFlowGraph(invokeSite.getInvoker());
long rMiss = methodCache.getMissPenaltyOnReturn(invokerCfg.getNumberOfWords(), invokeSite.getInvokeeRef().getDescriptor().getType());
long iMissMax = 0;
for (MethodInfo target : wcetTool.findImplementations(invokeSite.getInvoker(), invokeSite.getInstructionHandle(), context)) {
ControlFlowGraph invokedCfg = wcetTool.getFlowGraph(target);
long iMiss = methodCache.getMissPenaltyOnInvoke(invokedCfg.getNumberOfWords(), invokeSite.getInstructionHandle().getInstruction());
if (iMiss > iMissMax)
iMissMax = iMiss;
}
return iMissMax + rMiss;
}
Aggregations