use of com.jopdesign.common.MethodInfo in project jop by jop-devel.
the class AllocationWcetModel method getExecutionTime.
public long getExecutionTime(ExecutionContext context, InstructionHandle ih) {
int opcode = ih.getInstruction().getOpcode();
MethodInfo mCtx = context.getMethodInfo();
if (opcode == Constants.NEW) {
NEW insn = (NEW) ih.getInstruction();
ObjectType type = insn.getLoadClassType(mCtx.getConstantPoolGen());
return computeObjectSize(getFieldSize(getObjectFields(type.getClassName())));
} else if (opcode == Constants.NEWARRAY || opcode == Constants.ANEWARRAY) {
int typeSize = 1;
if (ih.getInstruction() instanceof NEWARRAY) {
NEWARRAY insn = (NEWARRAY) ih.getInstruction();
if (insn.getTypecode() == Constants.T_DOUBLE || insn.getTypecode() == Constants.T_LONG) {
typeSize = 2;
}
}
return computeArraySize(getArrayBound(context, ih, 0) * typeSize);
} else if (opcode == Constants.MULTIANEWARRAY) {
MULTIANEWARRAY insn = (MULTIANEWARRAY) ih.getInstruction();
int dim = insn.getDimensions();
long count = 1;
long size = 0;
for (int i = dim - 1; i >= 0; i--) {
long bound = getArrayBound(context, ih, i);
size += count * computeArraySize(bound);
count *= bound;
}
return size;
} else {
return 0;
}
}
use of com.jopdesign.common.MethodInfo in project jop by jop-devel.
the class TreeAnalysis method computeWCET.
public long computeWCET(MethodInfo targetMethod) {
this.methodWCET = new HashMap<MethodInfo, Long>();
List<MethodInfo> reachable = project.getCallGraph().getReachableImplementations(targetMethod);
Collections.reverse(reachable);
for (MethodInfo mi : reachable) {
ControlFlowGraph cfg = project.getFlowGraph(mi);
Map<CFGNode, Long> localCost = new HashMap<CFGNode, Long>();
LocalCostVisitor lcv = new LocalCostVisitor(new AnalysisContextCallString(CallString.EMPTY), project);
for (CFGNode n : cfg.vertexSet()) {
localCost.put(n, lcv.computeCost(n).getCost());
}
ProgressMeasure<CFGNode, ControlFlowGraph.CFGEdge> pm = new ProgressMeasure<CFGNode, ControlFlowGraph.CFGEdge>(cfg.getGraph(), cfg.getLoopColoring(), extractUBs(cfg.buildLoopBoundMap()), localCost);
long wcet = pm.getMaxProgress().get(cfg.getExit());
methodWCET.put(mi, wcet);
}
return methodWCET.get(targetMethod);
}
use of com.jopdesign.common.MethodInfo in project jop by jop-devel.
the class MethodCacheAnalysis method getMissOnceCummulativeCacheCost.
/**
* Compute the maximal total cache-miss penalty for <strong>invoking and executing</strong>
* m.
* <p>
* Precondition: The set of all methods reachable from <code>m</code> fit into the cache
* </p><p>
* Algorithm: If all methods reachable from <code>m</code> (including <code>m</code>) fit
* into the cache, we can compute the WCET of <m> using the {@code ALWAYS_HIT} cache
* approximation, and then add the sum of cache miss penalties for every reachable method.
* </p><p>
* Note that when using this approximation, we attribute the
* total cache miss cost to the invocation of that method.
* </p><p>
* Explanation: We know that there is only one cache miss per method, but for FIFO caches we
* do not know when the cache miss will occur (on return or invoke), except for leaf methods.
* Let <code>h</code> be the number of cycles hidden by <strong>any</strong> return or
* invoke instructions. Then the cache miss penalty is bounded by <code>(b-h)</code> per
* method.
* </p>
* @param m The method invoked
* @return the cache miss penalty
* @deprecated ported from the old method cache analysis framework
*/
@Deprecated
public long getMissOnceCummulativeCacheCost(MethodInfo m, boolean assumeOnInvoke) {
long miss = 0;
for (MethodInfo reachable : wcetTool.getCallGraph().getReachableImplementationsSet(m)) {
miss += getMissOnceCost(reachable, assumeOnInvoke);
}
Logger.getLogger(this.getClass()).debug("getMissOnceCummulativeCacheCost for " + m + "/" + (assumeOnInvoke ? "invoke" : "return") + ":" + miss);
return miss;
}
use of com.jopdesign.common.MethodInfo in project jop by jop-devel.
the class MethodCacheAnalysis method getInvokeReturnCacheCosts.
public long getInvokeReturnCacheCosts(ExecFrequencyProvider ecp, InvokeSite invokeSite) {
if (analysisType == AnalysisType.ALWAYS_HIT)
return 0;
AppInfo appInfo = AppInfo.getSingleton();
int size = 0;
for (MethodInfo method : appInfo.findImplementations(invokeSite)) {
size = Math.max(size, getMethodSize(method));
}
size = MiscUtils.bytesToWords(size);
int sizeInvoker = getMethodSize(invokeSite.getInvoker());
sizeInvoker = MiscUtils.bytesToWords(sizeInvoker);
long invokeCosts = cache.getMissPenaltyOnInvoke(size, invokeSite.getInvokeInstruction());
long returnCosts = cache.getMissPenaltyOnReturn(sizeInvoker, invokeSite.getInvokeeRef().getDescriptor().getType());
return getInvokeReturnCacheCosts(ecp, invokeSite, invokeCosts, returnCosts);
}
use of com.jopdesign.common.MethodInfo in project jop by jop-devel.
the class MethodCacheAnalysis method getMissCountChangeSet.
/**
* @param ecp exec count provider
* @return all methods for which the cache costs of the contained invoke sites changed, either due to classification
* changes or due to execution count changes.
*/
public Set<MethodInfo> getMissCountChangeSet(ExecFrequencyProvider ecp) {
if (analysisType == AnalysisType.ALWAYS_HIT)
return Collections.emptySet();
Set<MethodInfo> countChanges = new LinkedHashSet<MethodInfo>(classifyChanges);
// we check the exec analysis for changed exec counts,
// need to update change sets since cache miss counts changed for cache-misses
Set<MethodInfo> methods = ecp.getChangeSet();
if (analysisType == AnalysisType.ALWAYS_MISS) {
countChanges.addAll(methods);
return countChanges;
}
for (MethodInfo method : methods) {
if (!allFit(method)) {
countChanges.add(method);
}
}
if (analysisType == AnalysisType.ALL_FIT_REGIONS) {
for (MethodInfo method : ecp.getChangeSet()) {
if (!classifyChanges.contains(method)) {
continue;
}
// all methods for which the classification changed and for which the exe count changed..
for (ExecutionContext context : callGraph.getNodes(method)) {
// add all reachable methods
countChanges.addAll(reachableMethods.get(context));
}
}
}
return countChanges;
}
Aggregations