nus-yam/ex-repair huggingface dataset:
Program: 149780
Project: 149780
Buggy source:
/** 
 * Finalize the space map, establishing which virtual memory is nailed down, and then placing the rest into a map to be used by discontiguous spaces.
 */
@Interruptible public static void finalizeStaticSpaceMap(){
  Address startAddress=Space.getDiscontigStart();
  int first=hashAddress(startAddress);
  int last=hashAddress(Space.getDiscontigEnd().minus(1));
  int pages=(1 + last - first) * Space.PAGES_IN_CHUNK + 1;
  globalPageMap.resizeFreeList(pages,pages);
  for (int pr=0; pr < sharedDiscontigFLCount; pr++)   sharedFLMap[pr].resizeFreeList(startAddress);
  regionMap.alloc(first);
  for (int chunk=first; chunk <= last; chunk++)   regionMap.alloc(1);
  regionMap.alloc(Space.MAX_CHUNKS - last);
  int firstPage=0;
  for (int chunk=first; chunk <= last; chunk++) {
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(spaceMap[chunk] == null);
    totalAvailableDiscontiguousChunks++;
    regionMap.free(chunk);
    globalPageMap.setUncoalescable(firstPage);
    int tmp=globalPageMap.alloc(Space.PAGES_IN_CHUNK);
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(tmp == firstPage);
    firstPage+=Space.PAGES_IN_CHUNK;
  }
}

Fixed version (ground truth):
/** 
 * Finalize the space map, establishing which virtual memory is nailed down, and then placing the rest into a map to be used by discontiguous spaces.
 */
@Interruptible public static void finalizeStaticSpaceMap(){
  Address startAddress=Space.getDiscontigStart();
  int first=hashAddress(startAddress);
  int last=hashAddress(Space.getDiscontigEnd());
  int unavailStart=last + 1;
  int trailingUnavail=Space.MAX_CHUNKS - unavailStart;
  int pages=(1 + last - first) * Space.PAGES_IN_CHUNK;
  globalPageMap.resizeFreeList(pages,pages);
  for (int pr=0; pr < sharedDiscontigFLCount; pr++)   sharedFLMap[pr].resizeFreeList(startAddress);
  int index=regionMap.alloc(first);
  for (int chunk=first; chunk <= last; chunk++)   index=regionMap.alloc(1);
  index=regionMap.alloc(trailingUnavail);
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(index == unavailStart);
  int firstPage=0;
  for (int chunk=first; chunk <= last; chunk++) {
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(spaceMap[chunk] == null);
    totalAvailableDiscontiguousChunks++;
    regionMap.free(chunk);
    globalPageMap.setUncoalescable(firstPage);
    int tmp=globalPageMap.alloc(Space.PAGES_IN_CHUNK);
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(tmp == firstPage);
    firstPage+=Space.PAGES_IN_CHUNK;
  }
}
Program: 149781
Project: 149781
Buggy source:
/** 
 * Initiate a garbage collection.  Called by a mutator thread when its allocator runs out of space.  The caller should pass the Handshake that was referenced by the static variable "collect" at the time space was unavailable.
 * @param handshake Handshake for the requested collection
 */
@Unpreemptible("String_Node_Str") public static void collect(Handshake handshake,int why){
  Processor.getCurrentFeedlet().addEvent(MMTk_Events.events.gcStart,why);
  handshake.requestAndAwaitCompletion(why);
  Processor.getCurrentFeedlet().addEvent(MMTk_Events.events.gcStart,why);
}

Fixed version (ground truth):
/** 
 * Initiate a garbage collection.  Called by a mutator thread when its allocator runs out of space.  The caller should pass the Handshake that was referenced by the static variable "collect" at the time space was unavailable.
 * @param handshake Handshake for the requested collection
 */
@Unpreemptible("String_Node_Str") public static void collect(Handshake handshake,int why){
  Processor.getCurrentFeedlet().addEvent(MMTk_Events.events.gcStart,why);
  handshake.requestAndAwaitCompletion(why);
  Processor.getCurrentFeedlet().addEvent(MMTk_Events.events.gcStop);
}
Program: 149782
Project: 149782
Buggy source:
@Override public int rendezvous(int where){
  return rendezvous.rendezvous(where);
}

Fixed version (ground truth):
@Override public int rendezvous(int where){
  return Rendezvous.rendezvous(where);
}
Program: 149783
Project: 149783
Buggy source:
/** 
 * Rendezvous with all other processors, returning the rank (that is, the order this processor arrived at the barrier).
 */
int rendezvous(int where){
}

Fixed version (ground truth):
/** 
 * Dispatch to the current rendezvous object
 * @param where
 * @return
 */
static int rendezvous(int where){
  return current(where).rendezvous();
}
Program: 149785
Project: 149785
Buggy source:
/** 
 * Release a group of pages, associated with this page resource, that were allocated together, optionally zeroing on release and optionally memory protecting on release.
 * @param first The first page in the group of pages that wereallocated together.
 */
@Inline public void releasePages(Address first){
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(Conversions.isPageAligned(first));
  int pageOffset=Conversions.bytesToPages(first.diff(start));
  int pages=freeList.size(pageOffset);
  if (ZERO_ON_RELEASE)   VM.memory.zero(first,Conversions.pagesToBytes(pages));
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(pages <= committed);
  lock();
  reserved-=pages;
  committed-=pages;
  int freed=freeList.free(pageOffset,true);
  pagesCurrentlyOnFreeList+=pages;
  boolean completelyFreed=!contiguous && metaDataPagesPerRegion > 0 && freed == (PAGES_IN_CHUNK - metaDataPagesPerRegion);
  if (!contiguous && (freed % PAGES_IN_CHUNK == 0)) {
    int regionStart=pageOffset & ~(PAGES_IN_CHUNK - 1);
    int nextRegionStart=regionStart + PAGES_IN_CHUNK;
    while (regionStart >= 0 && freeList.isCoalescable(regionStart))     regionStart-=PAGES_IN_CHUNK;
    while (nextRegionStart < GenericFreeList.MAX_UNITS && freeList.isCoalescable(nextRegionStart))     nextRegionStart+=PAGES_IN_CHUNK;
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(regionStart >= 0 && nextRegionStart < GenericFreeList.MAX_UNITS);
    completelyFreed=(freed == nextRegionStart - regionStart);
  }
  if (completelyFreed)   freeContiguousChunk(Space.chunkAlign(first,true));
  unlock();
}

Fixed version (ground truth):
/** 
 * Release a group of pages, associated with this page resource, that were allocated together, optionally zeroing on release and optionally memory protecting on release.
 * @param first The first page in the group of pages that wereallocated together.
 */
