Search in sources :

Example 81 with MethodInfo

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;
    }
}
Also used : MULTIANEWARRAY(org.apache.bcel.generic.MULTIANEWARRAY) NEWARRAY(org.apache.bcel.generic.NEWARRAY) NEW(org.apache.bcel.generic.NEW) ObjectType(org.apache.bcel.generic.ObjectType) MULTIANEWARRAY(org.apache.bcel.generic.MULTIANEWARRAY) MethodInfo(com.jopdesign.common.MethodInfo)

Example 82 with MethodInfo

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);
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) HashMap(java.util.HashMap) ProgressMeasure(com.jopdesign.common.graphutils.ProgressMeasure) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 83 with MethodInfo

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;
}
Also used : MethodInfo(com.jopdesign.common.MethodInfo)

Example 84 with MethodInfo

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);
}
Also used : MethodInfo(com.jopdesign.common.MethodInfo) AppInfo(com.jopdesign.common.AppInfo)

Example 85 with MethodInfo

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExecutionContext(com.jopdesign.common.code.ExecutionContext) MethodInfo(com.jopdesign.common.MethodInfo)

Aggregations

MethodInfo (com.jopdesign.common.MethodInfo)108 LinkedHashSet (java.util.LinkedHashSet)21 InstructionHandle (org.apache.bcel.generic.InstructionHandle)20 ClassInfo (com.jopdesign.common.ClassInfo)19 ExecutionContext (com.jopdesign.common.code.ExecutionContext)16 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)13 ArrayList (java.util.ArrayList)13 CallString (com.jopdesign.common.code.CallString)12 ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)12 HashMap (java.util.HashMap)10 Set (java.util.Set)10 LinkedHashMap (java.util.LinkedHashMap)9 Instruction (org.apache.bcel.generic.Instruction)9 FieldInfo (com.jopdesign.common.FieldInfo)8 MethodCode (com.jopdesign.common.MethodCode)8 AppInfo (com.jopdesign.common.AppInfo)7 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)7 InvokeSite (com.jopdesign.common.code.InvokeSite)7 MemberID (com.jopdesign.common.type.MemberID)7 Context (com.jopdesign.dfa.framework.Context)7