use of com.jopdesign.wcet.WCETProcessorModel in project jop by jop-devel.
the class MethodBuilder method visitInvokeNode.
public void visitInvokeNode(ControlFlowGraph.InvokeNode n) {
ExecutionContext ctx = new ExecutionContext(n.getBasicBlock().getMethodInfo());
MethodCacheAnalysis mca = new MethodCacheAnalysis(jTrans.getProject());
WCETProcessorModel proc = jTrans.getProject().getWCETProcessorModel();
SubAutomaton invokeAuto;
long staticWCET = proc.basicBlockWCET(ctx, n.getBasicBlock());
if (jTrans.getCacheSim().isAlwaysMiss()) {
staticWCET += mca.getInvokeReturnMissCost(n.getInvokeSite(), CallString.EMPTY);
}
invokeAuto = invokeBuilder.translateInvoke(this, n, staticWCET);
this.nodeTemplates.put(n, invokeAuto);
}
use of com.jopdesign.wcet.WCETProcessorModel in project jop by jop-devel.
the class InlineOptimizer method initialize.
@Override
public void initialize(AnalysisManager analyses, Collection<MethodInfo> roots) {
if (!preciseCycleEstimate) {
ExecutionContext dummy = new ExecutionContext(roots.iterator().next());
WCETProcessorModel pm = analyses.getJCopter().getWCETProcessorModel();
InstructionList il = new InstructionList();
// TODO very messy approximation of exec time
storeCycles = (int) pm.getExecutionTime(dummy, il.append(new ASTORE(10)));
checkNPCycles = 0;
checkNPCycles += (int) pm.getExecutionTime(dummy, il.append(new DUP()));
checkNPCycles += (int) pm.getExecutionTime(dummy, il.append(new IFNONNULL(il.append(new ATHROW()))));
deltaReturnCycles = (int) pm.getExecutionTime(dummy, il.append(new RETURN()));
deltaReturnCycles -= (int) pm.getExecutionTime(dummy, il.append(new GOTO(il.getEnd())));
}
countInvokeSites = 0;
countDevirtualized = 0;
}
use of com.jopdesign.wcet.WCETProcessorModel in project jop by jop-devel.
the class LocalAnalysis method recursiveCost.
public WcetCost recursiveCost(RecursiveAnalysis<AnalysisContextLocal, WcetCost> stagedAnalysis, ControlFlowGraph.InvokeNode n, AnalysisContextLocal ctx) {
CacheCostCalculationMethod cacheMode = ctx.getCacheApproxMode();
if (cacheMode.needsInterProcIPET()) {
throw new AssertionError("Error: Cache Mode " + cacheMode + " not supported using local IPET strategy - " + "it needs an interprocedural IPET analysis");
}
WCETTool project = stagedAnalysis.getWCETTool();
MethodInfo invoker = n.getBasicBlock().getMethodInfo();
MethodInfo invoked = n.getImplementingMethod();
WCETProcessorModel proc = project.getWCETProcessorModel();
MethodCacheAnalysis mca = new MethodCacheAnalysis(project);
long cacheCost;
AnalysisContextLocal recCtx = ctx.withCallString(ctx.getCallString().push(n, maxCallstringLength));
WcetCost recCost = stagedAnalysis.computeCost(invoked, recCtx);
long nonLocalExecCost = recCost.getCost() - recCost.getCacheCost();
long nonLocalCacheCost = recCost.getCacheCost();
long invokeReturnCost = mca.getInvokeReturnMissCost(n.getInvokeSite(), ctx.getCallString());
if (proc.getMethodCache().getNumBlocks() == 0 || cacheMode == CacheCostCalculationMethod.ALWAYS_HIT) {
cacheCost = 0;
} else if (project.getCallGraph().isLeafMethod(invoked)) {
cacheCost = invokeReturnCost + nonLocalCacheCost;
} else if (cacheMode == CacheCostCalculationMethod.ALL_FIT_SIMPLE && allFit(project, invoked, recCtx.getCallString())) {
long returnCost = mca.getMissOnceCost(invoker, false);
/* Maybe its better not to apply the all-fit heuristic ... */
long noAllFitCost = recCost.getCost() + invokeReturnCost;
/* Compute cost without method cache */
AnalysisContextLocal ahCtx = recCtx.withCacheApprox(CacheCostCalculationMethod.ALWAYS_HIT);
long alwaysHitCost = stagedAnalysis.computeCost(invoked, ahCtx).getCost();
/* Compute penalty for loading each method exactly once */
long allFitPenalty = mca.getMissOnceCummulativeCacheCost(invoked, assumeMissOnceOnInvoke);
long allFitCacheCost = allFitPenalty + returnCost;
/* Cost All-Fit: recursive + penalty for loading once + return to caller */
long allFitCost = alwaysHitCost + allFitCacheCost;
/* Choose the better approximation */
if (allFitCost <= noAllFitCost) {
cacheCost = allFitCacheCost;
nonLocalExecCost = alwaysHitCost;
} else {
cacheCost = invokeReturnCost + nonLocalCacheCost;
}
} else {
/* ALWAYS MISS or doesn't fit */
cacheCost = invokeReturnCost + nonLocalCacheCost;
}
WcetCost cost = new WcetCost();
cost.addNonLocalCost(nonLocalExecCost);
cost.addCacheCost(cacheCost);
logger.debug("Recursive WCET computation: " + invoked + ". invoke return cache cost: " + invokeReturnCost + ". non-local cache cost: " + nonLocalCacheCost + ". cummulative cache cost: " + cacheCost + " non local execution cost: " + nonLocalExecCost);
return cost;
}
Aggregations