@Inline public void releasePages(Address first){
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(Conversions.isPageAligned(first));
  int pageOffset=Conversions.bytesToPages(first.diff(start));
  int pages=freeList.size(pageOffset);
  if (ZERO_ON_RELEASE)   VM.memory.zero(first,Conversions.pagesToBytes(pages));
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(pages <= committed);
  lock();
  reserved-=pages;
  committed-=pages;
  int freed=freeList.free(pageOffset,true);
  pagesCurrentlyOnFreeList+=pages;
  if (!contiguous)   releaseFreeChunks(first,freed);
  unlock();
}
Program: 149786
Project: 149786
Buggy source:
/** 
 * Copies characters from the string into the character array. Thread switching is disabled during this method's execution. <p> <b>TODO:</b> There are special memory management semantics here that someone should document.
 * @param str the source string
 * @param dst the destination array
 * @param dstBegin the start offset in the desination array
 * @param dstEnd the index after the last character in thedestination to copy to
 * @return the number of characters copied.
 */
public int copyStringToChars(String str,char[] dst,int dstBegin,int dstEnd){
  if (VM.runningVM) {
    Processor.getCurrentProcessor().disableThreadSwitching("String_Node_Str");
  }
  char[] str_backing=java.lang.JikesRVMSupport.getBackingCharArray(str);
  int str_length=java.lang.JikesRVMSupport.getStringLength(str);
  int str_offset=java.lang.JikesRVMSupport.getStringOffset(str);
  int n=(dstBegin + str_length <= dstEnd) ? str_length : (dstEnd - dstBegin);
  for (int i=0; i < n; i++) {
    Services.setArrayNoBarrier(dst,dstBegin + i,str_backing[str_offset + i]);
  }
  if (VM.runningVM) {
    Processor.getCurrentProcessor().enableThreadSwitching();
  }
  return n;
}

Fixed version (ground truth):
/** 
 * Copies characters from the string into the character array. Thread switching is disabled during this method's execution.
 * @param str the source string
 * @param dst the destination array
 * @param dstBegin the start offset in the desination array
 * @param dstEnd the index after the last character in thedestination to copy to
 * @return the number of characters copied.
 */
public int copyStringToChars(String str,char[] dst,int dstBegin,int dstEnd){
  if (!VM.runningVM)   return naiveCopyStringToChars(str,dst,dstBegin,dstEnd);
 else   return safeCopyStringToChars(str,dst,dstBegin,dstEnd);
}
Program: 149787
Project: 149787
Buggy source:
/** 
 * Finalize the space map, establishing which virtual memory is nailed down, and then placing the rest into a map to be used by discontiguous spaces.
 */
@Interruptible public static void finalizeStaticSpaceMap(){
  Address startAddress=Space.getDiscontigStart();
  int start=hashAddress(startAddress);
  int end=hashAddress(Space.getDiscontigEnd());
  int pages=(end - start) * Space.PAGES_IN_CHUNK + 1;
  globalPageMap.resizeFreeList(pages,pages);
  for (int pr=0; pr < sharedDiscontigFLCount; pr++)   sharedFLMap[pr].resizeFreeList(startAddress);
  regionMap.alloc(start);
  for (int chunk=start; chunk < end; chunk++)   regionMap.alloc(1);
  regionMap.alloc(Space.MAX_CHUNKS - end);
  int firstPage=0;
  for (int chunk=start; chunk < end; chunk++) {
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(spaceMap[chunk] == null);
    totalAvailableDiscontiguousChunks++;
    regionMap.free(chunk);
    globalPageMap.setUncoalescable(firstPage);
    int tmp=globalPageMap.alloc(Space.PAGES_IN_CHUNK);
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(tmp == firstPage);
    firstPage+=Space.PAGES_IN_CHUNK;
  }
}

Fixed version (ground truth):
/** 
 * Finalize the space map, establishing which virtual memory is nailed down, and then placing the rest into a map to be used by discontiguous spaces.
 */
@Interruptible public static void finalizeStaticSpaceMap(){
  Address startAddress=Space.getDiscontigStart();
  int first=hashAddress(startAddress);
  int last=hashAddress(Space.getDiscontigEnd().minus(1));
  int pages=(1 + last - first) * Space.PAGES_IN_CHUNK + 1;
  globalPageMap.resizeFreeList(pages,pages);
  for (int pr=0; pr < sharedDiscontigFLCount; pr++)   sharedFLMap[pr].resizeFreeList(startAddress);
  regionMap.alloc(first);
  for (int chunk=first; chunk <= last; chunk++)   regionMap.alloc(1);
  regionMap.alloc(Space.MAX_CHUNKS - last);
  int firstPage=0;
  for (int chunk=first; chunk <= last; chunk++) {
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(spaceMap[chunk] == null);
    totalAvailableDiscontiguousChunks++;
    regionMap.free(chunk);
    globalPageMap.setUncoalescable(firstPage);
    int tmp=globalPageMap.alloc(Space.PAGES_IN_CHUNK);
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(tmp == firstPage);
    firstPage+=Space.PAGES_IN_CHUNK;
  }
}
Program: 149789
Project: 149789
Buggy source:
/** 
 * Emit code to implement the instanceof bytecode
 * @param type     The LHS type
 */
protected final void emit_instanceof_resolvedClass(RVMClass type){
  int LHSDepth=type.getTypeDepth();
  int LHSId=type.getId();
  popAddr(T0);
  asm.emitCMPAddrI(T0,0);
  ForwardReference isNull=asm.emitForwardBC(EQ);
  ObjectModel.baselineEmitLoadTIB(asm,T0,T0);
  asm.emitLAddr(T0,TIB_SUPERCLASS_IDS_INDEX << LOG_BYTES_IN_ADDRESS,T0);
  ForwardReference outOfBounds=null;
  if (DynamicTypeCheck.MIN_SUPERCLASS_IDS_SIZE <= LHSDepth) {
    asm.emitLIntOffset(T1,T0,ObjectModel.getArrayLengthOffset());
    asm.emitLVAL(T2,LHSDepth);
    asm.emitCMPL(T1,T2);
    outOfBounds=asm.emitForwardBC(LE);
  }
  asm.emitLHZ(T0,LHSDepth << LOG_BYTES_IN_CHAR,T0);
  asm.emitCMPI(T0,LHSId);
  ForwardReference notMatched=asm.emitForwardBC(NE);
  asm.emitLVAL(T0,1);
  ForwardReference done=asm.emitForwardB();
  isNull.resolve(asm);
  if (outOfBounds != null)   outOfBounds.resolve(asm);
  notMatched.resolve(asm);
  asm.emitLVAL(T0,0);
  done.resolve(asm);
  pushInt(T0);
}

