Program: 149796
Project: 149796
Buggy source:
/** 
 * Given an HIR, expand operators that are implemented as calls to runtime service methods. This method should be called as one of the first steps in lowering HIR into LIR.
 * @param ir  The HIR to expand
 */
public void perform(IR ir){
  ir.gc.resync();
  Instruction next;
  for (Instruction inst=ir.firstInstructionInCodeOrder(); inst != null; inst=next) {
    next=inst.nextInstructionInCodeOrder();
    int opcode=inst.getOpcode();
switch (opcode) {
case NEW_opcode:
{
        TypeOperand Type=New.getClearType(inst);
        RVMClass cls=(RVMClass)Type.getVMType();
        IntConstantOperand hasFinalizer=IRTools.IC(cls.hasFinalizer() ? 1 : 0);
        RVMMethod callSite=inst.position.getMethod();
        IntConstantOperand allocator=IRTools.IC(MM_Interface.pickAllocator(cls,callSite));
        IntConstantOperand align=IRTools.IC(ObjectModel.getAlignment(cls));
        IntConstantOperand offset=IRTools.IC(ObjectModel.getOffsetForAlignment(cls));
        Operand tib=ConvertToLowLevelIR.getTIB(inst,ir,Type);
        if (VM.BuildForIA32 && VM.runningVM) {
          RegisterOperand tmp=ir.regpool.makeTemp(TypeReference.TIB);
          inst.insertBefore(Move.create(REF_MOVE,tmp,tib));
          tib=tmp.copyRO();
        }
        IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
        RVMMethod target=Entrypoints.resolvedNewScalarMethod;
        Call.mutate7(inst,CALL,New.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(cls.getInstanceSize()),tib,hasFinalizer,allocator,align,offset,site);
        next=inst.prevInstructionInCodeOrder();
        if (ir.options.INLINE_NEW) {
          if (inst.getBasicBlock().getInfrequent())           container.counter1++;
          container.counter2++;
          if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
            inline(inst,ir);
          }
        }
      }
    break;
case NEW_UNRESOLVED_opcode:
{
    int typeRefId=New.getType(inst).getTypeRef().getId();
    RVMMethod target=Entrypoints.unresolvedNewScalarMethod;
    IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
    Call.mutate2(inst,CALL,New.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(typeRefId),site);
  }
break;
case NEWARRAY_opcode:
{
TypeOperand Array=NewArray.getClearType(inst);
RVMArray array=(RVMArray)Array.getVMType();
Operand numberElements=NewArray.getClearSize(inst);
boolean inline=numberElements instanceof IntConstantOperand;
Operand width=IRTools.IC(array.getLogElementSize());
Operand headerSize=IRTools.IC(ObjectModel.computeArrayHeaderSize(array));
RVMMethod callSite=inst.position.getMethod();
IntConstantOperand allocator=IRTools.IC(MM_Interface.pickAllocator(array,callSite));
IntConstantOperand align=IRTools.IC(ObjectModel.getAlignment(array));
IntConstantOperand offset=IRTools.IC(ObjectModel.getOffsetForAlignment(array));
Operand tib=ConvertToLowLevelIR.getTIB(inst,ir,Array);
if (VM.BuildForIA32 && VM.runningVM) {
  RegisterOperand tmp=ir.regpool.makeTemp(TypeReference.TIB);
  inst.insertBefore(Move.create(REF_MOVE,tmp,tib));
  tib=tmp.copyRO();
}
IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
RVMMethod target=Entrypoints.resolvedNewArrayMethod;
Call.mutate8(inst,CALL,NewArray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),numberElements,width,headerSize,tib,allocator,align,offset,site);
next=inst.prevInstructionInCodeOrder();
if (inline && ir.options.INLINE_NEW) {
  if (inst.getBasicBlock().getInfrequent())   container.counter1++;
  container.counter2++;
  if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
    inline(inst,ir);
  }
}
}
break;
case NEWARRAY_UNRESOLVED_opcode:
{
int typeRefId=NewArray.getType(inst).getTypeRef().getId();
Operand numberElements=NewArray.getClearSize(inst);
RVMMethod target=Entrypoints.unresolvedNewArrayMethod;
IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
Call.mutate3(inst,CALL,NewArray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),numberElements,IRTools.IC(typeRefId),site);
}
break;
case NEWOBJMULTIARRAY_opcode:
{
int dimensions=Multianewarray.getNumberOfDimensions(inst);
RVMMethod callSite=inst.position.getMethod();
int typeRefId=Multianewarray.getType(inst).getTypeRef().getId();
if (dimensions == 2) {
RVMMethod target=Entrypoints.optNew2DArrayMethod;
Call.mutate4(inst,CALL,Multianewarray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(callSite.getId()),Multianewarray.getClearDimension(inst,0),Multianewarray.getClearDimension(inst,1),IRTools.IC(typeRefId));
}
 else {
TypeOperand dimArrayType=new TypeOperand(RVMArray.IntArray);
RegisterOperand dimArray=ir.regpool.makeTemp(TypeReference.IntArray);
dimArray.setPreciseType();
next=NewArray.create(NEWARRAY,dimArray,dimArrayType,new IntConstantOperand(dimensions));
inst.insertBefore(next);
for (int i=0; i < dimensions; i++) {
LocationOperand loc=new LocationOperand(TypeReference.Int);
inst.insertBefore(AStore.create(INT_ASTORE,Multianewarray.getClearDimension(inst,i),dimArray.copyD2U(),IRTools.IC(i),loc,IRTools.TG()));
}
RVMMethod target=Entrypoints.optNewArrayArrayMethod;
Call.mutate3(inst,CALL,Multianewarray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(callSite.getId()),dimArray.copyD2U(),IRTools.IC(typeRefId));
}
}
break;
case ATHROW_opcode:
{
RVMMethod target=Entrypoints.athrowMethod;
MethodOperand methodOp=MethodOperand.STATIC(target);
methodOp.setIsNonReturningCall(true);
Call.mutate1(inst,CALL,null,IRTools.AC(target.getOffset()),methodOp,Athrow.getClearValue(inst));
}
break;
case MONITORENTER_opcode:
{
if (ir.options.NO_SYNCHRO) {
inst.remove();
}
 else {
Operand ref=MonitorOp.getClearRef(inst);
RVMType refType=ref.getType().peekType();
if (refType != null && !refType.getThinLockOffset().isMax()) {
RVMMethod target=Entrypoints.inlineLockMethod;
Call.mutate2(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref,IRTools.AC(refType.getThinLockOffset()));
if (inst.getBasicBlock().getInfrequent()) container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst,ir);
}
}
 else {
RVMMethod target=Entrypoints.lockMethod;
Call.mutate1(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref);
}
}
break;
}
case MONITOREXIT_opcode:
{
if (ir.options.NO_SYNCHRO) {
inst.remove();
}
 else {
Operand ref=MonitorOp.getClearRef(inst);
RVMType refType=ref.getType().peekType();
if (refType != null && !refType.getThinLockOffset().isMax()) {
RVMMethod target=Entrypoints.inlineUnlockMethod;
Call.mutate2(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref,IRTools.AC(refType.getThinLockOffset()));
if (inst.getBasicBlock().getInfrequent()) container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst,ir);
}
}
 else {
RVMMethod target=Entrypoints.unlockMethod;
Call.mutate1(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref);
}
}
}
break;
case REF_ASTORE_opcode:
{
if (MM_Constants.NEEDS_WRITE_BARRIER) {
RVMMethod target=Entrypoints.arrayStoreWriteBarrierMethod;
Instruction wb=Call.create3(CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),AStore.getClearGuard(inst),AStore.getArray(inst).copy(),AStore.getIndex(inst).copy(),AStore.getValue(inst).copy());
wb.bcIndex=RUNTIME_SERVICES_BCI;
wb.position=inst.position;
inst.replace(wb);
next=wb.prevInstructionInCodeOrder();
if (ir.options.INLINE_WRITE_BARRIER) {
inline(wb,ir,true);
}
}
}
break;
case REF_ALOAD_opcode:
{
if (MM_Constants.NEEDS_READ_BARRIER) {
RVMMethod target=Entrypoints.arrayLoadReadBarrierMethod;
Instruction rb=Call.create2(CALL,ALoad.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),ALoad.getClearGuard(inst),ALoad.getArray(inst).copy(),ALoad.getIndex(inst).copy());
rb.bcIndex=RUNTIME_SERVICES_BCI;
rb.position=inst.position;
inst.replace(rb);
next=rb.prevInstructionInCodeOrder();
inline(rb,ir,true);
}
}
break;
case PUTFIELD_opcode:
{
if (MM_Constants.NEEDS_WRITE_BARRIER) {
LocationOperand loc=PutField.getLocation(inst);
FieldReference fieldRef=loc.getFieldRef();
if (!fieldRef.getFieldContentsType().isPrimitiveType()) {
RVMField field=fieldRef.peekResolvedField();
if (field == null || !field.isUntraced()) {
RVMMethod target=Entrypoints.putfieldWriteBarrierMethod;
Instruction wb=Call.create4(CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),PutField.getClearGuard(inst),PutField.getRef(inst).copy(),PutField.getOffset(inst).copy(),PutField.getValue(inst).copy(),IRTools.IC(fieldRef.getId()));
wb.bcIndex=RUNTIME_SERVICES_BCI;
wb.position=inst.position;
inst.replace(wb);
next=wb.prevInstructionInCodeOrder();
if (ir.options.INLINE_WRITE_BARRIER) {
inline(wb,ir,true);
}
}
}
}
}
break;
case GETFIELD_opcode:
{
if (MM_Constants.NEEDS_READ_BARRIER) {
LocationOperand loc=GetField.getLocation(inst);
FieldReference fieldRef=loc.getFieldRef();
if (GetField.getResult(inst).getType().isReferenceType()) {
RVMField field=fieldRef.peekResolvedField();
if (field == null || !field.isUntraced()) {
RVMMethod target=Entrypoints.getfieldReadBarrierMethod;
Instruction rb=Call.create3(CALL,GetField.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),GetField.getClearGuard(inst),GetField.getRef(inst).copy(),GetField.getOffset(inst).copy(),IRTools.IC(fieldRef.getId()));
rb.bcIndex=RUNTIME_SERVICES_BCI;
rb.position=inst.position;
inst.replace(rb);
next=rb.prevInstructionInCodeOrder();
inline(rb,ir,true);
}
}
}
}
break;
case PUTSTATIC_opcode:
{
if (MM_Constants.NEEDS_PUTSTATIC_WRITE_BARRIER) {
LocationOperand loc=PutStatic.getLocation(inst);
FieldReference field=loc.getFieldRef();
if (!field.getFieldContentsType().isPrimitiveType()) {
RVMMethod target=Entrypoints.putstaticWriteBarrierMethod;
Instruction wb=Call.create3(CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),PutStatic.getOffset(inst).copy(),PutStatic.getValue(inst).copy(),IRTools.IC(field.getId()));
wb.bcIndex=RUNTIME_SERVICES_BCI;
wb.position=inst.position;
inst.replace(wb);
next=wb.prevInstructionInCodeOrder();
if (ir.options.INLINE_WRITE_BARRIER) {
inline(wb,ir,true);
}
}
}
}
break;
case GETSTATIC_opcode:
{
if (MM_Constants.NEEDS_GETSTATIC_READ_BARRIER) {
LocationOperand loc=GetStatic.getLocation(inst);
FieldReference field=loc.getFieldRef();
if (!field.getFieldContentsType().isPrimitiveType()) {
RVMMethod target=Entrypoints.getstaticReadBarrierMethod;
Instruction rb=Call.create2(CALL,GetStatic.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),GetStatic.getOffset(inst).copy(),IRTools.IC(field.getId()));
rb.bcIndex=RUNTIME_SERVICES_BCI;
rb.position=inst.position;
inst.replace(rb);
next=rb.prevInstructionInCodeOrder();
inline(rb,ir,true);
}
}
}
break;
default :
break;
}
}
if (didSomething) {
branchOpts.perform(ir,true);
_os.perform(ir);
}
ir.gc.close();
}

