use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class ObjectReplacer method transform.
@Override
public void transform() {
// store the object's fields in a ArrayList
ArrayList<RVMField> fields = getFieldsAsArrayList(klass);
// create a scalar for each field. initialize the scalar to
// default values before the object's def
RegisterOperand[] scalars = new RegisterOperand[fields.size()];
RegisterOperand def = reg.defList;
Instruction defI = def.instruction;
for (int i = 0; i < fields.size(); i++) {
RVMField f = fields.get(i);
Operand defaultValue = IRTools.getDefaultOperand(f.getType());
scalars[i] = IRTools.moveIntoRegister(ir.regpool, defI, defaultValue);
scalars[i].setType(f.getType());
}
transform2(this.reg, defI, scalars, fields, null);
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class ObjectReplacer method scalarReplace.
/**
* Replace a given use of a object with its scalar equivalent
*
* @param use the use to replace
* @param scalars an array of scalar register operands to replace
* the object's fields with
* @param fields the object's fields
* @param visited the registers that were already seen
*/
private void scalarReplace(RegisterOperand use, RegisterOperand[] scalars, ArrayList<RVMField> fields, Set<Register> visited) {
Instruction inst = use.instruction;
try {
switch(inst.getOpcode()) {
case PUTFIELD_opcode:
{
FieldReference fr = PutField.getLocation(inst).getFieldRef();
if (VM.VerifyAssertions)
VM._assert(fr.isResolved());
RVMField f = fr.peekResolvedField();
int index = fields.indexOf(f);
TypeReference type = scalars[index].getType();
Operator moveOp = IRTools.getMoveOp(type);
Instruction i = Move.create(moveOp, scalars[index].copyRO(), PutField.getClearValue(inst));
inst.insertBefore(i);
DefUse.removeInstructionAndUpdateDU(inst);
DefUse.updateDUForNewInstruction(i);
}
break;
case GETFIELD_opcode:
{
FieldReference fr = GetField.getLocation(inst).getFieldRef();
if (VM.VerifyAssertions)
VM._assert(fr.isResolved());
RVMField f = fr.peekResolvedField();
int index = fields.indexOf(f);
TypeReference type = scalars[index].getType();
Operator moveOp = IRTools.getMoveOp(type);
Instruction i = Move.create(moveOp, GetField.getClearResult(inst), scalars[index].copyRO());
inst.insertBefore(i);
DefUse.removeInstructionAndUpdateDU(inst);
DefUse.updateDUForNewInstruction(i);
}
break;
case MONITORENTER_opcode:
inst.insertBefore(Empty.create(READ_CEILING));
DefUse.removeInstructionAndUpdateDU(inst);
break;
case MONITOREXIT_opcode:
inst.insertBefore(Empty.create(WRITE_FLOOR));
DefUse.removeInstructionAndUpdateDU(inst);
break;
case CALL_opcode:
case NULL_CHECK_opcode:
// (SJF) TODO: Why wasn't this caught by BC2IR for
// java.lang.Double.<init> (Ljava/lang/String;)V ?
DefUse.removeInstructionAndUpdateDU(inst);
break;
case CHECKCAST_opcode:
case CHECKCAST_NOTNULL_opcode:
case CHECKCAST_UNRESOLVED_opcode:
{
// We cannot handle removing the checkcast if the result of the
// checkcast test is unknown
TypeReference lhsType = TypeCheck.getType(inst).getTypeRef();
if (ClassLoaderProxy.includesType(lhsType, klass.getTypeRef()) == YES) {
if (visited == null) {
visited = new HashSet<Register>();
}
Register copy = TypeCheck.getResult(inst).getRegister();
if (!visited.contains(copy)) {
visited.add(copy);
transform2(copy, inst, scalars, fields, visited);
// NB will remove inst
} else {
DefUse.removeInstructionAndUpdateDU(inst);
}
} else {
Instruction i2 = Trap.create(TRAP, null, TrapCodeOperand.CheckCast());
DefUse.replaceInstructionAndUpdateDU(inst, i2);
}
}
break;
case INSTANCEOF_opcode:
case INSTANCEOF_NOTNULL_opcode:
case INSTANCEOF_UNRESOLVED_opcode:
{
// We cannot handle removing the instanceof if the result of the
// instanceof test is unknown
TypeReference lhsType = InstanceOf.getType(inst).getTypeRef();
Instruction i2;
if (ClassLoaderProxy.includesType(lhsType, klass.getTypeRef()) == YES) {
i2 = Move.create(INT_MOVE, InstanceOf.getClearResult(inst), IC(1));
} else {
i2 = Move.create(INT_MOVE, InstanceOf.getClearResult(inst), IC(0));
}
DefUse.replaceInstructionAndUpdateDU(inst, i2);
}
break;
case GET_OBJ_TIB_opcode:
{
Instruction i2 = Move.create(REF_MOVE, GuardedUnary.getClearResult(inst), new TIBConstantOperand(klass));
DefUse.replaceInstructionAndUpdateDU(inst, i2);
}
break;
case REF_MOVE_opcode:
{
if (visited == null) {
visited = new HashSet<Register>();
}
Register copy = Move.getResult(use.instruction).getRegister();
if (!visited.contains(copy)) {
visited.add(copy);
transform2(copy, inst, scalars, fields, visited);
// NB will remove inst
} else {
DefUse.removeInstructionAndUpdateDU(inst);
}
}
break;
default:
throw new OptimizingCompilerException("ObjectReplacer: unexpected use " + inst);
}
} catch (Exception e) {
OptimizingCompilerException oe = new OptimizingCompilerException("Error handling use (" + use + ") of: " + inst);
oe.initCause(e);
throw oe;
}
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class SSADictionary method registerUse.
/**
* Register that an instruction uses a heap variable for a given
* field.
*
* @param s the instruction in question
* @param fr the field heap variable the instruction uses
*/
private void registerUse(Instruction s, 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 defect 3481.
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));
}
HeapOperand<Object>[] Hprime = new HeapOperand[1];
Hprime[0] = H;
Hprime[0].setInstruction(s);
uses.put(s, Hprime);
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class VMObjectStreamClass method setDoubleNative.
static void setDoubleNative(Field field, Object obj, double val) {
RVMField f = java.lang.reflect.JikesRVMSupport.getFieldOf(field);
f.setDoubleValueUnchecked(obj, val);
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class VMObjectStreamClass method setCharNative.
static void setCharNative(Field field, Object obj, char val) {
RVMField f = java.lang.reflect.JikesRVMSupport.getFieldOf(field);
f.setCharValueUnchecked(obj, val);
}
Aggregations