Fixed version (ground truth):
/** 
 * Emit code to implement the instanceof bytecode
 * @param type     The LHS type
 */
protected final void emit_instanceof_resolvedClass(RVMClass type){
  int LHSDepth=type.getTypeDepth();
  int LHSId=type.getId();
  popAddr(T0);
  asm.emitCMPAddrI(T0,0);
  ForwardReference isNull=asm.emitForwardBC(EQ);
  ObjectModel.baselineEmitLoadTIB(asm,T0,T0);
  asm.emitLAddr(T0,TIB_SUPERCLASS_IDS_INDEX << LOG_BYTES_IN_ADDRESS,T0);
  ForwardReference outOfBounds=null;
  if (DynamicTypeCheck.MIN_SUPERCLASS_IDS_SIZE <= LHSDepth) {
    asm.emitLIntOffset(T1,T0,ObjectModel.getArrayLengthOffset());
    asm.emitLVAL(T2,LHSDepth);
    asm.emitCMPL(T1,T2);
    outOfBounds=asm.emitForwardBC(LE);
  }
  asm.emitLHZ(T0,LHSDepth << LOG_BYTES_IN_CHAR,T0);
  if (Assembler.fits(LHSId,16)) {
    asm.emitCMPI(T0,LHSId);
  }
 else {
    asm.emitLVAL(T1,LHSId);
    asm.emitCMP(T0,T1);
  }
  ForwardReference notMatched=asm.emitForwardBC(NE);
  asm.emitLVAL(T0,1);
  ForwardReference done=asm.emitForwardB();
  isNull.resolve(asm);
  if (outOfBounds != null)   outOfBounds.resolve(asm);
  notMatched.resolve(asm);
  asm.emitLVAL(T0,0);
  done.resolve(asm);
  pushInt(T0);
}
Program: 149790
Project: 149790
Buggy source:
/** 
 * Emit code to implement the checkcast bytecode
 * @param type   The LHS type
 */
protected final void emit_checkcast_resolvedClass(RVMClass type){
  int LHSDepth=type.getTypeDepth();
  int LHSId=type.getId();
  peekAddr(T0,0);
  asm.emitCMPAddrI(T0,0);
  ForwardReference isNull=asm.emitForwardBC(EQ);
  ObjectModel.baselineEmitLoadTIB(asm,T0,T0);
  asm.emitLAddr(T0,TIB_SUPERCLASS_IDS_INDEX << LOG_BYTES_IN_ADDRESS,T0);
  if (DynamicTypeCheck.MIN_SUPERCLASS_IDS_SIZE <= LHSDepth) {
    asm.emitLIntOffset(T1,T0,ObjectModel.getArrayLengthOffset());
    asm.emitLVAL(T2,LHSDepth);
    asm.emitCMPL(T2,T1);
    ForwardReference fr1=asm.emitForwardBC(LT);
    asm.emitTWI(31,12,TrapConstants.CHECKCAST_TRAP);
    fr1.resolve(asm);
  }
  asm.emitLHZ(T0,LHSDepth << LOG_BYTES_IN_CHAR,T0);
  asm.emitCMPI(T0,LHSId);
  ForwardReference fr2=asm.emitForwardBC(EQ);
  asm.emitTWI(31,12,TrapConstants.CHECKCAST_TRAP);
  fr2.resolve(asm);
  isNull.resolve(asm);
}

Fixed version (ground truth):
/** 
 * Emit code to implement the checkcast bytecode
 * @param type   The LHS type
 */
protected final void emit_checkcast_resolvedClass(RVMClass type){
  int LHSDepth=type.getTypeDepth();
  int LHSId=type.getId();
  peekAddr(T0,0);
  asm.emitCMPAddrI(T0,0);
  ForwardReference isNull=asm.emitForwardBC(EQ);
  ObjectModel.baselineEmitLoadTIB(asm,T0,T0);
  asm.emitLAddr(T0,TIB_SUPERCLASS_IDS_INDEX << LOG_BYTES_IN_ADDRESS,T0);
  if (DynamicTypeCheck.MIN_SUPERCLASS_IDS_SIZE <= LHSDepth) {
    asm.emitLIntOffset(T1,T0,ObjectModel.getArrayLengthOffset());
    asm.emitLVAL(T2,LHSDepth);
    asm.emitCMPL(T2,T1);
    ForwardReference fr1=asm.emitForwardBC(LT);
    asm.emitTWI(31,12,TrapConstants.CHECKCAST_TRAP);
    fr1.resolve(asm);
  }
  asm.emitLHZ(T0,LHSDepth << LOG_BYTES_IN_CHAR,T0);
  if (Assembler.fits(LHSId,16)) {
    asm.emitCMPI(T0,LHSId);
  }
 else {
    asm.emitLVAL(T1,LHSId);
    asm.emitCMP(T0,T1);
  }
  ForwardReference fr2=asm.emitForwardBC(EQ);
  asm.emitTWI(31,12,TrapConstants.CHECKCAST_TRAP);
  fr2.resolve(asm);
  isNull.resolve(asm);
}
Program: 149791
Project: 149791
Buggy source:
/** 
 * Create an array of a particular type. The easiest way to use this is: Foo[] x = (Foo [])Stream.createDataArray(new Foo[0], numElements);
 * @param templ a data array to use as a template
 * @param numElements number of elements in new array
 * @return the new array
 */
