use of org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand in project JikesRVM by JikesRVM.
the class EnterSSA method removeUnreachableOperands.
@SuppressWarnings("unused")
private void removeUnreachableOperands(HashSet<Instruction> scalarPhis) {
for (Instruction phi : scalarPhis) {
boolean didSomething = true;
while (didSomething) {
didSomething = false;
for (int j = 0; j < Phi.getNumberOfValues(phi); j++) {
Operand v = Phi.getValue(phi, j);
if (v instanceof UnreachableOperand) {
// rewrite the phi instruction to remove the unreachable
// operand
didSomething = true;
Instruction tmpPhi = phi.copyWithoutLinks();
Phi.mutate(phi, PHI, Phi.getResult(tmpPhi), Phi.getNumberOfValues(phi) - 1);
int m = 0;
for (int k = 0; k < Phi.getNumberOfValues(phi); k++) {
if (k == j)
continue;
Phi.setValue(phi, m, Phi.getValue(tmpPhi, k));
Phi.setPred(phi, m, Phi.getPred(tmpPhi, k));
m++;
}
}
}
}
}
}
use of org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand in project JikesRVM by JikesRVM.
the class EnterSSA method meetPhiType.
/**
* Return the meet of the types on the rhs of a phi instruction
*
* @param s phi instruction
* @param phiTypes TODO
* @return the meet of the types
*/
private static TypeReference meetPhiType(Instruction s, Map<Instruction, PhiTypeInformation> phiTypes) {
TypeReference result = null;
for (int i = 0; i < Phi.getNumberOfValues(s); i++) {
Operand val = Phi.getValue(s, i);
if (val instanceof UnreachableOperand)
continue;
TypeReference t = val.getType();
if (t == null) {
phiTypes.put(s, PhiTypeInformation.FOUND_NULL_TYPE);
} else if (result == null) {
result = t;
} else {
TypeReference meet = ClassLoaderProxy.findCommonSuperclass(result, t);
if (meet == null) {
// TODO: This horrific kludge should go away once we get rid of Address.toInt()
if ((result.isIntLikeType() && (t.isReferenceType() || t.isWordLikeType())) || ((result.isReferenceType() || result.isWordLikeType()) && t.isIntLikeType())) {
meet = TypeReference.Int;
} else if (result.isReferenceType() && t.isWordLikeType()) {
meet = t;
} else if (result.isWordLikeType() && t.isReferenceType()) {
meet = result;
}
}
if (VM.VerifyAssertions && meet == null) {
String msg = result + " and " + t + " meet to null";
VM._assert(VM.NOT_REACHED, msg);
}
result = meet;
}
}
return result;
}
use of org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand in project JikesRVM by JikesRVM.
the class ValueGraph method findOrCreateVertex.
/**
* Find or create an ValueGraphVertex corresponding to a
* given constant operand
*
* @param op the constant operand
* @return a value graph vertex corresponding to this variable
*/
private ValueGraphVertex findOrCreateVertex(ConstantOperand op) {
Object name;
if (op.isAddressConstant()) {
name = (VM.BuildFor32Addr) ? op.asAddressConstant().value.toInt() : op.asAddressConstant().value.toLong();
} else if (op.isIntConstant()) {
name = op.asIntConstant().value;
} else if (op.isFloatConstant()) {
name = op.asFloatConstant().value;
} else if (op.isLongConstant()) {
name = op.asLongConstant().value;
} else if (op.isDoubleConstant()) {
name = op.asDoubleConstant().value;
} else if (op instanceof ObjectConstantOperand) {
name = op.asObjectConstant().value;
} else if (op instanceof TIBConstantOperand) {
name = op.asTIBConstant().value;
} else if (op.isNullConstant()) {
name = op;
} else if (op instanceof TrueGuardOperand) {
name = op;
} else if (op instanceof UnreachableOperand) {
name = op;
} else {
throw new OptimizingCompilerException("ValueGraph.findOrCreateVertex: unexpected constant operand: " + op);
}
ValueGraphVertex v = getVertex(name);
if (v == null) {
v = new ValueGraphVertex(op);
v.setLabel(op, 0);
graph.addGraphNode(v);
nameMap.put(name, v);
}
return v;
}
use of org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand 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.operand.UnreachableOperand in project JikesRVM by JikesRVM.
the class Simplifier method getField.
private static DefUseEffect getField(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_FIELD_OPS) {
Operand ref = GetField.getRef(s);
if (VM.VerifyAssertions && ref.isNullConstant()) {
// Simplify to an unreachable operand, this instruction is dead code
// guarded by a nullcheck that should already have been simplified
RegisterOperand result = GetField.getClearResult(s);
Move.mutate(s, IRTools.getMoveOp(result.getType()), result, new UnreachableOperand());
return DefUseEffect.MOVE_FOLDED;
} else if (opts.SIMPLIFY_CHASE_FINAL_FIELDS && ref.isObjectConstant()) {
// A constant object references this field which is
// final. As the reference is final the constructor
// of the referred object MUST have already completed.
// This also implies that the type MUST have been resolved.
RVMField field = GetField.getLocation(s).getFieldRef().resolve();
if (field.isFinal() && field.getDeclaringClass().isInitialized()) {
try {
ConstantOperand op = StaticFieldReader.getFieldValueAsConstant(field, ref.asObjectConstant().value);
Move.mutate(s, IRTools.getMoveOp(field.getType()), GetField.getClearResult(s), op);
return DefUseEffect.MOVE_FOLDED;
} catch (NoSuchFieldException e) {
if (VM.runningVM) {
// this is unexpected
throw new Error("Unexpected exception", e);
} else {
// Field not found during bootstrap due to chasing a field
// only valid in the bootstrap JVM
}
}
}
}
}
return DefUseEffect.UNCHANGED;
}
Aggregations