use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LeaveSSA method unSSAGuardsDetermineReg.
/**
* Determine target register for guard phi operands
*
* @param ir the governing IR, currently in SSA form
*/
private void unSSAGuardsDetermineReg(IR ir) {
Instruction inst = guardPhis;
while (inst != null) {
Register r = Phi.getResult(inst).asRegister().getRegister();
int values = Phi.getNumberOfValues(inst);
for (int i = 0; i < values; ++i) {
Operand op = Phi.getValue(inst, i);
if (op instanceof RegisterOperand) {
guardUnion(op.asRegister().getRegister(), r);
} else {
if (VM.VerifyAssertions) {
VM._assert(op instanceof TrueGuardOperand || op instanceof UnreachableOperand);
}
}
}
inst = inst2guardPhi.get(inst);
}
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LeaveSSA method performRename.
// substitute variables renamed in control parents
private void performRename(BasicBlock bb, DominatorTree dom, VariableStacks s) {
if (DEBUG)
VM.sysWriteln("performRename: " + bb);
Enumeration<Instruction> e = bb.forwardRealInstrEnumerator();
while (e.hasMoreElements()) {
Instruction i = e.nextElement();
Enumeration<Operand> ee = i.getUses();
while (ee.hasMoreElements()) {
Operand o = ee.nextElement();
if (o instanceof RegisterOperand) {
Register r1 = ((RegisterOperand) o).getRegister();
if (r1.isValidation())
continue;
Operand r2 = s.peek(r1);
if (r2 != null) {
if (DEBUG) {
VM.sysWriteln("replace operand in " + i + "(" + r2 + " for " + o);
}
i.replaceOperand(o, r2.copy());
}
}
}
}
// record renamings required in children
e = bb.forwardRealInstrEnumerator();
while (e.hasMoreElements()) {
Instruction i = e.nextElement();
if (globalRenameTable.contains(i)) {
Register original = Move.getVal(i).asRegister().getRegister();
RegisterOperand rename = Move.getResult(i);
if (DEBUG)
VM.sysWriteln("record rename " + rename + " for " + original);
s.push(original, rename);
}
}
// insert copies in control children
Enumeration<TreeNode> children = dom.getChildren(bb);
while (children.hasMoreElements()) {
BasicBlock c = ((DominatorTreeNode) children.nextElement()).getBlock();
performRename(c, dom, s);
}
// pop renamings from this block off stack
e = bb.forwardRealInstrEnumerator();
while (e.hasMoreElements()) {
Instruction i = e.nextElement();
if (globalRenameTable.contains(i)) {
Register original = Move.getVal(i).asRegister().getRegister();
s.pop(original);
}
}
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class GenerationContextTest method assertThatLocalsForInstanceMethodWithoutParametersAreCorrect.
private void assertThatLocalsForInstanceMethodWithoutParametersAreCorrect(NormalMethod nm, GenerationContext gc) {
assertThatNumberOfParametersIs(gc, 1);
RegisterOperand thisOperand = getThisOperand(gc);
assertThatRegOpHoldsClassType(thisOperand);
assertThatRegOpHasDeclaredType(thisOperand);
Register thisLocalReg = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
assertThatRegOpIsLocalRegOfRegister(thisOperand, thisLocalReg);
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class GenerationContextTest method noNullCheckGuardsCanBeCreatedAfterCloseWasCalled.
@Test(expected = NullPointerException.class)
public void noNullCheckGuardsCanBeCreatedAfterCloseWasCalled() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
RegisterOperand thisLocal = gc.makeLocal(0, nm.getDeclaringClass().getTypeRef());
Register thisReg = thisLocal.getRegister();
gc.close();
gc.makeNullCheckGuard(thisReg);
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class GenerationContextTest method resyncDeletesNullCheckGuardsThatMapToUnusedRegisters.
@Test
public void resyncDeletesNullCheckGuardsThatMapToUnusedRegisters() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
RegisterOperand thisLocal = gc.makeLocal(0, nm.getDeclaringClass().getTypeRef());
Register thisReg = thisLocal.getRegister();
RegisterOperand thisNullCheckGuard = gc.makeNullCheckGuard(thisReg);
assertNotNull(thisNullCheckGuard);
gc.getTemps().removeRegister(thisReg);
gc.resync();
RegisterOperand newNullCheckGuard = gc.makeNullCheckGuard(thisReg);
assertFalse(newNullCheckGuard.sameRegisterPropertiesAs(thisNullCheckGuard));
}
Aggregations