@Interruptible public Object createDataArray(Object templ,int numElements){
  if (org.jikesrvm.VM.BuildWithGCSpy) {
    RVMArray array=Magic.getObjectType(templ).asArray();
    return RuntimeEntrypoints.resolvedNewArray(numElements,array.getLogElementSize(),ObjectModel.computeArrayHeaderSize(array),array.getTypeInformationBlock(),Plan.ALLOC_GCSPY,ObjectModel.getAlignment(array),ObjectModel.getOffsetForAlignment(array),0);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Create an array of a particular type. The easiest way to use this is: Foo[] x = (Foo [])Stream.createDataArray(new Foo[0], numElements);
 * @param templ a data array to use as a template
 * @param numElements number of elements in new array
 * @return the new array
 */
@Interruptible public Object createDataArray(Object templ,int numElements){
  if (org.jikesrvm.VM.BuildWithGCSpy) {
    RVMArray array=Magic.getObjectType(templ).asArray();
    return RuntimeEntrypoints.resolvedNewArray(numElements,array.getLogElementSize(),ObjectModel.computeArrayHeaderSize(array),array.getTypeInformationBlock(),Plan.ALLOC_GCSPY,ObjectModel.getAlignment(array),ObjectModel.getOffsetForAlignment(array,false),0);
  }
 else {
    return null;
  }
}
Program: 149792
Project: 149792
Buggy source:
/** 
 * Emit code to allocate an array
 * @param array the RVMArray to instantiate
 */
@Override protected final void emit_resolved_newarray(RVMArray array){
  int width=array.getLogElementSize();
  Offset tibOffset=array.getTibOffset();
  int headerSize=ObjectModel.computeHeaderSize(array);
  int whichAllocator=MM_Interface.pickAllocator(array,method);
  int site=MM_Interface.getAllocationSite(true);
  int align=ObjectModel.getAlignment(array);
  int offset=ObjectModel.getOffsetForAlignment(array);
  asm.emitPUSH_Imm(width);
  asm.emitPUSH_Imm(headerSize);
  asm.emitPUSH_Abs(Magic.getTocPointer().plus(tibOffset));
  asm.emitPUSH_Imm(whichAllocator);
  asm.emitPUSH_Imm(align);
  asm.emitPUSH_Imm(offset);
  asm.emitPUSH_Imm(site);
  genParameterRegisterLoad(8);
  asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.resolvedNewArrayMethod.getOffset()));
  asm.emitPUSH_Reg(T0);
}

Fixed version (ground truth):
/** 
 * Emit code to allocate an array
 * @param array the RVMArray to instantiate
 */
@Override protected final void emit_resolved_newarray(RVMArray array){
  int width=array.getLogElementSize();
  Offset tibOffset=array.getTibOffset();
  int headerSize=ObjectModel.computeHeaderSize(array);
  int whichAllocator=MM_Interface.pickAllocator(array,method);
  int site=MM_Interface.getAllocationSite(true);
  int align=ObjectModel.getAlignment(array);
  int offset=ObjectModel.getOffsetForAlignment(array,false);
  asm.emitPUSH_Imm(width);
  asm.emitPUSH_Imm(headerSize);
  asm.emitPUSH_Abs(Magic.getTocPointer().plus(tibOffset));
  asm.emitPUSH_Imm(whichAllocator);
  asm.emitPUSH_Imm(align);
  asm.emitPUSH_Imm(offset);
  asm.emitPUSH_Imm(site);
  genParameterRegisterLoad(8);
  asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.resolvedNewArrayMethod.getOffset()));
  asm.emitPUSH_Reg(T0);
}
Program: 149793
Project: 149793
Buggy source:
/** 
 * Emit code to allocate a scalar object
 * @param typeRef the RVMClass to instantiate
 */
@Override protected final void emit_resolved_new(RVMClass typeRef){
  int instanceSize=typeRef.getInstanceSize();
  Offset tibOffset=typeRef.getTibOffset();
  int whichAllocator=MM_Interface.pickAllocator(typeRef,method);
  int align=ObjectModel.getAlignment(typeRef);
  int offset=ObjectModel.getOffsetForAlignment(typeRef);
  int site=MM_Interface.getAllocationSite(true);
  asm.emitPUSH_Imm(instanceSize);
  asm.emitPUSH_Abs(Magic.getTocPointer().plus(tibOffset));
  asm.emitPUSH_Imm(typeRef.hasFinalizer() ? 1 : 0);
  asm.emitPUSH_Imm(whichAllocator);
  asm.emitPUSH_Imm(align);
  asm.emitPUSH_Imm(offset);
  asm.emitPUSH_Imm(site);
  genParameterRegisterLoad(7);
  asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.resolvedNewScalarMethod.getOffset()));
  asm.emitPUSH_Reg(T0);
}

Fixed version (ground truth):
/** 
 * Emit code to allocate a scalar object
 * @param typeRef the RVMClass to instantiate
 */
@Override protected final void emit_resolved_new(RVMClass typeRef){
  int instanceSize=typeRef.getInstanceSize();
  Offset tibOffset=typeRef.getTibOffset();
  int whichAllocator=MM_Interface.pickAllocator(typeRef,method);
  int align=ObjectModel.getAlignment(typeRef,false);
  int offset=ObjectModel.getOffsetForAlignment(typeRef,false);
  int site=MM_Interface.getAllocationSite(true);
  asm.emitPUSH_Imm(instanceSize);
  asm.emitPUSH_Abs(Magic.getTocPointer().plus(tibOffset));
  asm.emitPUSH_Imm(typeRef.hasFinalizer() ? 1 : 0);
  asm.emitPUSH_Imm(whichAllocator);
  asm.emitPUSH_Imm(align);
  asm.emitPUSH_Imm(offset);
  asm.emitPUSH_Imm(site);
  genParameterRegisterLoad(7);
  asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.resolvedNewScalarMethod.getOffset()));
  asm.emitPUSH_Reg(T0);
}
Program: 149794
Project: 149794
Buggy source:
/** 
 * Emit code to allocate an array
 * @param array the RVMArray to instantiate
 */
protected final void emit_resolved_newarray(RVMArray array){
  int width=array.getLogElementSize();
  Offset tibOffset=array.getTibOffset();
  int headerSize=ObjectModel.computeArrayHeaderSize(array);
  int whichAllocator=MM_Interface.pickAllocator(array,method);
  int site=MM_Interface.getAllocationSite(true);
  int align=ObjectModel.getAlignment(array);
  int offset=ObjectModel.getOffsetForAlignment(array);
  asm.emitLAddrToc(T0,Entrypoints.resolvedNewArrayMethod.getOffset());
  asm.emitMTCTR(T0);
  peekInt(T0,0);
  asm.emitLVAL(T5,site);
  asm.emitLVAL(T1,width);
  asm.emitLVAL(T2,headerSize);
  asm.emitLAddrToc(T3,tibOffset);
  asm.emitLVAL(T4,whichAllocator);
  asm.emitLVAL(T5,align);
  asm.emitLVAL(T6,offset);
  asm.emitBCCTRL();
  pokeAddr(T0,0);
}

Fixed version (ground truth):
/** 
 * Emit code to allocate an array
 * @param array the RVMArray to instantiate
 */
