Search in sources :

Example 1 with SortedGraphIterator

use of org.jikesrvm.compilers.opt.util.SortedGraphIterator in project JikesRVM by JikesRVM.

the class LiveAnalysis method perform.

/**
 * The entry point into this class
 * Perform live variable analysis on this IR, constructing live
 * range info and (optionally) GC map info as we go.
 *
 * @param ir the ir
 */
@Override
public void perform(IR ir) {
    liveIntervals = new LiveInterval();
    // Debugging information
    // Live Intervals, GC Maps, and fixed-point results
    final boolean dumpFinalLiveIntervals = DEBUG || ir.options.PRINT_GC_MAPS && (!ir.options.hasMETHOD_TO_PRINT() || (ir.options.hasMETHOD_TO_PRINT() && ir.options.fuzzyMatchMETHOD_TO_PRINT(ir.method.toString())));
    final boolean dumpFinalMaps = dumpFinalLiveIntervals;
    final boolean dumpFixedPointResults = dumpFinalLiveIntervals;
    // make sure IR info is up-to-date
    DefUse.recomputeSpansBasicBlock(ir);
    debugBegining(ir, createGCMaps, dumpFinalLiveIntervals, dumpFinalMaps, dumpFixedPointResults);
    bbLiveInfo = new BBLiveElement[ir.cfg.numberOfNodes()];
    for (int i = 0; i < ir.cfg.numberOfNodes(); i++) {
        bbLiveInfo[i] = new BBLiveElement();
    }
    // allocate the "currentSet" which is used to cache the current results
    currentSet = new LiveSet();
    boolean reuseCurrentSet = false;
    // make sure reverse top sort order is built
    // currentBlock is the first node in the list
    BasicBlock currentBlock = (BasicBlock) ir.cfg.buildRevTopSort();
    // 2nd param: true means forward analysis; false means backward analysis
    SortedGraphIterator bbIter = new SortedGraphIterator(currentBlock, false);
    while (currentBlock != null) {
        boolean changed = processBlock(currentBlock, reuseCurrentSet, ir);
        // mark this block as processed and get the next one
        BasicBlock nextBlock = (BasicBlock) bbIter.markAndGetNextTopSort(changed);
        // check to see if nextBlock has only one successor, currentBlock.
        // If so, we can reuse the current set and avoid performing a meet.
        reuseCurrentSet = nextBlock != null && bbIter.isSinglePredecessor(currentBlock, nextBlock);
        currentBlock = nextBlock;
    }
    debugPostGlobal(ir, dumpFinalLiveIntervals, dumpFinalMaps, dumpFixedPointResults);
    // created, so we can't print them.
    if (!skipLocal) {
        performLocalPropagation(ir, createGCMaps);
        if (createGCMaps && dumpFinalMaps) {
            System.out.println("**** START OF IR for method: " + ir.method.getName() + " in class: " + ir.method.getDeclaringClass());
            ir.printInstructions();
            System.out.println("**** END   OF IR INSTRUCTION DUMP ****");
            printFinalMaps(ir);
        }
        if (dumpFinalLiveIntervals) {
            printFinalLiveIntervals(ir);
        }
        // If we performed the local propagation, live interval information
        // lives off of each basic block.
        // Thus, we no longer need bbLiveInfo (the fixed points results)
        // When we don't perform the local propagation, such as translating
        // out of SSA, then we need to keep bbLiveInfo around
        bbLiveInfo = null;
        // compute the mapping from registers to live interval elements
        computeRegisterMap(ir);
    }
    // No longer need currentSet, which is simply a cache of a LiveSet).
    currentSet = null;
    // This will be null if createGCMaps is false
    if (createGCMaps) {
        ir.MIRInfo.gcIRMap = map;
        ir.MIRInfo.osrVarMap = osrMap;
    }
    // record whether or not we stored liveness information for handlers.
    ir.setHandlerLivenessComputed(storeLiveAtHandlers);
    ir.setLivenessInformation(liveIntervals);
}
Also used : SortedGraphIterator(org.jikesrvm.compilers.opt.util.SortedGraphIterator) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) OsrPoint(org.jikesrvm.compilers.opt.ir.OsrPoint)

Aggregations

BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)1 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)1 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)1 SortedGraphIterator (org.jikesrvm.compilers.opt.util.SortedGraphIterator)1