Search in sources :

Example 1 with ClassReport

use of com.jopdesign.wcet.report.ClassReport in project jop by jop-devel.

the class RecursiveWcetAnalysis method updateClassReport.

/**
     * Update class report (cost per line number)
     *
     * @param key
     * @param sol FIXME: Currently only reported once per method
     */
private void updateClassReport(CacheKey key, LocalWCETSolution sol) {
    MethodInfo m = key.m;
    if (costsPerLineReported.contains(m))
        return;
    costsPerLineReported.add(m);
    Map<CFGNode, WcetCost> nodeCosts = sol.getNodeCostMap();
    HashMap<CFGNode, String> nodeFlowCostDescrs = new HashMap<CFGNode, String>();
    // for autogenerated code
    long anonymousCost = 0;
    for (Entry<CFGNode, WcetCost> entry : nodeCosts.entrySet()) {
        CFGNode n = entry.getKey();
        WcetCost cost = entry.getValue();
        if (sol.getNodeFlow(n) > 0) {
            nodeFlowCostDescrs.put(n, cost.toString());
            BasicBlock basicBlock = n.getBasicBlock();
            /* prototyping */
            if (basicBlock != null) {
                Map<ClassInfo, TreeSet<Integer>> lineMap = basicBlock.getSourceLines();
                if (lineMap.isEmpty()) {
                    logger.error("No source code lines associated with basic block " + basicBlock + " in " + m + " ! ");
                    continue;
                }
                // we attach to the first class in the map only
                ClassInfo cli = lineMap.keySet().iterator().next();
                TreeSet<Integer> lineRange = lineMap.get(cli);
                ClassReport cr = getWCETTool().getReport().getClassReport(cli);
                long newCost = sol.getNodeFlow(n) * nodeCosts.get(n).getCost();
                // Autogenerated code, attach to next entry
                if (lineRange.isEmpty()) {
                    anonymousCost += newCost;
                    continue;
                } else {
                    newCost += anonymousCost;
                    anonymousCost = 0;
                }
                Long oldCost = (Long) cr.getLineProperty(lineRange.first(), "cost");
                if (oldCost == null)
                    oldCost = 0L;
                if (logger.isTraceEnabled()) {
                    logger.trace("Attaching cost " + oldCost + " + " + newCost + " to line " + lineRange.first() + " in " + basicBlock.getMethodInfo());
                }
                cr.addLineProperty(lineRange.first(), "cost", oldCost + newCost);
                for (int i : lineRange) {
                    cr.addLineProperty(i, "color", "red");
                }
            }
        } else {
            nodeFlowCostDescrs.put(n, "" + nodeCosts.get(n).getCost());
        }
    }
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) HashMap(java.util.HashMap) ClassReport(com.jopdesign.wcet.report.ClassReport) BasicBlock(com.jopdesign.common.code.BasicBlock) TreeSet(java.util.TreeSet) MethodInfo(com.jopdesign.common.MethodInfo) ClassInfo(com.jopdesign.common.ClassInfo)

Aggregations

ClassInfo (com.jopdesign.common.ClassInfo)1 MethodInfo (com.jopdesign.common.MethodInfo)1 BasicBlock (com.jopdesign.common.code.BasicBlock)1 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)1 ClassReport (com.jopdesign.wcet.report.ClassReport)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1