protected final void emit_resolved_newarray(RVMArray array){
  int width=array.getLogElementSize();
  Offset tibOffset=array.getTibOffset();
  int headerSize=ObjectModel.computeArrayHeaderSize(array);
  int whichAllocator=MM_Interface.pickAllocator(array,method);
  int site=MM_Interface.getAllocationSite(true);
  int align=ObjectModel.getAlignment(array);
  int offset=ObjectModel.getOffsetForAlignment(array,false);
  asm.emitLAddrToc(T0,Entrypoints.resolvedNewArrayMethod.getOffset());
  asm.emitMTCTR(T0);
  peekInt(T0,0);
  asm.emitLVAL(T5,site);
  asm.emitLVAL(T1,width);
  asm.emitLVAL(T2,headerSize);
  asm.emitLAddrToc(T3,tibOffset);
  asm.emitLVAL(T4,whichAllocator);
  asm.emitLVAL(T5,align);
  asm.emitLVAL(T6,offset);
  asm.emitBCCTRL();
  pokeAddr(T0,0);
}
Program: 149795
Project: 149795
Buggy source:
/** 
 * Emit code to allocate a scalar object
 * @param typeRef the RVMClass to instantiate
 */
protected final void emit_resolved_new(RVMClass typeRef){
  int instanceSize=typeRef.getInstanceSize();
  Offset tibOffset=typeRef.getTibOffset();
  int whichAllocator=MM_Interface.pickAllocator(typeRef,method);
  int align=ObjectModel.getAlignment(typeRef);
  int offset=ObjectModel.getOffsetForAlignment(typeRef);
  int site=MM_Interface.getAllocationSite(true);
  asm.emitLAddrToc(T0,Entrypoints.resolvedNewScalarMethod.getOffset());
  asm.emitMTCTR(T0);
  asm.emitLVAL(T0,instanceSize);
  asm.emitLAddrToc(T1,tibOffset);
  asm.emitLVAL(T2,typeRef.hasFinalizer() ? 1 : 0);
  asm.emitLVAL(T3,whichAllocator);
  asm.emitLVAL(T4,site);
  asm.emitLVAL(T4,align);
  asm.emitLVAL(T5,offset);
  asm.emitBCCTRL();
  pushAddr(T0);
}

Fixed version (ground truth):
/** 
 * Emit code to allocate a scalar object
 * @param typeRef the RVMClass to instantiate
 */
protected final void emit_resolved_new(RVMClass typeRef){
  int instanceSize=typeRef.getInstanceSize();
  Offset tibOffset=typeRef.getTibOffset();
  int whichAllocator=MM_Interface.pickAllocator(typeRef,method);
  int align=ObjectModel.getAlignment(typeRef);
  int offset=ObjectModel.getOffsetForAlignment(typeRef,false);
  int site=MM_Interface.getAllocationSite(true);
  asm.emitLAddrToc(T0,Entrypoints.resolvedNewScalarMethod.getOffset());
  asm.emitMTCTR(T0);
  asm.emitLVAL(T0,instanceSize);
  asm.emitLAddrToc(T1,tibOffset);
  asm.emitLVAL(T2,typeRef.hasFinalizer() ? 1 : 0);
  asm.emitLVAL(T3,whichAllocator);
  asm.emitLVAL(T4,site);
  asm.emitLVAL(T4,align);
  asm.emitLVAL(T5,offset);
  asm.emitBCCTRL();
  pushAddr(T0);
}
Program: 149797
Project: 149797
Buggy source:
/** 
 * Allocate a non moving int array
 * @param size The size of the array
 */
@Inline @Interruptible public static int[] newNonMovingIntArray(int size){
  if (!VM.runningVM) {
    return new int[size];
  }
  RVMArray arrayType=RVMArray.IntArray;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (int[])allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}

Fixed version (ground truth):
/** 
 * Allocate a non moving int array
 * @param size The size of the array
 */
@Inline @Interruptible public static int[] newNonMovingIntArray(int size){
  if (!VM.runningVM) {
    return new int[size];
  }
  RVMArray arrayType=RVMArray.IntArray;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType,false);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (int[])allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}
Program: 149798
Project: 149798
Buggy source:
/** 
 * Allocate a new runtime table (at runtime)
 * @param size The size of the table.
 * @return the newly allocated table
 */
@Inline @Interruptible public static Object newRuntimeTable(int size,RVMType type){
  if (VM.VerifyAssertions)   VM._assert(VM.runningVM);
  TIB realTib=type.getTypeInformationBlock();
  RVMArray fakeType=RVMType.WordArrayType;
  TIB fakeTib=fakeType.getTypeInformationBlock();
  int headerSize=ObjectModel.computeArrayHeaderSize(fakeType);
  int align=ObjectModel.getAlignment(fakeType);
  int offset=ObjectModel.getOffsetForAlignment(fakeType);
  int width=fakeType.getLogElementSize();
  Object array=allocateArray(size,width,headerSize,fakeTib,type.getMMAllocator(),align,offset,Plan.DEFAULT_SITE);
  ObjectModel.setTIB(array,realTib);
  return array;
}

Fixed version (ground truth):
/** 
 * Allocate a new runtime table (at runtime)
 * @param size The size of the table.
 * @return the newly allocated table
 */
@Inline @Interruptible public static Object newRuntimeTable(int size,RVMType type){
  if (VM.VerifyAssertions)   VM._assert(VM.runningVM);
  TIB realTib=type.getTypeInformationBlock();
  RVMArray fakeType=RVMType.WordArrayType;
  TIB fakeTib=fakeType.getTypeInformationBlock();
  int headerSize=ObjectModel.computeArrayHeaderSize(fakeType);
  int align=ObjectModel.getAlignment(fakeType);
  int offset=ObjectModel.getOffsetForAlignment(fakeType,false);
  int width=fakeType.getLogElementSize();
  Object array=allocateArray(size,width,headerSize,fakeTib,type.getMMAllocator(),align,offset,Plan.DEFAULT_SITE);
  ObjectModel.setTIB(array,realTib);
  return array;
}
Program: 149799
Project: 149799
Buggy source:
/** 
 * Allocate a stack
 * @param bytes    The number of bytes to allocate
 * @param immortal  Is the stack immortal and non-moving?
 * @return The stack
 */
@Inline @Interruptible public static byte[] newStack(int bytes,boolean immortal){
  if (!VM.runningVM) {
    return new byte[bytes];
  }
 else {
    RVMArray stackType=RVMArray.ByteArray;
    int headerSize=ObjectModel.computeArrayHeaderSize(stackType);
    int align=ObjectModel.getAlignment(stackType);
    int offset=ObjectModel.getOffsetForAlignment(stackType);
    int width=stackType.getLogElementSize();
    TIB stackTib=stackType.getTypeInformationBlock();
    return (byte[])allocateArray(bytes,width,headerSize,stackTib,(immortal ? Plan.ALLOC_IMMORTAL_STACK : Plan.ALLOC_STACK),align,offset,Plan.DEFAULT_SITE);
  }
}

Fixed version (ground truth):
/** 
 * Allocate a stack
 * @param bytes    The number of bytes to allocate
 * @param immortal  Is the stack immortal and non-moving?
 * @return The stack
 */
