Search in sources :

Example 6 with DF_LatticeCell

use of org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell in project JikesRVM by JikesRVM.

the class IndexPropagationSystem method makeCell.

/**
 * Create an DF_LatticeCell corresponding to an HeapVariable
 * @param o the heap variable
 * @return a new lattice cell corresponding to this heap variable
 */
@Override
protected DF_LatticeCell makeCell(Object o) {
    if (!(o instanceof HeapVariable)) {
        throw new OptimizingCompilerException("IndexPropagation:makeCell");
    }
    DF_LatticeCell result = null;
    Object heapType = ((HeapVariable<?>) o).getHeapType();
    if (heapType instanceof TypeReference) {
        result = new ArrayCell((HeapVariable<?>) o);
    } else {
        result = new ObjectCell((HeapVariable<?>) o);
    }
    return result;
}
Also used : ArrayCell(org.jikesrvm.compilers.opt.ssa.IndexPropagation.ArrayCell) DF_LatticeCell(org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell) ObjectCell(org.jikesrvm.compilers.opt.ssa.IndexPropagation.ObjectCell) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) TypeReference(org.jikesrvm.classloader.TypeReference)

Example 7 with DF_LatticeCell

use of org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell in project JikesRVM by JikesRVM.

the class IndexPropagationSystem method addUpdateArrayDefEquation.

/**
 * Add an equation to the system of the form
 * <pre>
 * L(A1) = updateDef(L(A2), &lt;VALNUM(array),VALNUM(index)&gt;)
 * </pre>
 *
 * @param A1 variable in the equation
 * @param A2 variable in the equation
 * @param array variable in the equation
 * @param index variable in the equation
 */
void addUpdateArrayDefEquation(HeapVariable<?> A1, HeapVariable<?> A2, Object array, Object index) {
    DF_LatticeCell cell1 = findOrCreateCell(A1);
    DF_LatticeCell cell2 = findOrCreateCell(A2);
    int arrayNumber = valueNumbers.getValueNumber(array);
    int indexNumber = valueNumbers.getValueNumber(index);
    UpdateDefArrayOperator op = new UpdateDefArrayOperator(arrayNumber, indexNumber);
    newEquation(cell1, op, cell2);
}
Also used : DF_LatticeCell(org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell)

Example 8 with DF_LatticeCell

use of org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell in project JikesRVM by JikesRVM.

the class DominatorSystem method setupEquations.

/**
 * Go through each basic block in the IR, and add equations
 * to the system as required.
 * <p> Uses the algorithm contained in Dragon book, pg. 670-1.
 * <pre>
 *     D(n0) := { n0 }
 *     for n in N - { n0 } do D(n) := N;
 *     while changes to any D(n) occur do
 *       for n in N - {n0} do
 *           D(n) := {n} U (intersect of D(p) over all predecessors p of n)
 * </pre>
 */
void setupEquations() {
    // loop through each basic block in the IR
    for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
        BasicBlock bb = e.nextElement();
        // add a data-flow equation for this basic block
        // DOM(n) = {n} MEET {pred(n)}
        DF_LatticeCell dom = findOrCreateCell(bb);
        DF_LatticeCell[] pred = getCellsForPredecessors(bb);
        newEquation(dom, DominatorOperator.MEET, pred);
    }
}
Also used : DF_LatticeCell(org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 9 with DF_LatticeCell

use of org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell in project JikesRVM by JikesRVM.

the class DominatorSystem method initializeLatticeCells.

/**
 * Initialize the lattice variables (Dominator sets) for
 * each basic block.
 */
@Override
protected void initializeLatticeCells() {
    if (Dominators.COMPUTE_POST_DOMINATORS) {
        BasicBlock exit = ir.cfg.exit();
        DominatorCell last = (DominatorCell) getCell(exit);
        for (final DF_LatticeCell latticeCell : cells.values()) {
            DominatorCell cell = (DominatorCell) latticeCell;
            if (cell == last) {
                cell.addSingleBlock(cell.block);
            } else {
                cell.setTOP(ir);
            }
        }
    } else {
        BasicBlock start = ir.cfg.entry();
        DominatorCell first = (DominatorCell) getCell(start);
        for (final DF_LatticeCell latticeCell : cells.values()) {
            DominatorCell cell = (DominatorCell) latticeCell;
            if (cell == first) {
                cell.addSingleBlock(cell.block);
            } else {
                cell.setTOP(ir);
            }
        }
    }
}
Also used : DF_LatticeCell(org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 10 with DF_LatticeCell

use of org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell in project JikesRVM by JikesRVM.

the class DominatorSystem method getCellsForPredecessors.

/**
 * @param bb the basic block
 * @return a list of lattice cells corresponding to the
 *  predecessors of a basic block
 */
DF_LatticeCell[] getCellsForPredecessors(BasicBlock bb) {
    if (Dominators.COMPUTE_POST_DOMINATORS) {
        /**
         **
         *       if ( bb.mayThrowUncaughtException() ) {
         *       if (Dominators.DEBUG) VM.sysWriteln("LOCATION #1 ...");
         *       // Include exit node as an output node
         *       DF_LatticeCell s[] = new DF_LatticeCell[bb.getNumberOfOut()+1];
         *       Enumeration<BasicBlock> e = bb.getOut();
         *       for (int i=0; i<s.length-1; i++ ) {
         *       BasicBlock p = e.next();
         *       s[i] = findOrCreateCell(getKey(p));
         *       }
         *       s[s.length-1] = findOrCreateCell(getKey(ir.cfg.exit()));
         *       return s;
         *       }
         *       else
         ***
         */
        {
            if (Dominators.DEBUG) {
                VM.sysWriteln("LOCATION #2 ...");
            }
            DF_LatticeCell[] s = new DF_LatticeCell[bb.getNumberOfOut()];
            Enumeration<BasicBlock> e = bb.getOut();
            for (int i = 0; i < s.length; i++) {
                BasicBlock p = e.nextElement();
                s[i] = findOrCreateCell(getKey(p));
            }
            return s;
        }
    } else {
        if (Dominators.DEBUG) {
            System.out.println("LOCATION #3 ...");
        }
        DF_LatticeCell[] s = new DF_LatticeCell[bb.getNumberOfIn()];
        Enumeration<BasicBlock> e = bb.getIn();
        for (int i = 0; i < s.length; i++) {
            BasicBlock p = e.nextElement();
            s[i] = findOrCreateCell(getKey(p));
        }
        return s;
    }
}
Also used : DF_LatticeCell(org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell) Enumeration(java.util.Enumeration) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Aggregations

DF_LatticeCell (org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell)11 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)4 ArrayCell (org.jikesrvm.compilers.opt.ssa.IndexPropagation.ArrayCell)2 ObjectCell (org.jikesrvm.compilers.opt.ssa.IndexPropagation.ObjectCell)2 Enumeration (java.util.Enumeration)1 TypeReference (org.jikesrvm.classloader.TypeReference)1 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)1 HeapOperand (org.jikesrvm.compilers.opt.ir.operand.HeapOperand)1 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)1