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);
}
}
}
}
}
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);
}
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);
}
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);
}
}
}
}
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;
}
Aggregations