@Inline @Interruptible public static byte[] newStack(int bytes,boolean immortal){
  if (!VM.runningVM) {
    return new byte[bytes];
  }
 else {
    RVMArray stackType=RVMArray.ByteArray;
    int headerSize=ObjectModel.computeArrayHeaderSize(stackType);
    int align=ObjectModel.getAlignment(stackType);
    int offset=ObjectModel.getOffsetForAlignment(stackType,false);
    int width=stackType.getLogElementSize();
    TIB stackTib=stackType.getTypeInformationBlock();
    return (byte[])allocateArray(bytes,width,headerSize,stackTib,(immortal ? Plan.ALLOC_IMMORTAL_STACK : Plan.ALLOC_STACK),align,offset,Plan.DEFAULT_SITE);
  }
}
Program: 149800
Project: 149800
Buggy source:
/** 
 * Allocate a CodeArray into a code space. Currently the interface is fairly primitive; just the number of instructions in the code array and a boolean to indicate hot or cold code.
 * @param numInstrs number of instructions
 * @param isHot is this a request for hot code space allocation?
 * @return The  array
 */
@Interruptible public static CodeArray allocateCode(int numInstrs,boolean isHot){
  RVMArray type=RVMType.CodeArrayType;
  int headerSize=ObjectModel.computeArrayHeaderSize(type);
  int align=ObjectModel.getAlignment(type);
  int offset=ObjectModel.getOffsetForAlignment(type);
  int width=type.getLogElementSize();
  TIB tib=type.getTypeInformationBlock();
  int allocator=isHot ? Plan.ALLOC_HOT_CODE : Plan.ALLOC_COLD_CODE;
  return (CodeArray)allocateArray(numInstrs,width,headerSize,tib,allocator,align,offset,Plan.DEFAULT_SITE);
}

Fixed version (ground truth):
/** 
 * Allocate a CodeArray into a code space. Currently the interface is fairly primitive; just the number of instructions in the code array and a boolean to indicate hot or cold code.
 * @param numInstrs number of instructions
 * @param isHot is this a request for hot code space allocation?
 * @return The  array
 */
@Interruptible public static CodeArray allocateCode(int numInstrs,boolean isHot){
  RVMArray type=RVMType.CodeArrayType;
  int headerSize=ObjectModel.computeArrayHeaderSize(type);
  int align=ObjectModel.getAlignment(type);
  int offset=ObjectModel.getOffsetForAlignment(type,false);
  int width=type.getLogElementSize();
  TIB tib=type.getTypeInformationBlock();
  int allocator=isHot ? Plan.ALLOC_HOT_CODE : Plan.ALLOC_COLD_CODE;
  return (CodeArray)allocateArray(numInstrs,width,headerSize,tib,allocator,align,offset,Plan.DEFAULT_SITE);
}
Program: 149801
Project: 149801
Buggy source:
/** 
 * Allocate a non moving double array
 * @param size The size of the array
 */
@Inline @Interruptible public static double[] newNonMovingDoubleArray(int size){
  if (!VM.runningVM) {
    return new double[size];
  }
  RVMArray arrayType=RVMArray.DoubleArray;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (double[])allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}

Fixed version (ground truth):
/** 
 * Allocate a non moving double array
 * @param size The size of the array
 */
@Inline @Interruptible public static double[] newNonMovingDoubleArray(int size){
  if (!VM.runningVM) {
    return new double[size];
  }
  RVMArray arrayType=RVMArray.DoubleArray;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType,false);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (double[])allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}
Program: 149802
Project: 149802
Buggy source:
/** 
 * Allocate a non moving word array
 * @param size The size of the array
 */
@Inline @Interruptible public static WordArray newNonMovingWordArray(int size){
  if (!VM.runningVM) {
    return WordArray.create(size);
  }
  RVMArray arrayType=RVMType.WordArrayType;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (WordArray)allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}

Fixed version (ground truth):
/** 
 * Allocate a non moving word array
 * @param size The size of the array
 */
@Inline @Interruptible public static WordArray newNonMovingWordArray(int size){
  if (!VM.runningVM) {
    return WordArray.create(size);
  }
  RVMArray arrayType=RVMType.WordArrayType;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType,false);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (WordArray)allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}
Program: 149803
Project: 149803
Buggy source:
/** 
 * Allocate a non moving int array
 * @param size The size of the array
 */
@Inline @Interruptible public static short[] newNonMovingShortArray(int size){
  if (!VM.runningVM) {
    return new short[size];
  }
  RVMArray arrayType=RVMArray.ShortArray;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (short[])allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}

Fixed version (ground truth):
/** 
 * Allocate a non moving int array
 * @param size The size of the array
 */
@Inline @Interruptible public static short[] newNonMovingShortArray(int size){
  if (!VM.runningVM) {
    return new short[size];
  }
  RVMArray arrayType=RVMArray.ShortArray;
  int headerSize=ObjectModel.computeArrayHeaderSize(arrayType);
  int align=ObjectModel.getAlignment(arrayType);
  int offset=ObjectModel.getOffsetForAlignment(arrayType,false);
  int width=arrayType.getLogElementSize();
  TIB arrayTib=arrayType.getTypeInformationBlock();
  return (short[])allocateArray(size,width,headerSize,arrayTib,Plan.ALLOC_NON_MOVING,align,offset,Plan.DEFAULT_SITE);
}
Program: 149804
Project: 149804
Buggy source:
/** 
 * Allocate and initialize space in the bootimage (at bootimage writing time) to be an uninitialized instance of the (array) type specified by array. NOTE: TIB is set by BootimageWriter2
 * @param bootImage the bootimage to put the object in
 * @param array RVMArray object of array being allocated.
 * @param numElements number of elements
 * @return Address of object in bootimage
 */
@Interruptible public static Address allocateCode(BootImageInterface bootImage,RVMArray array,int numElements){
  TIB tib=array.getTypeInformationBlock();
  int size=array.getInstanceSize(numElements);
  int align=getAlignment(array);
  int offset=getOffsetForAlignment(array);
  Address ptr=bootImage.allocateCodeStorage(size,align,offset);
  Address ref=JavaHeader.initializeArrayHeader(bootImage,ptr,tib,size,numElements,false,0);
  bootImage.setFullWord(ref.plus(getArrayLengthOffset()),numElements);
  MM_Interface.initializeHeader(bootImage,ref,tib,size,false);
  MiscHeader.initializeHeader(bootImage,ref,tib,size,false);
  return ref;
}

