Search in sources :

Example 16 with BasicBlock

use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.

the class YieldPoints method perform.

/**
 * Insert yield points in method prologues, loop heads, and method exits
 */
@Override
public final void perform(IR ir) {
    if (!ir.method.isInterruptible()) {
        // don't insert yieldpoints in Uninterruptible code.
        return;
    }
    // (1) Insert prologue yieldpoint unconditionally.
    // As part of prologue/epilogue insertion we'll remove
    // the yieldpoints in trivial methods that otherwise wouldn't need
    // a stackframe.
    prependYield(ir.cfg.entry(), YIELDPOINT_PROLOGUE, 0, ir.getGc().getInlineSequence());
    // (2) If using epilogue yieldpoints scan basic blocks, looking for returns or throws
    if (VM.UseEpilogueYieldPoints) {
        for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
            BasicBlock block = e.nextElement();
            if (block.hasReturn() || block.hasAthrowInst()) {
                prependYield(block, YIELDPOINT_EPILOGUE, INSTRUMENTATION_BCI, ir.getGc().getInlineSequence());
            }
        }
    }
    // (3) Insert yieldpoints in loop heads based on the LST.
    LSTGraph lst = ir.HIRInfo.loopStructureTree;
    if (lst != null) {
        for (java.util.Enumeration<LSTNode> e = lst.getRoot().getChildren(); e.hasMoreElements(); ) {
            processLoopNest(e.nextElement());
        }
    }
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 17 with BasicBlock

use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.

the class DepGraph method computeHandlerLiveSet.

/**
 * Determine the set of variables live on entry to any handler
 * block that is reachable from currentBlock
 */
private void computeHandlerLiveSet() {
    if (ir.getHandlerLivenessComputed() && currentBlock.hasExceptionHandlers()) {
        Enumeration<BasicBlock> e = currentBlock.getExceptionalOut();
        while (e.hasMoreElements()) {
            ExceptionHandlerBasicBlock handlerBlock = (ExceptionHandlerBasicBlock) e.nextElement();
            handlerLiveSet.add(handlerBlock.getLiveSet());
        }
    }
}
Also used : ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)

Example 18 with BasicBlock

use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.

the class DepGraphStats method printBasicBlockStatistics.

/**
 * Print the dependence graph stats for all basic blocks in an IR.
 * @param ir the IR
 */
public static void printBasicBlockStatistics(IR ir) {
    final boolean DEBUG = false;
    System.out.println();
    System.out.println("**** START OF printBasicBlockStatistics() for method " + ir.method + " ****");
    if (DEBUG) {
        ir.printInstructions();
    }
    // Performing live analysis may reduce dependences between PEIs and stores
    if (ir.options.L2M_HANDLER_LIVENESS) {
        new LiveAnalysis(false, false, true).perform(ir);
    }
    for (BasicBlock bb = ir.firstBasicBlockInCodeOrder(); bb != null; bb = bb.nextBasicBlockInCodeOrder()) {
        // DepGraph dg =
        new DepGraph(ir, bb.firstRealInstruction(), bb.lastRealInstruction(), bb);
    }
    System.out.println("**** END OF printBasicBlockStatistics() ****");
}
Also used : LiveAnalysis(org.jikesrvm.compilers.opt.liveness.LiveAnalysis) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 19 with BasicBlock

use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.

the class LTDominators method LINK.

/**
 *  Adds edge (block1, block2) to the forest maintained as an auxiliary
 *  data structure.  This implementation uses path compression and
 *  results in a O(e * alpha(e,n)) complexity, where e is the number of
 *  edges in the CFG and n is the number of nodes.
 *
 *  @param block1 a basic block corresponding to the source of the new edge
 *  @param block2 a basic block corresponding to the source of the new edge
 */
private void LINK(BasicBlock block1, BasicBlock block2) {
    if (DEBUG) {
        System.out.println("  Linking " + block1 + " with " + block2);
    }
    BasicBlock s = block2;
    while (getSemi(getLabel(block2)) < getSemi(getLabel(getChild(s)))) {
        if (getSize(s) + getSize(getChild(getChild(s))) >= 2 * getSize(getChild(s))) {
            LTDominatorInfo.getInfo(getChild(s), ir).setAncestor(s);
            LTDominatorInfo.getInfo(s, ir).setChild(getChild(getChild(s)));
        } else {
            LTDominatorInfo.getInfo(getChild(s), ir).setSize(getSize(s));
            LTDominatorInfo.getInfo(s, ir).setAncestor(getChild(s));
            s = getChild(s);
        }
    }
    LTDominatorInfo.getInfo(s, ir).setLabel(getLabel(block2));
    LTDominatorInfo.getInfo(block1, ir).setSize(getSize(block1) + getSize(block2));
    if (getSize(block1) < 2 * getSize(block2)) {
        BasicBlock tmp = s;
        s = getChild(block1);
        LTDominatorInfo.getInfo(block1, ir).setChild(tmp);
    }
    while (s != null) {
        LTDominatorInfo.getInfo(s, ir).setAncestor(block1);
        s = getChild(s);
    }
    if (DEBUG) {
        System.out.println("  .... done");
    }
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 20 with BasicBlock

use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.

the class LTDominators method printDFSNumbers.

/**
 *  Print the result of the DFS numbering performed in Step 1
 */
private void printDFSNumbers() {
    for (Enumeration<BasicBlock> bbEnum = cfg.basicBlocks(); bbEnum.hasMoreElements(); ) {
        BasicBlock block = bbEnum.nextElement();
        // We don't compute a result for the exit node for forward direction
        if (forward && block.isExit()) {
            continue;
        }
        LTDominatorInfo info = ir.getLtDominators().getInfo(block);
        System.out.println(" " + block + " " + info);
    }
    // has number 1
    for (int i = 1; i <= DFSCounter; i++) {
        System.out.println(" Vertex: " + i + " " + vertex[i]);
    }
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Aggregations

BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)219 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)117 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)93 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)66 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)52 Register (org.jikesrvm.compilers.opt.ir.Register)50 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)48 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)37 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)33 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)27 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)24 HeapOperand (org.jikesrvm.compilers.opt.ir.operand.HeapOperand)21 BasicBlockOperand (org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand)20 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)19 TypeReference (org.jikesrvm.classloader.TypeReference)18 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)18 Test (org.junit.Test)17 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)16 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)14 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)14