Search in sources :

Example 1 with BasicBlock

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

the class ObjectCacheAnalysis method getSaturatedTypes.

/**
 * Traverse vertex set. Collect those types where we could not resolve
 * the symbolic object names. (Not too useful in the analysis, but useful
 * for debugging)
 */
public HashSet<String> getSaturatedTypes(Segment segment, LocalPointsToResult usedRefs) {
    HashSet<String> topTypes = new HashSet<String>();
    for (SuperGraphNode n : segment.getNodes()) {
        BasicBlock bb = n.getCFGNode().getBasicBlock();
        if (bb == null)
            continue;
        CallString cs = n.getContextCFG().getCallString();
        for (InstructionHandle ih : bb.getInstructions()) {
            BoundedSet<SymbolicAddress> refs;
            if (usedRefs.containsKey(ih)) {
                refs = usedRefs.get(ih, cs);
                String handleType = getHandleType(project, n.getCfg(), ih);
                if (handleType == null)
                    continue;
                if (refs.isSaturated()) {
                    topTypes.add(handleType);
                }
            }
        }
    }
    return topTypes;
}
Also used : BasicBlock(com.jopdesign.common.code.BasicBlock) SuperGraphNode(com.jopdesign.common.code.SuperGraph.SuperGraphNode) CallString(com.jopdesign.common.code.CallString) SymbolicAddress(com.jopdesign.dfa.analyses.SymbolicAddress) InstructionHandle(org.apache.bcel.generic.InstructionHandle) HashSet(java.util.HashSet) CallString(com.jopdesign.common.code.CallString)

Example 2 with BasicBlock

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

the class WCETTool method getInfeasibleEdges.

/**
 * Get infeasible edges for certain call string
 *
 * @param cfg the controlflowgraph of the method
 * @param cs the callstring of the method
 * @return The infeasible edges
 */
public List<CFGEdge> getInfeasibleEdges(ControlFlowGraph cfg, CallString cs) {
    List<CFGEdge> edges = new ArrayList<CFGEdge>();
    for (BasicBlock b : cfg.getBlocks()) {
        List<CFGEdge> edge = dfaInfeasibleEdge(cfg, b, cs);
        edges.addAll(edge);
    }
    return edges;
}
Also used : ArrayList(java.util.ArrayList) BasicBlock(com.jopdesign.common.code.BasicBlock) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 3 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 4 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)

Example 5 with BasicBlock

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

the class ObjectCacheAnalysis method extractAccessesAndCosts.

/**
 * Traverse vertex set.
 * <p>Add vertex to access set of referenced addresses
 * For references whose type cannot be fully resolved, add a
 * cost of 1.</p>
 * <p>FIXME: We should deal with subtyping (or better use storage based alias-analysis)</p>
 *
 * @param nodes
 * @param usedRefs the results of the local points-to analysis, or {@code null} for always miss costs
 * @param costModel
 */
private AccessCostInfo extractAccessesAndCosts(Iterable<SuperGraphNode> nodes, LocalPointsToResult usedRefs, ObjectCacheCostModel costModel) {
    AccessCostInfo aci = new AccessCostInfo();
    for (SuperGraphNode node : nodes) {
        /* Compute cost for basic block */
        BasicBlock bb = node.getCFGNode().getBasicBlock();
        if (bb == null)
            continue;
        long bypassCost = 0;
        long alwaysMissCost = 0;
        CallString cs = node.getContextCFG().getCallString();
        for (InstructionHandle ih : bb.getInstructions()) {
            String handleType = getHandleType(project, node.getCfg(), ih);
            if (handleType == null)
                continue;
            /* No getfield/handle access */
            int fieldIndex = getFieldIndex(project, node.getCfg(), ih);
            int blockIndex = getBlockIndex(fieldIndex);
            if (fieldIndex > this.maxCachedFieldIndex) {
                bypassCost += costModel.getFieldAccessCostBypass();
                continue;
            }
            BoundedSet<SymbolicAddress> refs = null;
            if (usedRefs != null) {
                if (!usedRefs.containsKey(ih)) {
                    usedRefs = null;
                    WCETTool.logger.error("No DFA results for: " + ih.getInstruction() + " with field " + ((FieldInstruction) ih.getInstruction()).getFieldName(bb.cpg()));
                } else {
                    refs = usedRefs.get(ih, cs);
                    if (refs.isSaturated())
                        refs = null;
                }
            }
            if (refs == null) {
                alwaysMissCost += costModel.getReplaceLineCost() + costModel.getLoadCacheBlockCost();
            } else {
                for (SymbolicAddress ref : refs.getSet()) {
                    aci.addRefAccess(ref, node);
                    aci.addBlockAccess(ref.accessArray(blockIndex), node);
                    // Handle getfield_long / getfield_double
                    if (getCachedType(project, node.getCfg(), ih) == Type.LONG || getCachedType(project, node.getCfg(), ih) == Type.DOUBLE) {
                        if (blockIndex + 1 > this.maxCachedFieldIndex) {
                            bypassCost += costModel.getFieldAccessCostBypass();
                        } else {
                            aci.addBlockAccess(ref.accessArray(blockIndex + 1), node);
                        }
                    }
                }
            }
        }
        aci.putBypassCost(node, bypassCost);
        aci.putStaticCost(node, bypassCost + alwaysMissCost);
    }
    return aci;
}
Also used : AccessCostInfo(com.jopdesign.wcet.analysis.cache.ObjectCacheAnalysis.AccessCostInfo) BasicBlock(com.jopdesign.common.code.BasicBlock) SuperGraphNode(com.jopdesign.common.code.SuperGraph.SuperGraphNode) CallString(com.jopdesign.common.code.CallString) FieldInstruction(org.apache.bcel.generic.FieldInstruction) SymbolicAddress(com.jopdesign.dfa.analyses.SymbolicAddress) InstructionHandle(org.apache.bcel.generic.InstructionHandle) CallString(com.jopdesign.common.code.CallString)

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