Fixed version (ground truth):
/** 
 * Allocate and initialize space in the bootimage (at bootimage writing time) to be an uninitialized instance of the (array) type specified by array. NOTE: TIB is set by BootimageWriter2
 * @param bootImage the bootimage to put the object in
 * @param array RVMArray object of array being allocated.
 * @param numElements number of elements
 * @return Address of object in bootimage
 */
@Interruptible public static Address allocateCode(BootImageInterface bootImage,RVMArray array,int numElements){
  TIB tib=array.getTypeInformationBlock();
  int size=array.getInstanceSize(numElements);
  int align=getAlignment(array);
  int offset=getOffsetForAlignment(array,false);
  Address ptr=bootImage.allocateCodeStorage(size,align,offset);
  Address ref=JavaHeader.initializeArrayHeader(bootImage,ptr,tib,size,numElements,false,0);
  bootImage.setFullWord(ref.plus(getArrayLengthOffset()),numElements);
  MM_Interface.initializeHeader(bootImage,ref,tib,size,false);
  MiscHeader.initializeHeader(bootImage,ref,tib,size,false);
  return ref;
}
Program: 149805
Project: 149805
Buggy source:
/** 
 * Allocate and initialize space in the bootimage (at bootimage writing time) to be an uninitialized instance of the (array) type specified by array. NOTE: TIB is set by BootimageWriter2
 * @param bootImage the bootimage to put the object in
 * @param array RVMArray object of array being allocated.
 * @param numElements number of elements
 * @param needsIdentityHash needs an identity hash value
 * @param identityHashValue the value for the identity hash
 * @return Address of object in bootimage (in bytes)
 */
@Interruptible public static Address allocateArray(BootImageInterface bootImage,RVMArray array,int numElements,boolean needsIdentityHash,int identityHashValue){
  TIB tib=array.getTypeInformationBlock();
  int size=array.getInstanceSize(numElements);
  if (needsIdentityHash) {
    if (JavaHeader.ADDRESS_BASED_HASHING) {
      size+=JavaHeader.HASHCODE_BYTES;
    }
 else {
      throw new Error("String_Node_Str");
    }
  }
  int align=getAlignment(array);
  int offset=getOffsetForAlignment(array);
  Address ptr=bootImage.allocateDataStorage(size,align,offset);
  Address ref=JavaHeader.initializeArrayHeader(bootImage,ptr,tib,size,numElements,needsIdentityHash,identityHashValue);
  bootImage.setFullWord(ref.plus(getArrayLengthOffset()),numElements);
  MM_Interface.initializeHeader(bootImage,ref,tib,size,false);
  MiscHeader.initializeHeader(bootImage,ref,tib,size,false);
  return ref;
}

Fixed version (ground truth):
/** 
 * Allocate and initialize space in the bootimage (at bootimage writing time) to be an uninitialized instance of the (array) type specified by array. NOTE: TIB is set by BootimageWriter2
 * @param bootImage the bootimage to put the object in
 * @param array RVMArray object of array being allocated.
 * @param numElements number of elements
 * @param needsIdentityHash needs an identity hash value
 * @param identityHashValue the value for the identity hash
 * @return Address of object in bootimage (in bytes)
 */
@Interruptible public static Address allocateArray(BootImageInterface bootImage,RVMArray array,int numElements,boolean needsIdentityHash,int identityHashValue){
  TIB tib=array.getTypeInformationBlock();
  int size=array.getInstanceSize(numElements);
  if (needsIdentityHash) {
    if (JavaHeader.ADDRESS_BASED_HASHING) {
      size+=JavaHeader.HASHCODE_BYTES;
    }
 else {
      throw new Error("String_Node_Str");
    }
  }
  int align=getAlignment(array);
  int offset=getOffsetForAlignment(array,needsIdentityHash);
  Address ptr=bootImage.allocateDataStorage(size,align,offset);
  Address ref=JavaHeader.initializeArrayHeader(bootImage,ptr,tib,size,numElements,needsIdentityHash,identityHashValue);
  bootImage.setFullWord(ref.plus(getArrayLengthOffset()),numElements);
  MM_Interface.initializeHeader(bootImage,ref,tib,size,false);
  MiscHeader.initializeHeader(bootImage,ref,tib,size,false);
  return ref;
}
Program: 149806
Project: 149806
Buggy source:
/** 
 * Allocate and initialize space in the bootimage (at bootimage writing time) to be an uninitialized instance of the (scalar) type specified by klass. NOTE: TIB is set by BootImageWriter2
 * @param bootImage the bootimage to put the object in
 * @param klass the RVMClass object of the instance to create.
 * @param needsIdentityHash needs an identity hash value
 * @param identityHashValue the value for the identity hash
 * @return the offset of object in bootimage (in bytes)
 */
@Interruptible public static Address allocateScalar(BootImageInterface bootImage,RVMClass klass,boolean needsIdentityHash,int identityHashValue){
  TIB tib=klass.getTypeInformationBlock();
  int size=klass.getInstanceSize();
  if (needsIdentityHash) {
    if (JavaHeader.ADDRESS_BASED_HASHING) {
      size+=JavaHeader.HASHCODE_BYTES;
    }
 else {
      throw new Error("String_Node_Str");
    }
  }
  int align=getAlignment(klass);
  int offset=getOffsetForAlignment(klass);
  Address ptr=bootImage.allocateDataStorage(size,align,offset);
  Address ref=JavaHeader.initializeScalarHeader(bootImage,ptr,tib,size,needsIdentityHash,identityHashValue);
  MM_Interface.initializeHeader(bootImage,ref,tib,size,true);
  MiscHeader.initializeHeader(bootImage,ref,tib,size,true);
  return ref;
}

Fixed version (ground truth):
/** 
 * Allocate and initialize space in the bootimage (at bootimage writing time) to be an uninitialized instance of the (scalar) type specified by klass. NOTE: TIB is set by BootImageWriter2
 * @param bootImage the bootimage to put the object in
 * @param klass the RVMClass object of the instance to create.
 * @param needsIdentityHash needs an identity hash value
 * @param identityHashValue the value for the identity hash
 * @return the offset of object in bootimage (in bytes)
 */
