Program: 149974
Project: 149974
Buggy source:
/** 
 * Insert the prologue for a normal method.   Assume we are inserting the prologue for method B called from method A.   <ul> <li> Perform a stack overflow check. <li> Store a back pointer to A's frame <li> Store B's compiled method id <li> Adjust frame pointer to point to B's frame <li> Save any used non-volatile registers </ul>
 */
void insertNormalPrologue(){
  OPT_PhysicalRegisterSet phys=ir.regpool.getPhysicalRegisterSet();
  OPT_Register ESP=phys.getESP();
  OPT_Register PR=phys.getPR();
  OPT_MemoryOperand fpHome=OPT_MemoryOperand.BD(new OPT_RegisterOperand(PR,VM_TypeReference.Int),VM_Entrypoints.framePointerField.getOffset(),(byte)WORDSIZE,null,null);
  OPT_Instruction inst=ir.firstInstructionInCodeOrder().nextInstructionInCodeOrder().nextInstructionInCodeOrder();
  OPT_Instruction plg=inst.getPrev();
  int frameFixedSize=getFrameFixedSize();
  ir.compiledMethod.setFrameFixedSize(frameFixedSize);
  if (frameFixedSize >= 256) {
    insertBigFrameStackOverflowCheck(plg);
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,fpHome));
    inst.insertBefore(MIR_Move.create(IA32_MOV,fpHome.copy(),new OPT_RegisterOperand(ESP,VM_TypeReference.Int)));
    int cmid=ir.compiledMethod.getId();
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,IC(cmid)));
  }
 else {
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,fpHome));
    inst.insertBefore(MIR_Move.create(IA32_MOV,fpHome.copy(),new OPT_RegisterOperand(ESP,VM_TypeReference.Int)));
    int cmid=ir.compiledMethod.getId();
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,IC(cmid)));
    insertNormalStackOverflowCheck(plg);
  }
  if (ir.compiledMethod.isSaveVolatile()) {
    saveVolatiles(inst);
    saveFloatingPointState(inst);
  }
  saveNonVolatiles(inst);
  inst.insertBefore(Empty.create(IR_ENDPROLOGUE));
}

Fixed version (ground truth):
/** 
 * Insert the prologue for a normal method.   Assume we are inserting the prologue for method B called from method A.   <ul> <li> Perform a stack overflow check. <li> Store a back pointer to A's frame <li> Store B's compiled method id <li> Adjust frame pointer to point to B's frame <li> Save any used non-volatile registers </ul>
 */
void insertNormalPrologue(){
  OPT_PhysicalRegisterSet phys=ir.regpool.getPhysicalRegisterSet();
  OPT_Register ESP=phys.getESP();
  OPT_Register PR=phys.getPR();
  OPT_MemoryOperand fpHome=OPT_MemoryOperand.BD(new OPT_RegisterOperand(PR,VM_TypeReference.Int),VM_Entrypoints.framePointerField.getOffset(),(byte)WORDSIZE,null,null);
  OPT_Instruction inst=ir.firstInstructionInCodeOrder().nextInstructionInCodeOrder().nextInstructionInCodeOrder();
  OPT_Instruction plg=inst.getPrev();
  int frameFixedSize=getFrameFixedSize();
  ir.compiledMethod.setFrameFixedSize(frameFixedSize);
  if (frameFixedSize >= 256) {
    insertBigFrameStackOverflowCheck(plg);
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,fpHome));
    inst.insertBefore(MIR_Move.create(IA32_MOV,fpHome.copy(),new OPT_RegisterOperand(ESP,VM_TypeReference.Int)));
    int cmid=ir.compiledMethod.getId();
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,IC(cmid)));
  }
 else {
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,fpHome));
    inst.insertBefore(MIR_Move.create(IA32_MOV,fpHome.copy(),new OPT_RegisterOperand(ESP,VM_TypeReference.Int)));
    int cmid=ir.compiledMethod.getId();
    inst.insertBefore(MIR_UnaryNoRes.create(IA32_PUSH,IC(cmid)));
    insertNormalStackOverflowCheck(plg);
  }
  if (ir.compiledMethod.isSaveVolatile()) {
    saveVolatiles(inst);
    saveFloatingPointState(inst);
  }
  saveNonVolatiles(inst);
}