Search in sources :

Example 1 with DFSEdgeType

use of com.jopdesign.common.graphutils.DFSTraverser.DFSEdgeType in project jop by jop-devel.

the class WCAInvoker method updateWCA.

///////////////////////////////////////////////////////////////////////////////
// Update results
///////////////////////////////////////////////////////////////////////////////
/**
     * Update the WCA results after a set of methods have been changed. The changesets of analyses
     * in the AnalysisManager are checked for changes too.
     *
     * @param changedMethods a set of methods of which the code has been modified.
     * @return a set of all methods for which the path may have changed.
     */
public Set<MethodInfo> updateWCA(Collection<MethodInfo> changedMethods) {
    // Now we need to clear all results for all callers of the modified methods as well as the modified methods,
    // and recalculate all results
    CallGraph callGraph = wcetTool.getCallGraph();
    final Set<ExecutionContext> rootNodes = new LinkedHashSet<ExecutionContext>();
    for (MethodInfo root : changedMethods) {
        rootNodes.addAll(callGraph.getNodes(root));
    }
    // we also need to recalculate for new nodes.. we simply go down callstring-length from the changed methods
    final int callstringLength = AppInfo.getSingleton().getCallstringLength();
    DFSVisitor<ExecutionContext, ContextEdge> visitor = new EmptyDFSVisitor<ExecutionContext, ContextEdge>() {

        @Override
        public boolean visitNode(ExecutionContext parent, ContextEdge edge, ExecutionContext node, DFSEdgeType type, Collection<ContextEdge> outEdges, int depth) {
            if (type.isFirstVisit() && !wcaNodeFlow.containsKey(node)) {
                rootNodes.add(node);
            }
            return depth <= callstringLength;
        }
    };
    DFSTraverser<ExecutionContext, ContextEdge> traverser = new DFSTraverser<ExecutionContext, ContextEdge>(visitor);
    traverser.traverse(callGraph.getGraph(), new ArrayList<ExecutionContext>(rootNodes));
    // classification changed too
    for (MethodInfo method : analyses.getMethodCacheAnalysis().getClassificationChangeSet()) {
        rootNodes.addAll(callGraph.getNodes(method));
    }
    Set<MethodInfo> changed = runAnalysis(wcetTool.getCallGraph().createInvokeGraph(rootNodes, true));
    updateWCEP();
    return changed;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EmptyDFSVisitor(com.jopdesign.common.graphutils.DFSTraverser.EmptyDFSVisitor) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge) DFSTraverser(com.jopdesign.common.graphutils.DFSTraverser) ExecutionContext(com.jopdesign.common.code.ExecutionContext) CallGraph(com.jopdesign.common.code.CallGraph) DFSEdgeType(com.jopdesign.common.graphutils.DFSTraverser.DFSEdgeType) Collection(java.util.Collection) MethodInfo(com.jopdesign.common.MethodInfo)

Aggregations

MethodInfo (com.jopdesign.common.MethodInfo)1 CallGraph (com.jopdesign.common.code.CallGraph)1 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)1 ExecutionContext (com.jopdesign.common.code.ExecutionContext)1 DFSTraverser (com.jopdesign.common.graphutils.DFSTraverser)1 DFSEdgeType (com.jopdesign.common.graphutils.DFSTraverser.DFSEdgeType)1 EmptyDFSVisitor (com.jopdesign.common.graphutils.DFSTraverser.EmptyDFSVisitor)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1