Search in sources :

Example 21 with ControlFlowGraph

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

the class Report method generateInfoPages.

/**
     * Dump the project's input (callgraph,cfgs)
     *
     * @throws IOException
     */
public void generateInfoPages() throws IOException {
    this.addStat("#classes", project.getCallGraph().getClassInfos().size());
    this.addStat("#methods", project.getCallGraph().getReachableImplementationsSet(project.getTargetMethod()).size());
    this.addStat("max call stack ", project.getCallGraph().getMaximalCallStack());
    this.addStat("largest method size (in bytes)", project.getCallGraph().getLargestMethod().getNumberOfBytes());
    this.addStat("largest method size (in words)", project.getCallGraph().getLargestMethod().getNumberOfWords());
    this.addStat("total size of task (in bytes)", project.getCallGraph().getTotalSizeInBytes());
    generateInputOverview();
    this.addPage("details", null);
    for (MethodInfo m : project.getCallGraph().getReachableImplementationsSet(project.getTargetMethod())) {
        for (LineNumber ln : m.getCode().getLineNumberTable().getLineNumberTable()) {
            getClassReport(m.getClassInfo()).addLinePropertyIfNull(ln.getLineNumber(), "color", "lightgreen");
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Generating report for method: " + m);
        }
        ControlFlowGraph flowGraph = project.getFlowGraph(m);
        Map<String, Object> stats = new TreeMap<String, Object>();
        stats.put("#nodes", flowGraph.vertexSet().size() - 2);
        stats.put("number of words", flowGraph.getNumberOfWords());
        this.addDetailedReport(m, new DetailedMethodReport(config, project, m, "CFG", stats, null, null), true);
        generateDetailedReport(m);
    }
    for (ClassInfo c : project.getCallGraph().getClassInfos()) {
        ClassReport cr = getClassReport(c);
        String page = pageOf(c);
        HashMap<String, Object> ctx = new HashMap<String, Object>();
        ctx.put("classreport", cr);
        try {
            this.generateFile("class.vm", config.getReportFile(page), ctx);
        } catch (Exception e) {
            logger.error(e);
        }
        addPage("details/" + c.getClassName(), page);
    }
}
Also used : HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) LineNumber(org.apache.bcel.classfile.LineNumber) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ResourceNotFoundException(org.apache.velocity.exception.ResourceNotFoundException) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo) ClassInfo(com.jopdesign.common.ClassInfo)

Example 22 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph 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 23 with ControlFlowGraph

use of com.jopdesign.common.code.ControlFlowGraph 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)

Aggregations

ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)23 MethodInfo (com.jopdesign.common.MethodInfo)12 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)10 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)5 ExecutionContext (com.jopdesign.common.code.ExecutionContext)5 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)4 LoopBound (com.jopdesign.common.code.LoopBound)4 BadGraphError (com.jopdesign.common.misc.BadGraphError)3 BadGraphException (com.jopdesign.common.misc.BadGraphException)3 HashMap (java.util.HashMap)3 InstructionHandle (org.apache.bcel.generic.InstructionHandle)3 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)2 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)2 ProgressMeasure (com.jopdesign.common.graphutils.ProgressMeasure)2 ClassInfo (com.jopdesign.common.ClassInfo)1 MethodCode (com.jopdesign.common.MethodCode)1 BasicBlock (com.jopdesign.common.code.BasicBlock)1 CallString (com.jopdesign.common.code.CallString)1 InvokeNode (com.jopdesign.common.code.ControlFlowGraph.InvokeNode)1 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1