Search in sources :

Example 6 with BasicBlock

use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.

the class ObjectCacheAnalysis method extractCost.

/**
	 * 
	 * @param segment the segment analyzed
	 * @param lpCost the lp objective value
	 * @param flowMap the lp assignment for variables
	 * @param accessCostInfo information on object cache cost edges
	 * @param costModel the object cache cost model
	 * @param refMissEdges the object cache cost edges for references
	 * @param blockMissEdges the object cache cost edges for blocks
	 * @return
	 */
private ObjectCache.ObjectCacheCost extractCost(Segment segment, long lpCost, Map<SuperGraphEdge, Long> flowMap, AccessCostInfo accessCostInfo, ObjectCacheCostModel costModel, Set<SuperGraphEdge> refMissEdges, Set<SuperGraphEdge> blockMissEdges) {
    long missCount = 0;
    /* miss count */
    long totalMissCost = 0;
    /* has to be equal to (cost - bypass cost) */
    long bypassAccesses = 0;
    /* bypassed fields accesses */
    long fieldAccesses = 0;
    /* cached fields accessed */
    long totalBypassCost = 0;
    for (SuperGraphEdge edge : segment.getEdges()) {
        long edgeFreq = flowMap.get(edge);
        SuperGraphNode node = edge.getTarget();
        /* Compute cost for basic block */
        BasicBlock bb = node.getCFGNode().getBasicBlock();
        if (bb == null)
            continue;
        long missCost = accessCostInfo.getMissCost(node) * edgeFreq;
        totalMissCost += missCost;
        totalBypassCost += accessCostInfo.getBypassCost(node) * edgeFreq;
        /* Calculate number of unpredictable always-miss accesses, and record them */
        long alwaysMissCost = costModel.getReplaceLineCost() + costModel.getLoadCacheBlockCost();
        if (alwaysMissCost > 0) {
            missCount += missCost / alwaysMissCost;
        }
        /* count normal and bypass accesses in the basic block */
        for (InstructionHandle ih : bb.getInstructions()) {
            String handleType = getHandleType(project, node.getCfg(), ih);
            if (handleType == null)
                continue;
            /* No getfield/handle access */
            if (!isFieldCached(project, node.getCfg(), ih, maxCachedFieldIndex)) {
                bypassAccesses += edgeFreq;
            } else {
                fieldAccesses += edgeFreq;
            }
        }
    }
    /* For each miss edge, there is an associated cost; moreover
		 * fill-word & single-field: missCount = sum of miss block variables
		 * fill-line: missCount = sum of miss object reference variables
		 */
    long totalRefMisses = 0;
    for (SuperGraphEdge refMissEdge : refMissEdges) {
        totalRefMisses += flowMap.get(refMissEdge);
    }
    totalMissCost += costModel.getReplaceLineCost() * totalRefMisses;
    long totalBlockMisses = 0;
    for (SuperGraphEdge blockMissEdge : blockMissEdges) {
        totalBlockMisses += flowMap.get(blockMissEdge);
    }
    totalMissCost += costModel.getLoadCacheBlockCost() * totalBlockMisses;
    missCount += totalBlockMisses;
    if (totalMissCost + totalBypassCost != lpCost) {
        WCETTool.logger.warn(String.format("Error in calculating missCost in all fit-area (misscount = %d): %d but should be %d (%d - %d)", missCount, totalMissCost, lpCost - totalBypassCost, lpCost, totalBypassCost));
    }
    ObjectCache.ObjectCacheCost ocCost = new ObjectCache.ObjectCacheCost(missCount, totalMissCost, bypassAccesses, totalBypassCost, fieldAccesses);
    return ocCost;
}
Also used : ObjectCache(com.jopdesign.wcet.jop.ObjectCache) ObjectCacheCost(com.jopdesign.wcet.jop.ObjectCache.ObjectCacheCost) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) BasicBlock(com.jopdesign.common.code.BasicBlock) SuperGraphNode(com.jopdesign.common.code.SuperGraph.SuperGraphNode) CallString(com.jopdesign.common.code.CallString) ObjectCacheCost(com.jopdesign.wcet.jop.ObjectCache.ObjectCacheCost) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Example 7 with BasicBlock

use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.

the class WCETNodeLabeller method addNodeLabel.

@Override
protected void addNodeLabel(BasicBlockNode n, StringBuilder nodeInfo) {
    BasicBlock codeBlock = n.getBasicBlock();
    nodeInfo.append(project.getWCETProcessorModel().basicBlockWCET(new ExecutionContext(codeBlock.getMethodInfo()), codeBlock) + " Cyc, ");
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) BasicBlock(com.jopdesign.common.code.BasicBlock)

Example 8 with BasicBlock

use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.

the class ConstantCache method build.

public ConstantCache build() {
    List<MethodInfo> methods = project.getCallGraph().getReachableImplementations(project.getTargetMethod());
    for (int i = methods.size() - 1; i >= 0; i--) {
        MethodInfo mi = methods.get(i);
        ControlFlowGraph cfg = project.getFlowGraph(mi);
        for (CFGNode n : cfg.vertexSet()) {
            BasicBlock bb = n.getBasicBlock();
            if (bb == null)
                continue;
            for (InstructionHandle ii : bb.getInstructions()) {
                extractConstantAddresses(cfg, ii);
            }
        }
    }
    return this;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) BasicBlock(com.jopdesign.common.code.BasicBlock) MethodInfo(com.jopdesign.common.MethodInfo) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Aggregations

BasicBlock (com.jopdesign.common.code.BasicBlock)8 InstructionHandle (org.apache.bcel.generic.InstructionHandle)5 MethodInfo (com.jopdesign.common.MethodInfo)3 CallString (com.jopdesign.common.code.CallString)3 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)3 SuperGraphNode (com.jopdesign.common.code.SuperGraph.SuperGraphNode)3 ClassInfo (com.jopdesign.common.ClassInfo)2 ExecutionContext (com.jopdesign.common.code.ExecutionContext)2 SymbolicAddress (com.jopdesign.dfa.analyses.SymbolicAddress)2 HashSet (java.util.HashSet)2 MethodCode (com.jopdesign.common.MethodCode)1 ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)1 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)1 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)1 LoopBound (com.jopdesign.common.code.LoopBound)1 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1 AccessCostInfo (com.jopdesign.wcet.analysis.cache.ObjectCacheAnalysis.AccessCostInfo)1 BadAnnotationException (com.jopdesign.wcet.annotations.BadAnnotationException)1 SourceAnnotations (com.jopdesign.wcet.annotations.SourceAnnotations)1 ObjectCache (com.jopdesign.wcet.jop.ObjectCache)1