Search in sources :

Example 1 with LoopBounds

use of com.jopdesign.dfa.analyses.LoopBounds in project jop by jop-devel.

the class DFATool method runLoopboundAnalysis.

public void runLoopboundAnalysis(int callstringLength) {
    LoopBounds dfaLoopBounds = new LoopBounds(callstringLength);
    runAnalysis(dfaLoopBounds);
    setLoopBounds(dfaLoopBounds);
}
Also used : LoopBounds(com.jopdesign.dfa.analyses.LoopBounds)

Example 2 with LoopBounds

use of com.jopdesign.dfa.analyses.LoopBounds in project jop by jop-devel.

the class WCETEventHandler method dfaLoopBound.

/**
     * Get a loop bound from the DFA for a certain loop and call string and
     * merge it with the annotated value.
     * @return The loop bound to be used for further computations
     */
public LoopBound dfaLoopBound(BasicBlock headOfLoopBlock, ExecutionContext eCtx, LoopBound annotatedBound) {
    LoopBounds lbAnalysis = project.getDfaLoopBounds();
    if (lbAnalysis == null)
        return annotatedBound;
    MethodInfo methodInfo = headOfLoopBlock.getMethodInfo();
    int dfaUpperBound;
    // FIXME: Bad style
    try {
        dfaUpperBound = lbAnalysis.getBound(headOfLoopBlock.getLastInstruction(), eCtx.getCallString());
    } catch (NullPointerException ex) {
        logger.error("Failed to retrieve DFA loop bound values", ex);
        dfaUpperBound = -1;
    }
    if (dfaUpperBound < 0) {
        if (!printedLoopBoundInfoMessage.contains(headOfLoopBlock)) {
            logger.info("No DFA bound for " + methodInfo + "/" + headOfLoopBlock + ". Using manual bound: " + annotatedBound);
            printedLoopBoundInfoMessage.add(headOfLoopBlock);
        }
        return annotatedBound;
    }
    LoopBound loopBound;
    if (annotatedBound == null) {
        loopBound = LoopBound.boundedAbove(dfaUpperBound);
        logger.debug("Only DFA bound for " + methodInfo + "headOfLoopBlock");
    } else {
        loopBound = annotatedBound.clone();
        // More testing would be nice
        loopBound.addBound(LoopBoundExpr.numUpperBound(dfaUpperBound), SymbolicMarker.LOOP_ENTRY);
        long loopUb = annotatedBound.getSimpleLoopBound().upperBound(eCtx);
        if (dfaUpperBound < loopUb) {
            /* This isn't unusual (context dependent loop bounds) */
            if (logger.isDebugEnabled()) {
                logger.debug("DFA analysis reports a smaller upper bound :" + dfaUpperBound + " < " + loopUb + " for " + methodInfo + "/" + headOfLoopBlock);
            }
        } else if (dfaUpperBound > loopUb) {
            /* In principle this is possible, but usually a bad sign */
            logger.warn("DFA analysis reports a larger upper bound: " + dfaUpperBound + " > " + loopUb + " for " + methodInfo);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("DFA and annotated loop bounds match for " + methodInfo);
            }
        }
    }
    if (!printedLoopBoundInfoMessage.contains(headOfLoopBlock)) {
        logger.info("DFA bound for " + methodInfo + "/" + headOfLoopBlock + ": " + loopBound + ". Manual bound info: " + annotatedBound);
        printedLoopBoundInfoMessage.add(headOfLoopBlock);
    }
    return loopBound;
}
Also used : LoopBounds(com.jopdesign.dfa.analyses.LoopBounds) LoopBound(com.jopdesign.common.code.LoopBound) MethodInfo(com.jopdesign.common.MethodInfo)

Example 3 with LoopBounds

use of com.jopdesign.dfa.analyses.LoopBounds in project jop by jop-devel.

the class WCETTool method dfaInfeasibleEdge.

/**
     * Get infeasible edges for certain basic block call string
     * @param cfg the CFG containing the block
     * @param block get infeasible outgoing edges for the block
     * @param cs the callstring
     * @return The infeasible edges for this basic block
     */
private List<CFGEdge> dfaInfeasibleEdge(ControlFlowGraph cfg, BasicBlock block, CallString cs) {
    List<CFGEdge> retval = new LinkedList<CFGEdge>();
    if (getDfaLoopBounds() != null) {
        LoopBounds lbs = getDfaLoopBounds();
        Set<FlowEdge> edges = lbs.getInfeasibleEdges(block.getLastInstruction(), cs);
        for (FlowEdge e : edges) {
            BasicBlockNode head = cfg.getHandleNode(e.getHead());
            BasicBlockNode tail = cfg.getHandleNode(e.getTail());
            CFGEdge edge = cfg.getEdge(tail, head);
            if (edge != null) {
                retval.add(edge);
            } else {
            // edge does was removed from the CFG
            // logger.warn("The infeasible edge between "+head+" and "+tail+" does not exist");                	
            }
        }
    }
    return retval;
}
Also used : FlowEdge(com.jopdesign.dfa.framework.FlowEdge) LoopBounds(com.jopdesign.dfa.analyses.LoopBounds) BasicBlockNode(com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode) LinkedList(java.util.LinkedList) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Aggregations

LoopBounds (com.jopdesign.dfa.analyses.LoopBounds)3 MethodInfo (com.jopdesign.common.MethodInfo)1 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)1 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)1 LoopBound (com.jopdesign.common.code.LoopBound)1 FlowEdge (com.jopdesign.dfa.framework.FlowEdge)1 LinkedList (java.util.LinkedList)1