@Interruptible public static Address allocateScalar(BootImageInterface bootImage,RVMClass klass,boolean needsIdentityHash,int identityHashValue){
  TIB tib=klass.getTypeInformationBlock();
  int size=klass.getInstanceSize();
  if (needsIdentityHash) {
    if (JavaHeader.ADDRESS_BASED_HASHING) {
      size+=JavaHeader.HASHCODE_BYTES;
    }
 else {
      throw new Error("String_Node_Str");
    }
  }
  int align=getAlignment(klass);
  int offset=getOffsetForAlignment(klass,needsIdentityHash);
  Address ptr=bootImage.allocateDataStorage(size,align,offset);
  Address ref=JavaHeader.initializeScalarHeader(bootImage,ptr,tib,size,needsIdentityHash,identityHashValue);
  MM_Interface.initializeHeader(bootImage,ref,tib,size,true);
  MiscHeader.initializeHeader(bootImage,ref,tib,size,true);
  return ref;
}
Program: 149807
Project: 149807
Buggy source:
/** 
 * Allocate something like "new Foo()".
 * @param id id of type reference of class to create.
 * @return object with header installed and all fields set to zero/null(ready for initializer to be run on it) See also: bytecode 0xbb ("new")
 */
@Entrypoint static Object unresolvedNewScalar(int id,int site) throws NoClassDefFoundError, OutOfMemoryError {
  TypeReference tRef=TypeReference.getTypeRef(id);
  RVMType t=tRef.peekType();
  if (t == null) {
    t=tRef.resolve();
  }
  RVMClass cls=t.asClass();
  if (!cls.isInitialized()) {
    initializeClassForDynamicLink(cls);
  }
  int allocator=MM_Interface.pickAllocator(cls);
  int align=ObjectModel.getAlignment(cls);
  int offset=ObjectModel.getOffsetForAlignment(cls);
  return resolvedNewScalar(cls.getInstanceSize(),cls.getTypeInformationBlock(),cls.hasFinalizer(),allocator,align,offset,site);
}

Fixed version (ground truth):
/** 
 * Allocate something like "new Foo()".
 * @param id id of type reference of class to create.
 * @return object with header installed and all fields set to zero/null(ready for initializer to be run on it) See also: bytecode 0xbb ("new")
 */
@Entrypoint static Object unresolvedNewScalar(int id,int site) throws NoClassDefFoundError, OutOfMemoryError {
  TypeReference tRef=TypeReference.getTypeRef(id);
  RVMType t=tRef.peekType();
  if (t == null) {
    t=tRef.resolve();
  }
  RVMClass cls=t.asClass();
  if (!cls.isInitialized()) {
    initializeClassForDynamicLink(cls);
  }
  int allocator=MM_Interface.pickAllocator(cls);
  int align=ObjectModel.getAlignment(cls);
  int offset=ObjectModel.getOffsetForAlignment(cls,false);
  return resolvedNewScalar(cls.getInstanceSize(),cls.getTypeInformationBlock(),cls.hasFinalizer(),allocator,align,offset,site);
}
Program: 149809
Project: 149809
Buggy source:
private int bucketIndex(K key,int divisor){
  if (key == null) {
    return 0;
  }
 else {
    return (key.hashCode() & 0x7fffffff) % divisor;
  }
}

Fixed version (ground truth):
private int bucketIndex(K key,int divisor){
  if (key == null) {
    return 0;
  }
 else {
    return (hashTheKey(key) & 0x7fffffff) % divisor;
  }
}
Program: 149811
Project: 149811
Buggy source:
private static DefUseEffect intDiv(Instruction s){
  if (CF_INT) {
    Operand op1=GuardedBinary.getVal1(s);
    Operand op2=GuardedBinary.getVal2(s);
    if (op1.similar(op2)) {
      Move.mutate(s,INT_MOVE,GuardedBinary.getClearResult(s),IC(1));
      return DefUseEffect.MOVE_FOLDED;
    }
    if (op2.isIntConstant()) {
      int val2=op2.asIntConstant().value;
      if (val2 == 0) {
        return DefUseEffect.UNCHANGED;
      }
      if (op1.isIntConstant()) {
        int val1=op1.asIntConstant().value;
        Move.mutate(s,INT_MOVE,GuardedBinary.getClearResult(s),IC(val1 / val2));
        return DefUseEffect.MOVE_FOLDED;
      }
 else {
        if (val2 == 1) {
          Move.mutate(s,INT_MOVE,GuardedBinary.getClearResult(s),GuardedBinary.getClearVal1(s));
          return DefUseEffect.MOVE_REDUCED;
        }
        int power=PowerOf2(val2);
        if (power != -1) {
          Binary.mutate(s,INT_SHR,GuardedBinary.getClearResult(s),GuardedBinary.getClearVal1(s),IC(power));
          return DefUseEffect.REDUCED;
        }
      }
    }
  }
  return DefUseEffect.UNCHANGED;
}

Fixed version (ground truth):
private static DefUseEffect intDiv(AbstractRegisterPool regpool,Instruction s){
  if (CF_INT) {
    Operand op1=GuardedBinary.getVal1(s);
    Operand op2=GuardedBinary.getVal2(s);
    if (op1.similar(op2)) {
      Move.mutate(s,INT_MOVE,GuardedBinary.getClearResult(s),IC(1));
      return DefUseEffect.MOVE_FOLDED;
    }
    if (op2.isIntConstant()) {
      int val2=op2.asIntConstant().value;
      if (val2 == 0) {
        return DefUseEffect.UNCHANGED;
      }
      if (op1.isIntConstant()) {
        int val1=op1.asIntConstant().value;
        Move.mutate(s,INT_MOVE,GuardedBinary.getClearResult(s),IC(val1 / val2));
        return DefUseEffect.MOVE_FOLDED;
      }
 else {
        if (val2 == 1) {
          Move.mutate(s,INT_MOVE,GuardedBinary.getClearResult(s),GuardedBinary.getClearVal1(s));
          return DefUseEffect.MOVE_REDUCED;
        }
        if (s.getPrev() != null) {
          int power=PowerOf2(val2);
          if (power != -1) {
            int x=(1 << power) - 1;
            RegisterOperand tempInt1=regpool.makeTempInt();
            RegisterOperand tempInt2=regpool.makeTempInt();
            RegisterOperand tempInt3=regpool.makeTempInt();
            Instruction sign=Binary.create(INT_SHR,tempInt1,GuardedBinary.getVal1(s).copy(),IC(31));
            sign.copyPosition(s);
            s.insertBefore(sign);
            Instruction masked=Binary.create(INT_AND,tempInt2,tempInt1.copyRO(),IC((1 << power) - 1));
            masked.copyPosition(s);
            s.insertBefore(masked);
            Instruction adjusted=Binary.create(INT_ADD,tempInt3,tempInt2.copyRO(),GuardedBinary.getClearVal1(s));
            adjusted.copyPosition(s);
            s.insertBefore(adjusted);
            Binary.mutate(s,INT_SHR,GuardedBinary.getClearResult(s),tempInt3.copyRO(),IC(power));
            return DefUseEffect.REDUCED;
          }
        }
      }
    }
  }
  return DefUseEffect.UNCHANGED;
}