Search in sources :

Example 16 with HeapOperand

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

the class EnterSSA method registerRenamedHeapPhis.

/**
 * After performing renaming on heap phi functions, this
 * routines notifies the SSA dictionary of the new names.
 * <p>
 * FIXME - this was commented out: delete it ??  RJG
 *
 * @param ir the governing IR
 */
@SuppressWarnings({ "unused", "unchecked" })
private // HeapOperand requires casts to a generic type
void registerRenamedHeapPhis(IR ir) {
    SSADictionary ssa = ir.HIRInfo.dictionary;
    for (Enumeration<BasicBlock> e1 = ir.getBasicBlocks(); e1.hasMoreElements(); ) {
        BasicBlock bb = e1.nextElement();
        for (Enumeration<Instruction> e2 = ssa.getAllInstructions(bb); e2.hasMoreElements(); ) {
            Instruction s = e2.nextElement();
            if (Phi.conforms(s)) {
                if (ssa.defsHeapVariable(s)) {
                    int n = Phi.getNumberOfValues(s);
                    HeapOperand<Object>[] uses = new HeapOperand[n];
                    for (int i = 0; i < n; i++) {
                        uses[i] = (HeapOperand) Phi.getValue(s, i);
                    }
                    ssa.replaceUses(s, uses);
                }
            }
        }
    }
}
Also used : HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 17 with HeapOperand

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

the class SSADictionary method registerUnknown.

/**
 * Register that an instruction s has unknown side effects.  That is,
 * we conservatively record that s defs and uses all heap variables.
 * <p> NOTE: This function should be called before renaming.
 *
 * @param s the instruction in question
 * @param b the basic block containing s
 */
@SuppressWarnings("unchecked")
void registerUnknown(Instruction s, BasicBlock b) {
    if (VM.VerifyAssertions)
        VM._assert(s.operator() != PHI);
    // setup an array of all heap variables
    // TODO: for efficiency, cache a copy of 'all'
    Iterator vars = heapVariables.values().iterator();
    HeapOperand<Object>[] all = new HeapOperand[heapVariables.size()];
    for (int i = 0; i < all.length; i++) {
        all[i] = new HeapOperand<Object>((HeapVariable<Object>) vars.next());
        all[i].setInstruction(s);
        // record that all[i] is def'ed in b
        all[i].getHeapVariable().registerDef(b);
    }
    // record that s uses and defs all heap variables
    uses.put(s, all);
    defs.put(s, all);
    // record that instruction s can exit the procedure
    exits.add(s);
}
Also used : HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) Iterator(java.util.Iterator)

Example 18 with HeapOperand

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

the class SSADictionary method registerDef.

/**
 * Register that instruction <code>s</code> writes a heap variable for
 * a given field.
 *
 * @param s the instruction in question
 * @param b  <code>s</code>'s basic block
 * @param fr the field heap variable the instruction modifies
 */
private void registerDef(Instruction s, BasicBlock b, FieldReference fr) {
    if (VM.VerifyAssertions)
        VM._assert(s.operator() != PHI);
    RVMField f = fr.peekResolvedField();
    HeapOperand<Object> H;
    if (f == null) {
        // can't resolve field at compile time.
        // This isn't quite correct, but is somewhat close.
        // See bug #1147433
        H = new HeapOperand<Object>(findOrCreateHeapVariable(fr));
    } else {
        // not included in the set
        if (heapTypes != null) {
            if (!heapTypes.contains(f)) {
                return;
            }
        }
        H = new HeapOperand<Object>(findOrCreateHeapVariable(f));
    }
    H.value.registerDef(b);
    HeapOperand<Object>[] Hprime = new HeapOperand[1];
    Hprime[0] = H;
    Hprime[0].setInstruction(s);
    defs.put(s, Hprime);
}
Also used : HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) RVMField(org.jikesrvm.classloader.RVMField)

Example 19 with HeapOperand

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

the class SSADictionary method recomputeArrayDU.

/**
 * Recompute the chain of uses for each heap variable.
 * NOTE: for now this procedure does <em> not </em> recompute
 * def chains
 */
void recomputeArrayDU() {
    UseChain.clear();
    DefChain.clear();
    // create a set of uses for each heap variable
    for (Iterator<HeapVariable<Object>> e = getHeapVariables(); e.hasNext(); ) {
        HeapVariable<Object> H = e.next();
        HashSet<HeapOperand<Object>> u = new HashSet<HeapOperand<Object>>(2);
        UseChain.put(H, u);
    }
    // populate the use chain with each use registered
    for (HeapOperand<Object>[] operands : uses.values()) {
        if (operands == null)
            continue;
        for (HeapOperand<Object> operand : operands) {
            HeapVariable<Object> v = operand.getHeapVariable();
            HashSet<HeapOperand<Object>> u = UseChain.get(v);
            u.add(operand);
        }
    }
    // record the unique def for each heap variable
    for (HeapOperand<Object>[] operands : defs.values()) {
        if (operands == null)
            continue;
        for (HeapOperand<Object> operand : operands) {
            HeapVariable<Object> v = operand.getHeapVariable();
            DefChain.put(v, operand);
        }
    }
    // handle each HEAP PHI function.
    for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
        BasicBlock bb = e.nextElement();
        for (Iterator<Instruction> hp = getHeapPhiInstructions(bb); hp.hasNext(); ) {
            Instruction phi = hp.next();
            HeapOperand<Object> H = (HeapOperand) Phi.getResult(phi);
            HeapVariable<Object> v = H.getHeapVariable();
            DefChain.put(v, H);
            for (int i = 0; i < Phi.getNumberOfValues(phi); i++) {
                HeapOperand<Object> Hu = (HeapOperand) Phi.getValue(phi, i);
                HeapVariable<Object> vu = Hu.getHeapVariable();
                HashSet<HeapOperand<Object>> u = UseChain.get(vu);
                u.add(Hu);
            }
        }
    }
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) HashSet(java.util.HashSet)

Example 20 with HeapOperand

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

the class SSADictionary method isExposedOnExit.

/**
 * Checks whether a heap variable is exposed on procedure exit.
 *
 * @param H the heap variable
 * @return {@code true} or {@code false} as appropriate
 */
boolean isExposedOnExit(HeapVariable<Object> H) {
    for (Iterator<HeapOperand<Object>> i = iterateHeapUses(H); i.hasNext(); ) {
        HeapOperand<Object> op = i.next();
        Instruction s = op.instruction;
        if (exits.contains(s)) {
            return true;
        }
    }
    return false;
}
Also used : HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Aggregations

HeapOperand (org.jikesrvm.compilers.opt.ir.operand.HeapOperand)20 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)13 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)8 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)7 BasicBlockOperand (org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand)5 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)4 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)4 Register (org.jikesrvm.compilers.opt.ir.Register)3 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)3 HashSet (java.util.HashSet)2 RVMField (org.jikesrvm.classloader.RVMField)2 TypeReference (org.jikesrvm.classloader.TypeReference)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Stack (java.util.Stack)1 DominatorTreeNode (org.jikesrvm.compilers.opt.controlflow.DominatorTreeNode)1 DF_LatticeCell (org.jikesrvm.compilers.opt.dfsolver.DF_LatticeCell)1 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)1 IREnumeration (org.jikesrvm.compilers.opt.ir.IREnumeration)1 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)1