Fixed version (ground truth):
/** 
 * Given an HIR, expand operators that are implemented as calls to runtime service methods. This method should be called as one of the first steps in lowering HIR into LIR.
 * @param ir  The HIR to expand
 */
public void perform(IR ir){
  ir.gc.resync();
  Instruction next;
  for (Instruction inst=ir.firstInstructionInCodeOrder(); inst != null; inst=next) {
    next=inst.nextInstructionInCodeOrder();
    int opcode=inst.getOpcode();
switch (opcode) {
case NEW_opcode:
{
        TypeOperand Type=New.getClearType(inst);
        RVMClass cls=(RVMClass)Type.getVMType();
        IntConstantOperand hasFinalizer=IRTools.IC(cls.hasFinalizer() ? 1 : 0);
        RVMMethod callSite=inst.position.getMethod();
        IntConstantOperand allocator=IRTools.IC(MM_Interface.pickAllocator(cls,callSite));
        IntConstantOperand align=IRTools.IC(ObjectModel.getAlignment(cls));
        IntConstantOperand offset=IRTools.IC(ObjectModel.getOffsetForAlignment(cls,false));
        Operand tib=ConvertToLowLevelIR.getTIB(inst,ir,Type);
        if (VM.BuildForIA32 && VM.runningVM) {
          RegisterOperand tmp=ir.regpool.makeTemp(TypeReference.TIB);
          inst.insertBefore(Move.create(REF_MOVE,tmp,tib));
          tib=tmp.copyRO();
        }
        IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
        RVMMethod target=Entrypoints.resolvedNewScalarMethod;
        Call.mutate7(inst,CALL,New.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(cls.getInstanceSize()),tib,hasFinalizer,allocator,align,offset,site);
        next=inst.prevInstructionInCodeOrder();
        if (ir.options.INLINE_NEW) {
          if (inst.getBasicBlock().getInfrequent())           container.counter1++;
          container.counter2++;
          if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
            inline(inst,ir);
          }
        }
      }
    break;
case NEW_UNRESOLVED_opcode:
{
    int typeRefId=New.getType(inst).getTypeRef().getId();
    RVMMethod target=Entrypoints.unresolvedNewScalarMethod;
    IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
    Call.mutate2(inst,CALL,New.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(typeRefId),site);
  }
break;
case NEWARRAY_opcode:
{
TypeOperand Array=NewArray.getClearType(inst);
RVMArray array=(RVMArray)Array.getVMType();
Operand numberElements=NewArray.getClearSize(inst);
boolean inline=numberElements instanceof IntConstantOperand;
Operand width=IRTools.IC(array.getLogElementSize());
Operand headerSize=IRTools.IC(ObjectModel.computeArrayHeaderSize(array));
RVMMethod callSite=inst.position.getMethod();
IntConstantOperand allocator=IRTools.IC(MM_Interface.pickAllocator(array,callSite));
IntConstantOperand align=IRTools.IC(ObjectModel.getAlignment(array));
IntConstantOperand offset=IRTools.IC(ObjectModel.getOffsetForAlignment(array,false));
Operand tib=ConvertToLowLevelIR.getTIB(inst,ir,Array);
if (VM.BuildForIA32 && VM.runningVM) {
  RegisterOperand tmp=ir.regpool.makeTemp(TypeReference.TIB);
  inst.insertBefore(Move.create(REF_MOVE,tmp,tib));
  tib=tmp.copyRO();
}
IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
RVMMethod target=Entrypoints.resolvedNewArrayMethod;
Call.mutate8(inst,CALL,NewArray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),numberElements,width,headerSize,tib,allocator,align,offset,site);
next=inst.prevInstructionInCodeOrder();
if (inline && ir.options.INLINE_NEW) {
  if (inst.getBasicBlock().getInfrequent())   container.counter1++;
  container.counter2++;
  if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
    inline(inst,ir);
  }
}
}
break;
case NEWARRAY_UNRESOLVED_opcode:
{
int typeRefId=NewArray.getType(inst).getTypeRef().getId();
Operand numberElements=NewArray.getClearSize(inst);
RVMMethod target=Entrypoints.unresolvedNewArrayMethod;
IntConstantOperand site=IRTools.IC(MM_Interface.getAllocationSite(true));
Call.mutate3(inst,CALL,NewArray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),numberElements,IRTools.IC(typeRefId),site);
}
break;
case NEWOBJMULTIARRAY_opcode:
{
int dimensions=Multianewarray.getNumberOfDimensions(inst);
RVMMethod callSite=inst.position.getMethod();
int typeRefId=Multianewarray.getType(inst).getTypeRef().getId();
if (dimensions == 2) {
RVMMethod target=Entrypoints.optNew2DArrayMethod;
Call.mutate4(inst,CALL,Multianewarray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(callSite.getId()),Multianewarray.getClearDimension(inst,0),Multianewarray.getClearDimension(inst,1),IRTools.IC(typeRefId));
}
 else {
TypeOperand dimArrayType=new TypeOperand(RVMArray.IntArray);
RegisterOperand dimArray=ir.regpool.makeTemp(TypeReference.IntArray);
dimArray.setPreciseType();
next=NewArray.create(NEWARRAY,dimArray,dimArrayType,new IntConstantOperand(dimensions));
inst.insertBefore(next);
for (int i=0; i < dimensions; i++) {
LocationOperand loc=new LocationOperand(TypeReference.Int);
inst.insertBefore(AStore.create(INT_ASTORE,Multianewarray.getClearDimension(inst,i),dimArray.copyD2U(),IRTools.IC(i),loc,IRTools.TG()));
}
RVMMethod target=Entrypoints.optNewArrayArrayMethod;
Call.mutate3(inst,CALL,Multianewarray.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),IRTools.IC(callSite.getId()),dimArray.copyD2U(),IRTools.IC(typeRefId));
}
}
break;
case ATHROW_opcode:
{
RVMMethod target=Entrypoints.athrowMethod;
MethodOperand methodOp=MethodOperand.STATIC(target);
methodOp.setIsNonReturningCall(true);
Call.mutate1(inst,CALL,null,IRTools.AC(target.getOffset()),methodOp,Athrow.getClearValue(inst));
}
break;
case MONITORENTER_opcode:
{
if (ir.options.NO_SYNCHRO) {
inst.remove();
}
 else {
Operand ref=MonitorOp.getClearRef(inst);
RVMType refType=ref.getType().peekType();
if (refType != null && !refType.getThinLockOffset().isMax()) {
RVMMethod target=Entrypoints.inlineLockMethod;
Call.mutate2(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref,IRTools.AC(refType.getThinLockOffset()));
if (inst.getBasicBlock().getInfrequent()) container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst,ir);
}
}
 else {
RVMMethod target=Entrypoints.lockMethod;
Call.mutate1(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref);
}
}
break;
}
case MONITOREXIT_opcode:
{
if (ir.options.NO_SYNCHRO) {
inst.remove();
}
 else {
Operand ref=MonitorOp.getClearRef(inst);
RVMType refType=ref.getType().peekType();
if (refType != null && !refType.getThinLockOffset().isMax()) {
RVMMethod target=Entrypoints.inlineUnlockMethod;
Call.mutate2(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref,IRTools.AC(refType.getThinLockOffset()));
if (inst.getBasicBlock().getInfrequent()) container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst,ir);
}
}
 else {
RVMMethod target=Entrypoints.unlockMethod;
Call.mutate1(inst,CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),MonitorOp.getClearGuard(inst),ref);
}
}
}
break;
case REF_ASTORE_opcode:
{
if (MM_Constants.NEEDS_WRITE_BARRIER) {
RVMMethod target=Entrypoints.arrayStoreWriteBarrierMethod;
Instruction wb=Call.create3(CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),AStore.getClearGuard(inst),AStore.getArray(inst).copy(),AStore.getIndex(inst).copy(),AStore.getValue(inst).copy());
wb.bcIndex=RUNTIME_SERVICES_BCI;
wb.position=inst.position;
inst.replace(wb);
next=wb.prevInstructionInCodeOrder();
if (ir.options.INLINE_WRITE_BARRIER) {
inline(wb,ir,true);
}
}
}
break;
case REF_ALOAD_opcode:
{
if (MM_Constants.NEEDS_READ_BARRIER) {
RVMMethod target=Entrypoints.arrayLoadReadBarrierMethod;
Instruction rb=Call.create2(CALL,ALoad.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),ALoad.getClearGuard(inst),ALoad.getArray(inst).copy(),ALoad.getIndex(inst).copy());
rb.bcIndex=RUNTIME_SERVICES_BCI;
rb.position=inst.position;
inst.replace(rb);
next=rb.prevInstructionInCodeOrder();
inline(rb,ir,true);
}
}
break;
case PUTFIELD_opcode:
{
if (MM_Constants.NEEDS_WRITE_BARRIER) {
LocationOperand loc=PutField.getLocation(inst);
FieldReference fieldRef=loc.getFieldRef();
if (!fieldRef.getFieldContentsType().isPrimitiveType()) {
RVMField field=fieldRef.peekResolvedField();
if (field == null || !field.isUntraced()) {
RVMMethod target=Entrypoints.putfieldWriteBarrierMethod;
Instruction wb=Call.create4(CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),PutField.getClearGuard(inst),PutField.getRef(inst).copy(),PutField.getOffset(inst).copy(),PutField.getValue(inst).copy(),IRTools.IC(fieldRef.getId()));
wb.bcIndex=RUNTIME_SERVICES_BCI;
wb.position=inst.position;
inst.replace(wb);
next=wb.prevInstructionInCodeOrder();
if (ir.options.INLINE_WRITE_BARRIER) {
inline(wb,ir,true);
}
}
}
}
}
break;
case GETFIELD_opcode:
{
if (MM_Constants.NEEDS_READ_BARRIER) {
LocationOperand loc=GetField.getLocation(inst);
FieldReference fieldRef=loc.getFieldRef();
if (GetField.getResult(inst).getType().isReferenceType()) {
RVMField field=fieldRef.peekResolvedField();
if (field == null || !field.isUntraced()) {
RVMMethod target=Entrypoints.getfieldReadBarrierMethod;
Instruction rb=Call.create3(CALL,GetField.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),GetField.getClearGuard(inst),GetField.getRef(inst).copy(),GetField.getOffset(inst).copy(),IRTools.IC(fieldRef.getId()));
rb.bcIndex=RUNTIME_SERVICES_BCI;
rb.position=inst.position;
inst.replace(rb);
next=rb.prevInstructionInCodeOrder();
inline(rb,ir,true);
}
}
}
}
break;
case PUTSTATIC_opcode:
{
if (MM_Constants.NEEDS_PUTSTATIC_WRITE_BARRIER) {
LocationOperand loc=PutStatic.getLocation(inst);
FieldReference field=loc.getFieldRef();
if (!field.getFieldContentsType().isPrimitiveType()) {
RVMMethod target=Entrypoints.putstaticWriteBarrierMethod;
Instruction wb=Call.create3(CALL,null,IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),PutStatic.getOffset(inst).copy(),PutStatic.getValue(inst).copy(),IRTools.IC(field.getId()));
wb.bcIndex=RUNTIME_SERVICES_BCI;
wb.position=inst.position;
inst.replace(wb);
next=wb.prevInstructionInCodeOrder();
if (ir.options.INLINE_WRITE_BARRIER) {
inline(wb,ir,true);
}
}
}
}
break;
case GETSTATIC_opcode:
{
if (MM_Constants.NEEDS_GETSTATIC_READ_BARRIER) {
LocationOperand loc=GetStatic.getLocation(inst);
FieldReference field=loc.getFieldRef();
if (!field.getFieldContentsType().isPrimitiveType()) {
RVMMethod target=Entrypoints.getstaticReadBarrierMethod;
Instruction rb=Call.create2(CALL,GetStatic.getClearResult(inst),IRTools.AC(target.getOffset()),MethodOperand.STATIC(target),GetStatic.getOffset(inst).copy(),IRTools.IC(field.getId()));
rb.bcIndex=RUNTIME_SERVICES_BCI;
rb.position=inst.position;
inst.replace(rb);
next=rb.prevInstructionInCodeOrder();
inline(rb,ir,true);
}
}
}
break;
default :
break;
}
}
if (didSomething) {
branchOpts.perform(ir,true);
_os.perform(ir);
}
ir.gc.close();
}