nus-yam/ex-repair huggingface dataset:
Program: 149693
Project: 149693
Buggy source:
/** 
 * Perform element-by-element arraycopy for array of objects without performing checkcast.  Used when bulk copy is not possible, but checkcast is still not necessary.  If barriers are required they must be explicitly invoked.
 * @param src The source array
 * @param srcIdx The starting source index
 * @param dst The destination array
 * @param dstIdx The starting destination index
 * @param len The number of array elements to be copied
 */
private static void arraycopyPiecemealNoCheckcast(Object[] src,Object[] dst,int len,Offset srcOffset,Offset dstOffset,int bytes){
  int increment;
  if (srcOffset.sGT(dstOffset)) {
    increment=BYTES_IN_ADDRESS;
  }
 else {
    srcOffset=srcOffset.plus(bytes - BYTES_IN_ADDRESS);
    dstOffset=dstOffset.plus(bytes - BYTES_IN_ADDRESS);
    increment=-BYTES_IN_ADDRESS;
  }
  while (len-- != 0) {
    Object value;
    if (NEEDS_OBJECT_ALOAD_BARRIER) {
      value=Barriers.objectArrayRead(src,srcOffset.toInt() >> LOG_BYTES_IN_ADDRESS);
    }
 else {
      value=Magic.getObjectAtOffset(src,srcOffset);
    }
    if (NEEDS_OBJECT_ASTORE_BARRIER) {
      Barriers.objectArrayWrite(dst,dstOffset.toInt() >> LOG_BYTES_IN_ADDRESS,value);
    }
 else {
      Magic.setObjectAtOffset(dst,dstOffset,value);
    }
    srcOffset=srcOffset.plus(increment);
    dstOffset=dstOffset.plus(increment);
  }
}

Fixed version (ground truth):
/** 
 * Perform element-by-element arraycopy for array of objects without performing checkcast.  Used when bulk copy is not possible, but checkcast is still not necessary.  If barriers are required they must be explicitly invoked.
 * @param src The source array
 * @param dst The destination array
 * @param len The number of array elements to be copied
 * @param srcOffset The starting offset in the source array
 * @param dstOffset The starting offset in the destination array.
 * @param bytes the number of bytes to copy
 */
private static void arraycopyPiecemealNoCheckcast(Object[] src,Object[] dst,int len,Offset srcOffset,Offset dstOffset,int bytes){
  int increment;
  if (srcOffset.sGT(dstOffset)) {
    increment=BYTES_IN_ADDRESS;
  }
 else {
    srcOffset=srcOffset.plus(bytes - BYTES_IN_ADDRESS);
    dstOffset=dstOffset.plus(bytes - BYTES_IN_ADDRESS);
    increment=-BYTES_IN_ADDRESS;
  }
  while (len-- != 0) {
    Object value;
    if (NEEDS_OBJECT_ALOAD_BARRIER) {
      value=Barriers.objectArrayRead(src,srcOffset.toInt() >> LOG_BYTES_IN_ADDRESS);
    }
 else {
      value=Magic.getObjectAtOffset(src,srcOffset);
    }
    if (NEEDS_OBJECT_ASTORE_BARRIER) {
      Barriers.objectArrayWrite(dst,dstOffset.toInt() >> LOG_BYTES_IN_ADDRESS,value);
    }
 else {
      Magic.setObjectAtOffset(dst,dstOffset,value);
    }
    srcOffset=srcOffset.plus(increment);
    dstOffset=dstOffset.plus(increment);
  }
}
Program: 149694
Project: 149694
Buggy source:
/** 
 * Number of padding bytes required.
 * @param alignCode Prospective encoded value.
 * @return
 */
public static int padding(int alignCode){
  if (alignCode == ALIGN_CODE_NONE)   return 0;
  return (MAX_ALIGN_WORDS << FIELD_SHIFT);
}

Fixed version (ground truth):
/** 
 * Number of padding bytes required.
 * @param alignCode Prospective encoded value.
 * @return the number of padding bytes required
 */
public static int padding(int alignCode){
  if (alignCode == ALIGN_CODE_NONE)   return 0;
  return (MAX_ALIGN_WORDS << FIELD_SHIFT);
}
Program: 149695
Project: 149695
Buggy source:
/** 
 * Extract the encoded value from an object's TIB pointer
 * @param tib
 * @return
 */
@Uninterruptible @Inline public static int getTibCode(ObjectReference object){
  int tibCode=extractTibCode(Magic.objectAsAddress(ObjectModel.getTIB(object)));
  return tibCode;
}

Fixed version (ground truth):
/** 
 * Extract the encoded value from an object's TIB pointer
 * @param object
 * @return the encoded value from a TIB pointer
 */
@Uninterruptible @Inline public static int getTibCode(ObjectReference object){
  int tibCode=extractTibCode(Magic.objectAsAddress(ObjectModel.getTIB(object)));
  return tibCode;
}
Program: 149696
Project: 149696
Buggy source:
/** 
 * Extract the encoded value from a TIB pointer, represented as a raw address.
 * @param tib
 * @return
 */
@Uninterruptible @Inline public static int extractTibCode(Address address){
  return (address.toInt() & TIB_ALIGN_MASK) >> FIELD_SHIFT;
}

Fixed version (ground truth):
/** 
 * Extract the encoded value from a TIB pointer, represented as a raw address.
 * @param address
 * @return the encoded value from a TIB pointer
 */
@Uninterruptible @Inline public static int extractTibCode(Address address){
  return (address.toInt() & TIB_ALIGN_MASK) >> FIELD_SHIFT;
}
Program: 149697
Project: 149697
Buggy source:
/** 
 * Adjust a region address so that the object pointer of an object that starts at this address will be aligned so as to encode the specified value.
 * @param alignCode Value to encode
 * @param region The initial region
 * @return
 */
public static Address adjustRegion(int alignCode,Address region){
  assertSanity(alignCode);
  if (alignCode == ALIGN_CODE_NONE)   return region;
  final Address limit=region.plus(padding(alignCode));
  if (VERBOSE) {
    VM.sysWrite("String_Node_Str",region,"String_Node_Str",getTibCodeForRegion(region));
    VM.sysWriteln("String_Node_Str",alignCode);
  }
  while (getTibCodeForRegion(region) != alignCode) {
    if (VM.runningVM) {
      region.store(Word.fromIntZeroExtend(ObjectModel.ALIGNMENT_VALUE));
    }
    region=region.plus(ALIGNMENT_INCREMENT);
    if (region.GT(limit)) {
      VM.sysFail("String_Node_Str");
    }
  }
  if (VERBOSE) {
    VM.sysWrite("String_Node_Str",region,"String_Node_Str",getTibCodeForRegion(region));
    VM.sysWriteln("String_Node_Str",alignCode);
  }
  return region;
}

Fixed version (ground truth):
/** 
 * Adjust a region address so that the object pointer of an object that starts at this address will be aligned so as to encode the specified value.
 * @param alignCode Value to encode
 * @param region The initial region
 * @return the aligned address
 */
public static Address adjustRegion(int alignCode,Address region){
  assertSanity(alignCode);
  if (alignCode == ALIGN_CODE_NONE)   return region;
  final Address limit=region.plus(padding(alignCode));
  if (VERBOSE) {
    VM.sysWrite("String_Node_Str",region,"String_Node_Str",getTibCodeForRegion(region));
    VM.sysWriteln("String_Node_Str",alignCode);
  }
  while (getTibCodeForRegion(region) != alignCode) {
    if (VM.runningVM) {
      region.store(Word.fromIntZeroExtend(ObjectModel.ALIGNMENT_VALUE));
    }
    region=region.plus(ALIGNMENT_INCREMENT);
    if (region.GT(limit)) {
      VM.sysFail("String_Node_Str");
    }
  }
  if (VERBOSE) {
    VM.sysWrite("String_Node_Str",region,"String_Node_Str",getTibCodeForRegion(region));
    VM.sysWriteln("String_Node_Str",alignCode);
  }
  return region;
}
Program: 149698
Project: 149698
Buggy source:
/** 
 * Barrier for a bulk copy of floats (i.e. in an array copy).
 * @param src The source array
 * @param srcIdx The starting source index
 * @param dst The destination array
 * @param dstIdx The starting source index
 * @param len The number of array elements to be copied
 */
@Inline public static void floatBulkCopy(float[] src,Offset srcOffset,float[] dst,Offset dstOffset,int bytes){
  if (VM.VerifyAssertions)   VM._assert(FLOAT_BULK_COPY_SUPPORTED);
  if (!Selected.Mutator.get().floatBulkCopy(ObjectReference.fromObject(src),srcOffset,ObjectReference.fromObject(dst),dstOffset,bytes)) {
    Memory.aligned32Copy(Magic.objectAsAddress(dst).plus(dstOffset),Magic.objectAsAddress(src).plus(srcOffset),bytes);
  }
}

Fixed version (ground truth):
/** 
 * Barrier for a bulk copy of floats (i.e. in an array copy).
 * @param src The source array
 * @param srcOffset The starting source offset
 * @param dst The destination array
 * @param dstOffset The starting destination offset
 * @param bytes The number of bytes to be copied
 */
@Inline public static void floatBulkCopy(float[] src,Offset srcOffset,float[] dst,Offset dstOffset,int bytes){
  if (VM.VerifyAssertions)   VM._assert(FLOAT_BULK_COPY_SUPPORTED);
  if (!Selected.Mutator.get().floatBulkCopy(ObjectReference.fromObject(src),srcOffset,ObjectReference.fromObject(dst),dstOffset,bytes)) {
    Memory.aligned32Copy(Magic.objectAsAddress(dst).plus(dstOffset),Magic.objectAsAddress(src).plus(srcOffset),bytes);
  }
}
Program: 149699
Project: 149699
Buggy source:
/** 
 * Barrier for a bulk copy of doubles (i.e. in an array copy).
 * @param src The source array
 * @param srcIdx The starting source index
 * @param dst The destination array
 * @param dstIdx The starting source index
 * @param len The number of array elements to be copied
 */
@Inline public static void doubleBulkCopy(double[] src,Offset srcOffset,double[] dst,Offset dstOffset,int bytes){
  if (VM.VerifyAssertions)   VM._assert(DOUBLE_BULK_COPY_SUPPORTED);
  if (!Selected.Mutator.get().doubleBulkCopy(ObjectReference.fromObject(src),srcOffset,ObjectReference.fromObject(dst),dstOffset,bytes)) {
    Memory.aligned64Copy(Magic.objectAsAddress(dst).plus(dstOffset),Magic.objectAsAddress(src).plus(srcOffset),bytes);
  }
}

Fixed version (ground truth):
/** 
 * Barrier for a bulk copy of doubles (i.e. in an array copy).
 * @param src The source array
 * @param srcOffset The starting source offset
 * @param dst The destination array
 * @param dstOffset The starting destination offset
 * @param bytes The number of bytes to be copied
 */
@Inline public static void doubleBulkCopy(double[] src,Offset srcOffset,double[] dst,Offset dstOffset,int bytes){
  if (VM.VerifyAssertions)   VM._assert(DOUBLE_BULK_COPY_SUPPORTED);
  if (!Selected.Mutator.get().doubleBulkCopy(ObjectReference.fromObject(src),srcOffset,ObjectReference.fromObject(dst),dstOffset,bytes)) {
    Memory.aligned64Copy(Magic.objectAsAddress(dst).plus(dstOffset),Magic.objectAsAddress(src).plus(srcOffset),bytes);
  }
}
Program: 149701
Project: 149701
Buggy source:
/** 
 * Atomically attempt to set the mark bit of an object.  Return true if successful, false if the mark bit was already set.
 * @param object The object whose mark bit is to be written
 * @param value The value to which the mark bits will be set
 */
@Inline private boolean testAndMark(ObjectReference object){
  byte oldValue, markBits;
  oldValue=VM.objectModel.readAvailableByte(object);
  markBits=(byte)(oldValue & MARK_COUNT_MASK);
  if (markBits == markState)   return false;
  VM.objectModel.writeAvailableByte(object,(byte)((oldValue & ~MARK_COUNT_MASK) | markState));
  return true;
}

Fixed version (ground truth):
/** 
 * Atomically attempt to set the mark bit of an object.  Return true if successful, false if the mark bit was already set.
 * @param object The object whose mark bit is to be written
 * @param value The value to which the mark bits will be set
 */
@Inline private boolean testAndMark(ObjectReference object){
  byte oldValue, markBits, newValue;
  oldValue=VM.objectModel.readAvailableByte(object);
  markBits=(byte)(oldValue & MARK_COUNT_MASK);
  if (markBits == markState)   return false;
  newValue=(byte)((oldValue & ~MARK_COUNT_MASK) | markState);
  if (HeaderByte.NEEDS_UNLOGGED_BIT)   newValue|=HeaderByte.UNLOGGED_BIT;
  VM.objectModel.writeAvailableByte(object,newValue);
  return true;
}
Program: 149702
Project: 149702
Buggy source:
/** 
 * Perform any required initialization of the GC portion of the header.
 * @param object the object ref to the storage to be initialized
 * @param alloc is this initialization occuring due to (initial) allocation(true) or due to copying (false)?
 */
@Inline public void initializeHeader(ObjectReference object,boolean alloc){
  if (HEADER_MARK_BITS) {
    byte oldValue=VM.objectModel.readAvailableByte(object);
    byte newValue=(byte)((oldValue & ~MARK_COUNT_MASK) | (alloc && !isAllocAsMarked ? allocState : markState));
    if (HeaderByte.NEEDS_UNLOGGED_BIT)     newValue|=HeaderByte.UNLOGGED_BIT;
    VM.objectModel.writeAvailableByte(object,newValue);
  }
 else   if (HeaderByte.NEEDS_UNLOGGED_BIT)   HeaderByte.markAsUnlogged(object);
}

Fixed version (ground truth):
/** 
 * Perform any required initialization of the GC portion of the header.
 * @param object the object ref to the storage to be initialized
 * @param alloc is this initialization occuring due to (initial) allocation(true) or due to copying (false)?
 */
@Inline public void initializeHeader(ObjectReference object,boolean alloc){
  if (HEADER_MARK_BITS) {
    byte oldValue=VM.objectModel.readAvailableByte(object);
    byte newValue=(byte)((oldValue & ~MARK_COUNT_MASK) | (alloc && !isAllocAsMarked ? allocState : markState));
    VM.objectModel.writeAvailableByte(object,newValue);
  }
 else   if (HeaderByte.NEEDS_UNLOGGED_BIT)   HeaderByte.markAsUnlogged(object);
}
Program: 149703
Project: 149703
Buggy source:
/** 
 * Perform a (global) collection phase.
 * @param phaseId Collection phase to execute.
 */
@Inline @Override public final void collectionPhase(short phaseId){
  if (phaseId == SET_COLLECTION_KIND) {
    super.collectionPhase(phaseId);
    collectWholeHeap=requiresFullHeapCollection();
    if (Stats.gatheringStats() && collectWholeHeap)     fullHeap.set();
    super.collectionPhase(phaseId);
    return;
  }
  if (!collectWholeHeap && phaseId == PREPARE) {
    immixTrace.prepare();
    immixSpace.prepare(false);
    return;
  }
  if (phaseId == RELEASE) {
    if (collectWholeHeap) {
      super.collectionPhase(RELEASE);
    }
 else {
      immixTrace.release();
      lastGCWasDefrag=immixSpace.release(false);
    }
    modPool.reset();
    lastCommittedImmixPages=immixSpace.committedPages();
    nextGCWholeHeap=(getPagesAvail() < Options.nurserySize.getMinNursery());
    return;
  }
  super.collectionPhase(phaseId);
}

Fixed version (ground truth):
/** 
 * Perform a (global) collection phase.
 * @param phaseId Collection phase to execute.
 */
@Inline @Override public final void collectionPhase(short phaseId){
  if (phaseId == SET_COLLECTION_KIND) {
    super.collectionPhase(phaseId);
    collectWholeHeap=requiresFullHeapCollection();
    if (Stats.gatheringStats() && collectWholeHeap)     fullHeap.set();
    return;
  }
  if (!collectWholeHeap && phaseId == PREPARE) {
    immixTrace.prepare();
    immixSpace.prepare(false);
    return;
  }
  if (phaseId == RELEASE) {
    if (collectWholeHeap) {
      super.collectionPhase(RELEASE);
    }
 else {
      immixTrace.release();
      lastGCWasDefrag=immixSpace.release(false);
    }
    modPool.reset();
    lastCommittedImmixPages=immixSpace.committedPages();
    nextGCWholeHeap=(getPagesAvail() < Options.nurserySize.getMinNursery());
    return;
  }
  super.collectionPhase(phaseId);
}
Program: 149704
Project: 149704
Buggy source:
/** 
 * The phase has changed (from GC to mutator or mutator to GC). Take action with respect to the last phase if necessary. <b>Do nothing in this case.</b>
 * @param oldPhase The last phase
 */
void phaseChange(int oldPhase){
  if (running) {
    count[oldPhase]=totalCount;
    totalCount=0;
  }
}

Fixed version (ground truth):
/** 
 * The phase has changed (from GC to mutator or mutator to GC). Take action with respect to the last phase if necessary. <b>Do nothing in this case.</b>
 * @param oldPhase The last phase
 */
void phaseChange(int oldPhase){
  if (running) {
    count[oldPhase]=currentCount;
    currentCount=0;
  }
}
Program: 149705
Project: 149705
Buggy source:
/** 
 * Stop this counter
 */
protected void stop(){
  if (!Stats.gatheringStats)   return;
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(running);
  running=false;
}

Fixed version (ground truth):
/** 
 * Stop this counter
 */
protected void stop(){
  if (!Stats.gatheringStats)   return;
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(running);
  count[Stats.phase]=currentCount;
  currentCount=0;
  running=false;
}
Program: 149706
Project: 149706
Buggy source:
/** 
 * Increment the event counter by <code>value</code>
 * @param value The amount by which the counter should be incremented.
 */
public void inc(int value){
  if (running)   totalCount+=value;
}

Fixed version (ground truth):
/** 
 * Increment the event counter by <code>value</code>
 * @param value The amount by which the counter should be incremented.
 */
public void inc(int value){
  if (running)   currentCount+=value;
}
Program: 149707
Project: 149707
Buggy source:
/** 
 * Print the current value for this counter (mid-phase)
 */
public final void printCurrent(){
  printValue(totalCount);
}

Fixed version (ground truth):
/** 
 * Print the current value for this counter (mid-phase)
 */
public final void printCurrent(){
  printValue(currentCount);
}
Program: 149708
Project: 149708
Buggy source:
/** 
 * Scan static variables (JTOC) for object references.  Executed by all GC threads in parallel, with each doing a portion of the JTOC.
 */
@Inline @Uninterruptible public static void scanStatics(TraceLocal trace){
  final Address slots=Magic.getJTOC();
  final CollectorContext cc=RVMThread.getCurrentThread().getCollectorContext();
  final int numberOfCollectors=cc.parallelWorkerCount();
  final int numberOfReferences=Statics.getNumberOfReferenceSlots();
  final int chunkSize=(numberOfReferences / numberOfCollectors) & chunkSizeMask;
  final int threadOrdinal=cc.parallelWorkerOrdinal();
  final int start=(threadOrdinal == 0) ? refSlotSize : threadOrdinal * chunkSize;
  final int end=(threadOrdinal + 1 == numberOfCollectors) ? numberOfReferences : numberOfCollectors * chunkSize;
  for (int slot=start; slot < end; slot+=refSlotSize) {
    Offset slotOffset=Offset.fromIntSignExtend(slot << LOG_BYTES_IN_INT);
    if (ScanThread.VALIDATE_REFS)     checkReference(slots.plus(slotOffset),slot);
    trace.processRootEdge(slots.plus(slotOffset),true);
  }
}

Fixed version (ground truth):
/** 
 * Scan static variables (JTOC) for object references.  Executed by all GC threads in parallel, with each doing a portion of the JTOC.
 */
@Inline @Uninterruptible public static void scanStatics(TraceLocal trace){
  final Address slots=Magic.getJTOC();
  final CollectorContext cc=RVMThread.getCurrentThread().getCollectorContext();
  final int numberOfCollectors=cc.parallelWorkerCount();
  final int numberOfReferences=Statics.getNumberOfReferenceSlots();
  final int chunkSize=(numberOfReferences / numberOfCollectors) & chunkSizeMask;
  final int threadOrdinal=cc.parallelWorkerOrdinal();
  final int start=(threadOrdinal == 0) ? refSlotSize : threadOrdinal * chunkSize;
  final int end=(threadOrdinal + 1 == numberOfCollectors) ? numberOfReferences : (threadOrdinal + 1) * chunkSize;
  for (int slot=start; slot < end; slot+=refSlotSize) {
    Offset slotOffset=Offset.fromIntSignExtend(slot << LOG_BYTES_IN_INT);
    if (ScanThread.VALIDATE_REFS)     checkReference(slots.plus(slotOffset),slot);
    trace.processRootEdge(slots.plus(slotOffset),true);
  }
}
Program: 149709
Project: 149709
Buggy source:
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the Address field
 * @param expected The old Address to be swapped out
 * @param newValue the new Address
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Override public boolean addressTryCompareAndSwap(ObjectReference objref,Address expected,Address newValue,Word offset,Word unused,int mode){
  Address oldValue;
  do {
    oldValue=Magic.prepareAddress(objref,offset.toOffset());
    if (oldValue != expected)     return false;
  }
 while (!Magic.attemptAddress(objref,offset.toOffset(),oldValue,newValue));
  return true;
}

Fixed version (ground truth):
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the Address field
 * @param expected The old Address to be swapped out
 * @param newValue the new Address
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Override public boolean addressTryCompareAndSwap(ObjectReference objref,Address expected,Address newValue,Word offset,Word unused,int mode){
  if (org.jikesrvm.VM.BuildForIA32) {
    return Magic.attemptAddress(objref.toObject(),offset.toOffset(),expected,newValue);
  }
 else {
    Address oldValue;
    do {
      oldValue=Magic.prepareAddress(objref,offset.toOffset());
      if (oldValue != expected)       return false;
    }
 while (!Magic.attemptAddress(objref,offset.toOffset(),oldValue,newValue));
    return true;
  }
}
Program: 149710
Project: 149710
Buggy source:
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the int field
 * @param expected The old int to be swapped out
 * @param newValue the new int
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Override public boolean intTryCompareAndSwap(ObjectReference objref,int expected,int newValue,Word offset,Word unused,int mode){
  int oldValue;
  do {
    oldValue=Magic.prepareInt(objref,offset.toOffset());
    if (oldValue != expected)     return false;
  }
 while (!Magic.attemptInt(objref,offset.toOffset(),oldValue,newValue));
  return true;
}

Fixed version (ground truth):
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the int field
 * @param expected The old int to be swapped out
 * @param newValue the new int
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Override public boolean intTryCompareAndSwap(ObjectReference objref,int expected,int newValue,Word offset,Word unused,int mode){
  if (org.jikesrvm.VM.BuildForIA32) {
    return Magic.attemptInt(objref.toObject(),offset.toOffset(),expected,newValue);
  }
 else {
    int oldValue;
    do {
      oldValue=Magic.prepareInt(objref,offset.toOffset());
      if (oldValue != expected)       return false;
    }
 while (!Magic.attemptInt(objref,offset.toOffset(),oldValue,newValue));
    return true;
  }
}
Program: 149711
Project: 149711
Buggy source:
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the reference field
 * @param old The old reference to be swapped out
 * @param target The value that the slot will be updated to
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Inline @Override public final boolean objectReferenceTryCompareAndSwap(ObjectReference objref,ObjectReference old,ObjectReference target,Word offset,Word unused,int mode){
  Object oldValue;
  do {
    oldValue=Magic.prepareObject(objref,offset.toOffset());
    if (oldValue != old)     return false;
  }
 while (!Magic.attemptObject(objref,offset.toOffset(),oldValue,target));
  return true;
}

Fixed version (ground truth):
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the reference field
 * @param old The old reference to be swapped out
 * @param target The value that the slot will be updated to
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Inline @Override public final boolean objectReferenceTryCompareAndSwap(ObjectReference objref,ObjectReference old,ObjectReference target,Word offset,Word unused,int mode){
  if (org.jikesrvm.VM.BuildForIA32) {
    return Magic.attemptObject(objref.toObject(),offset.toOffset(),old.toObject(),target.toObject());
  }
 else {
    Object oldValue;
    do {
      oldValue=Magic.prepareObject(objref,offset.toOffset());
      if (oldValue != old)       return false;
    }
 while (!Magic.attemptObject(objref,offset.toOffset(),oldValue,target));
    return true;
  }
}
Program: 149712
Project: 149712
Buggy source:
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param ref The object that has the Word field
 * @param old The old Word to be swapped out
 * @param target The value that the slot will be updated to
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Inline @Override public final boolean wordTryCompareAndSwap(ObjectReference ref,Word old,Word target,Word offset,Word unused,int mode){
  do {
    Word currentValue=Magic.prepareWord(ref,offset.toOffset());
    if (currentValue != old)     return false;
  }
 while (!Magic.attemptWord(ref,offset.toOffset(),old,target));
  return true;
}

Fixed version (ground truth):
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param ref The object that has the Word field
 * @param old The old Word to be swapped out
 * @param target The value that the slot will be updated to
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Inline @Override public final boolean wordTryCompareAndSwap(ObjectReference ref,Word old,Word target,Word offset,Word unused,int mode){
  if (org.jikesrvm.VM.BuildForIA32) {
    return Magic.attemptWord(ref.toObject(),offset.toOffset(),old,target);
  }
 else {
    do {
      Word currentValue=Magic.prepareWord(ref,offset.toOffset());
      if (currentValue != old)       return false;
    }
 while (!Magic.attemptWord(ref,offset.toOffset(),old,target));
    return true;
  }
}
Program: 149713
Project: 149713
Buggy source:
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the long field
 * @param expected The old long to be swapped out
 * @param newValue the new long
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Override public boolean longTryCompareAndSwap(ObjectReference objref,long expected,long newValue,Word offset,Word unused,int mode){
  long oldValue;
  do {
    oldValue=Magic.prepareLong(objref,offset.toOffset());
    if (oldValue != expected)     return false;
  }
 while (!Magic.attemptLong(objref,offset.toOffset(),oldValue,newValue));
  return true;
}

Fixed version (ground truth):
/** 
 * Attempt an atomic compare and exchange in a write barrier sequence.
 * @param objref The object that has the long field
 * @param expected The old long to be swapped out
 * @param newValue the new long
 * @param offset The offset from the ref
 * @param unused Unused
 * @param mode The context in which the write is occurring
 * @return True if the compare and swap was successful
 */
@Override public boolean longTryCompareAndSwap(ObjectReference objref,long expected,long newValue,Word offset,Word unused,int mode){
  if (org.jikesrvm.VM.BuildForIA32) {
    return Magic.attemptLong(objref.toObject(),offset.toOffset(),expected,newValue);
  }
 else {
    long oldValue;
    do {
      oldValue=Magic.prepareLong(objref,offset.toOffset());
      if (oldValue != expected)       return false;
    }
 while (!Magic.attemptLong(objref,offset.toOffset(),oldValue,newValue));
    return true;
  }
}
Program: 149714
Project: 149714
Buggy source:
public void putIntVolatile(Object obj,long offset,int value){
  Magic.writeFloor();
  Offset off=longToOffset(offset);
  if (NEEDS_INT_PUTFIELD_BARRIER) {
    intFieldWrite(obj,value,off,0);
  }
 else {
    Magic.setIntAtOffset(obj,off,value);
  }
}

Fixed version (ground truth):
public void putIntVolatile(Object obj,long offset,int value){
  Magic.writeFloor();
  Offset off=longToOffset(offset);
  if (NEEDS_INT_PUTFIELD_BARRIER) {
    intFieldWrite(obj,value,off,0);
  }
 else {
    Magic.setIntAtOffset(obj,off,value);
  }
  Magic.fence();
}
Program: 149715
Project: 149715
Buggy source:
public void putLongVolatile(Object obj,long offset,long value){
  Magic.writeFloor();
  Offset off=longToOffset(offset);
  if (NEEDS_LONG_PUTFIELD_BARRIER) {
    longFieldWrite(obj,value,off,0);
  }
 else {
    Magic.setLongAtOffset(obj,off,value);
  }
}

Fixed version (ground truth):
public void putLongVolatile(Object obj,long offset,long value){
  Magic.writeFloor();
  Offset off=longToOffset(offset);
  if (NEEDS_LONG_PUTFIELD_BARRIER) {
    longFieldWrite(obj,value,off,0);
  }
 else {
    Magic.setLongAtOffset(obj,off,value);
  }
  Magic.fence();
}
Program: 149716
Project: 149716
Buggy source:
public void putObjectVolatile(Object obj,long offset,Object value){
  Offset off=longToOffset(offset);
  Magic.writeFloor();
  if (NEEDS_OBJECT_PUTFIELD_BARRIER) {
    objectFieldWrite(obj,value,off,0);
  }
 else {
    Magic.setObjectAtOffset(obj,off,value);
  }
}

Fixed version (ground truth):
public void putObjectVolatile(Object obj,long offset,Object value){
  Offset off=longToOffset(offset);
  Magic.writeFloor();
  if (NEEDS_OBJECT_PUTFIELD_BARRIER) {
    objectFieldWrite(obj,value,off,0);
  }
 else {
    Magic.setObjectAtOffset(obj,off,value);
  }
  Magic.fence();
}
Program: 149718
Project: 149718
Buggy source:
protected void zeroLiveBits(){
  Extent bytes=Extent.fromIntSignExtend(EmbeddedMetaData.BYTES_IN_REGION >> LOG_LIVE_COVERAGE);
  if (contiguous) {
    Address end=((FreeListPageResource)pr).getHighWater();
    Address cursor=start;
    while (cursor.LT(end)) {
      Address metadata=EmbeddedMetaData.getMetaDataBase(cursor).plus(META_DATA_OFFSET);
      VM.memory.zero(metadata,bytes);
      cursor=cursor.plus(EmbeddedMetaData.BYTES_IN_REGION);
    }
  }
 else {
    for (Address cursor=lastDiscontiguousRegion; !cursor.isZero(); cursor=Map.getNextContiguousRegion(cursor)) {
      Address metadata=EmbeddedMetaData.getMetaDataBase(cursor).plus(META_DATA_OFFSET);
      VM.memory.zero(metadata,bytes);
    }
  }
}

Fixed version (ground truth):
protected void zeroLiveBits(){
  Extent bytes=Extent.fromIntSignExtend(EmbeddedMetaData.BYTES_IN_REGION >> LOG_LIVE_COVERAGE);
  if (contiguous) {
    Address end=((FreeListPageResource)pr).getHighWater();
    Address cursor=start;
    while (cursor.LT(end)) {
      Address metadata=EmbeddedMetaData.getMetaDataBase(cursor).plus(META_DATA_OFFSET);
      VM.memory.zero(metadata,bytes);
      cursor=cursor.plus(EmbeddedMetaData.BYTES_IN_REGION);
    }
  }
 else {
    for (Address cursor=headDiscontiguousRegion; !cursor.isZero(); cursor=Map.getNextContiguousRegion(cursor)) {
      Address metadata=EmbeddedMetaData.getMetaDataBase(cursor).plus(META_DATA_OFFSET);
      VM.memory.zero(metadata,bytes);
    }
  }
}
Program: 149719
Project: 149719
Buggy source:
/** 
 * Extend the virtual memory associated with a particular discontiguous space.  This simply involves requesting a suitable number of chunks from the pool of chunks available to discontiguous spaces.
 * @param chunks The number of chunks by which the space needs to be extended
 * @return The address of the new discontiguous space.
 */
public Address growDiscontiguousSpace(int chunks){
  this.lastDiscontiguousRegion=Map.allocateContiguousChunks(descriptor,this,chunks,lastDiscontiguousRegion);
  return lastDiscontiguousRegion;
}

Fixed version (ground truth):
/** 
 * Extend the virtual memory associated with a particular discontiguous space.  This simply involves requesting a suitable number of chunks from the pool of chunks available to discontiguous spaces.
 * @param chunks The number of chunks by which the space needs to be extended
 * @return The address of the new discontiguous space.
 */
public Address growDiscontiguousSpace(int chunks){
  return headDiscontiguousRegion=Map.allocateContiguousChunks(descriptor,this,chunks,headDiscontiguousRegion);
}
Program: 149722
Project: 149722
Buggy source:
/** 
 * Release one or more contiguous chunks associated with a discontiguous space.
 * @param chunk THe address of the start of the contiguous chunk or chunks
 * @return The number of chunks freed
 */
public int releaseDiscontiguousChunks(Address chunk){
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(chunk.EQ(chunkAlign(chunk,true)));
  if (chunk.EQ(lastDiscontiguousRegion)) {
    lastDiscontiguousRegion=Map.getNextContiguousRegion(chunk);
  }
  return Map.freeContiguousChunks(chunk);
}

Fixed version (ground truth):
/** 
 * Release one or more contiguous chunks associated with a discontiguous space.
 * @param chunk THe address of the start of the contiguous chunk or chunks
 * @return The number of chunks freed
 */
public int releaseDiscontiguousChunks(Address chunk){
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(chunk.EQ(chunkAlign(chunk,true)));
  if (chunk.EQ(headDiscontiguousRegion)) {
    headDiscontiguousRegion=Map.getNextContiguousRegion(chunk);
  }
  return Map.freeContiguousChunks(chunk);
}
Program: 149723
Project: 149723
Buggy source:
/** 
 * Return the address of the next contiguous region associated with some discontiguous space by following the linked list for that space.
 * @param start The current region (return the next region in the list)
 * @return Return the next contiguous region after start in the linked list of regions
 */
public static Address getNextContiguousRegion(Address start){
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(start.EQ(Space.chunkAlign(start,true)));
  int chunk=getChunkIndex(start);
  return (chunk == 0) ? Address.zero() : (linkageMap[chunk] == 0) ? Address.zero() : addressForChunkIndex(linkageMap[chunk]);
}

Fixed version (ground truth):
/** 
 * Return the address of the next contiguous region associated with some discontiguous space by following the linked list for that space.
 * @param start The current region (return the next region in the list)
 * @return Return the next contiguous region after start in the linked list of regions
 */
public static Address getNextContiguousRegion(Address start){
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(start.EQ(Space.chunkAlign(start,true)));
  int chunk=getChunkIndex(start);
  return (chunk == 0) ? Address.zero() : (nextLink[chunk] == 0) ? Address.zero() : addressForChunkIndex(nextLink[chunk]);
}
Program: 149724
Project: 149724
Buggy source:
/** 
 * Allocate some number of contiguous chunks within a discontiguous region
 * @param descriptor The descriptor for the space to which these chunks will be assigned
 * @param space The space to which these chunks will be assigned
 * @param chunks The number of chunks required
 * @param previous The previous contgiuous set of chunks for this space (to create a linked list of contiguous regions for each space)
 * @return The address of the assigned memory.  This always succeeds.  If the request fails we fail right here.
 */
public static Address allocateContiguousChunks(int descriptor,Space space,int chunks,Address previous){
  lock.acquire();
  int chunk=regionMap.alloc(chunks);
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(chunk != 0);
  if (chunk == -1) {
    Log.write("String_Node_Str");
    Log.write(space.getName());
    Log.write("String_Node_Str");
    Log.write(chunks);
    Log.write("String_Node_Str");
    Log.write(chunks << Space.LOG_BYTES_IN_CHUNK);
    Log.writeln("String_Node_Str");
    Space.printVMMap();
    VM.assertions.fail("String_Node_Str");
  }
  totalAvailableDiscontiguousChunks-=chunks;
  Address rtn=addressForChunkIndex(chunk);
  insert(rtn,Extent.fromIntZeroExtend(chunks << Space.LOG_BYTES_IN_CHUNK),descriptor,space);
  linkageMap[chunk]=previous.isZero() ? 0 : getChunkIndex(previous);
  lock.release();
  return rtn;
}

Fixed version (ground truth):
/** 
 * Allocate some number of contiguous chunks within a discontiguous region
 * @param descriptor The descriptor for the space to which these chunks will be assigned
 * @param space The space to which these chunks will be assigned
 * @param chunks The number of chunks required
 * @param head The previous contgiuous set of chunks for this space (to create a linked list of contiguous regions for each space)
 * @return The address of the assigned memory.  This always succeeds.  If the request fails we fail right here.
 */
public static Address allocateContiguousChunks(int descriptor,Space space,int chunks,Address head){
  lock.acquire();
  int chunk=regionMap.alloc(chunks);
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(chunk != 0);
  if (chunk == -1) {
    Log.write("String_Node_Str");
    Log.write(space.getName());
    Log.write("String_Node_Str");
    Log.write(chunks);
    Log.write("String_Node_Str");
    Log.write(chunks << Space.LOG_BYTES_IN_CHUNK);
    Log.writeln("String_Node_Str");
    Space.printVMMap();
    VM.assertions.fail("String_Node_Str");
  }
  totalAvailableDiscontiguousChunks-=chunks;
  Address rtn=addressForChunkIndex(chunk);
  insert(rtn,Extent.fromIntZeroExtend(chunks << Space.LOG_BYTES_IN_CHUNK),descriptor,space);
  if (head.isZero()) {
    if (VM.VERIFY_ASSERTIONS)     VM.assertions._assert(nextLink[chunk] == 0);
  }
 else {
    nextLink[chunk]=getChunkIndex(head);
    prevLink[getChunkIndex(head)]=chunk;
  }
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(prevLink[chunk] == 0);
  lock.release();
  return rtn;
}
Program: 149725
Project: 149725
Buggy source:
/** 
 * Free all chunks in a linked list of contiguous chunks.  This means starting with lastChunk and then walking the chain of contiguous regions, freeing each.
 * @param lastChunk The last chunk in the linked list of chunks to be freed
 */
public static void freeAllChunks(Address lastChunk){
  lock.acquire();
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(lastChunk.EQ(Space.chunkAlign(lastChunk,true)));
  int chunk=getChunkIndex(lastChunk);
  while (chunk != 0) {
    int next=linkageMap[chunk];
    freeContiguousChunks(chunk);
    chunk=next;
  }
  lock.release();
}

Fixed version (ground truth):
/** 
 * Free all chunks in a linked list of contiguous chunks.  This means starting with one and then walking the chains of contiguous regions, freeing each.
 * @param anyChunk Any chunk in the linked list of chunks to be freed
 */
public static void freeAllChunks(Address anyChunk){
  lock.acquire();
  if (VM.VERIFY_ASSERTIONS)   VM.assertions._assert(anyChunk.EQ(Space.chunkAlign(anyChunk,true)));
  if (!anyChunk.isZero()) {
    int chunk=getChunkIndex(anyChunk);
    while (nextLink[chunk] != 0) {
      freeContiguousChunks(nextLink[chunk]);
    }
    while (prevLink[chunk] != 0) {
      freeContiguousChunks(prevLink[chunk]);
    }
    freeContiguousChunks(chunk);
  }
  lock.release();
}
Program: 149726
Project: 149726
Buggy source:
/** 
 * Free some set of contiguous chunks, given the chunk index
 * @param chunk The chunk index of the region to be freed
 * @return The number of chunks freed
 */
private static int freeContiguousChunks(int chunk){
  int chunks=regionMap.free(chunk);
  totalAvailableDiscontiguousChunks+=chunks;
  for (int offset=0; offset < chunks; offset++) {
    descriptorMap[chunk + offset]=0;
    VM.barriers.objectArrayStoreNoGCBarrier(spaceMap,chunk + offset,null);
    linkageMap[chunk + offset]=0;
  }
  return chunks;
}

Fixed version (ground truth):
/** 
 * Free some set of contiguous chunks, given the chunk index
 * @param chunk The chunk index of the region to be freed
 * @return The number of chunks freed
 */
private static int freeContiguousChunks(int chunk){
  int chunks=regionMap.free(chunk);
  totalAvailableDiscontiguousChunks+=chunks;
  int next=nextLink[chunk];
  int prev=prevLink[chunk];
  if (next != 0)   prevLink[next]=prev;
  if (prev != 0)   nextLink[prev]=next;
  nextLink[chunk]=prevLink[chunk]=0;
  for (int offset=0; offset < chunks; offset++) {
    descriptorMap[chunk + offset]=0;
    VM.barriers.objectArrayStoreNoGCBarrier(spaceMap,chunk + offset,null);
  }
  return chunks;
}
Program: 149727
Project: 149727
Buggy source:
/** 
 * Allocate a numeric slot in the jtoc.
 * @param size of slot
 * @param field is the slot for a field
 * @return offset of slot that was allocated as int(two slots are allocated for longs and doubles)
 */
public static synchronized Offset allocateNumericSlot(int size,boolean field){
  int slot;
  if (size == 16) {
    nextNumericSlot-=3;
    if ((nextNumericSlot & 1) != 0) {
      nextNumericSlot--;
      numericSlotHole=nextNumericSlot + 2;
    }
    if ((nextNumericSlot & 3) != 0) {
      nextNumericSlot-=2;
    }
    slot=nextNumericSlot;
    nextNumericSlot--;
    if (field) {
      numericFieldVector.set(slot);
      numericFieldVector.set(slot + 1);
      numericFieldVector.set(slot + 2);
      numericFieldVector.set(slot + 3);
    }
  }
 else   if (size == BYTES_IN_LONG) {
    nextNumericSlot--;
    if ((nextNumericSlot & 1) != 0) {
      nextNumericSlot--;
      numericSlotHole=nextNumericSlot + 2;
    }
    slot=nextNumericSlot;
    nextNumericSlot--;
    if (field) {
      numericFieldVector.set(slot);
      numericFieldVector.set(slot + 1);
    }
  }
 else {
    if (numericSlotHole != middleOfTable) {
      slot=numericSlotHole;
      numericSlotHole=middleOfTable;
    }
 else {
      slot=nextNumericSlot;
      nextNumericSlot--;
    }
    if (field) {
      numericFieldVector.set(slot);
    }
  }
  if (nextNumericSlot < 0) {
    enlargeTable();
  }
  return slotAsOffset(slot);
}

Fixed version (ground truth):
/** 
 * Allocate a numeric slot in the jtoc.
 * @param size of slot
 * @param field is the slot for a field
 * @return offset of slot that was allocated as int(two slots are allocated for longs and doubles)
 */
public static synchronized Offset allocateNumericSlot(int size,boolean field){
  int slot;
  if (size == 16) {
    nextNumericSlot-=3;
    if ((nextNumericSlot & 1) != 0) {
      nextNumericSlot--;
      numericSlotHole=nextNumericSlot + 4;
    }
    if ((nextNumericSlot & 3) != 0) {
      nextNumericSlot-=2;
    }
    slot=nextNumericSlot;
    nextNumericSlot--;
    if (field) {
      numericFieldVector.set(slot);
      numericFieldVector.set(slot + 1);
      numericFieldVector.set(slot + 2);
      numericFieldVector.set(slot + 3);
    }
  }
 else   if (size == BYTES_IN_LONG) {
    nextNumericSlot--;
    if ((nextNumericSlot & 1) != 0) {
      nextNumericSlot--;
      numericSlotHole=nextNumericSlot + 2;
    }
    slot=nextNumericSlot;
    nextNumericSlot--;
    if (field) {
      numericFieldVector.set(slot);
      numericFieldVector.set(slot + 1);
    }
  }
 else {
    if (numericSlotHole != middleOfTable) {
      slot=numericSlotHole;
      numericSlotHole=middleOfTable;
    }
 else {
      slot=nextNumericSlot;
      nextNumericSlot--;
    }
    if (field) {
      numericFieldVector.set(slot);
    }
  }
  if (nextNumericSlot < 0) {
    enlargeTable();
  }
  return slotAsOffset(slot);
}
Program: 149729
Project: 149729
Buggy source:
/** 
 * Save data and perform necessary conversions for entry into JNI. NB only used for Intel.
 * @param encodedReferenceOffsets bit mask marking which elements on the stack hold objects that need encoding as JNI ref identifiers
 */
@Uninterruptible("String_Node_Str") @Entrypoint public void entryToJNI(int encodedReferenceOffsets){
  savedTRreg=Magic.getThreadRegister();
  Address callersFP=Magic.getCallerFramePointer(Magic.getFramePointer());
  basePointerOnEntryToNative=callersFP;
  JNITopJavaFP=callersFP;
  if (VM.traceJNI) {
    RVMMethod m=CompiledMethods.getCompiledMethod(Magic.getCompiledMethodID(callersFP)).getMethod();
    VM.sysWrite("String_Node_Str");
    VM.sysWrite(m.getDeclaringClass().getDescriptor());
    VM.sysWrite("String_Node_Str");
    VM.sysWrite(m.getName());
    VM.sysWrite(m.getDescriptor());
    VM.sysWriteln();
  }
  int oldJNIRefsSavedFP=JNIRefsSavedFP;
  JNIRefsSavedFP=JNIRefsTop;
  uninterruptiblePushJNIRef(Address.fromIntSignExtend(oldJNIRefsSavedFP),false);
  Address fp=Magic.getFramePointer();
  Offset argOffset=Offset.fromIntSignExtend(5 * BYTES_IN_ADDRESS);
  fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset),true),argOffset);
  while (encodedReferenceOffsets != 0) {
    argOffset=argOffset.plus(BYTES_IN_ADDRESS);
    if ((encodedReferenceOffsets & 1) != 0) {
      fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset),true),argOffset);
    }
    encodedReferenceOffsets>>>=1;
  }
  RVMThread.enterJNIFromCallIntoNative();
}

Fixed version (ground truth):
/** 
 * Save data and perform necessary conversions for entry into JNI. NB only used for Intel.
 * @param encodedReferenceOffsets bit mask marking which elements on the stack hold objects that need encoding as JNI ref identifiers
 */
@Uninterruptible("String_Node_Str") @Entrypoint public void entryToJNI(int encodedReferenceOffsets){
  savedTRreg=Magic.getThreadRegister();
  Address callersFP=Magic.getCallerFramePointer(Magic.getFramePointer());
  basePointerOnEntryToNative=callersFP;
  JNITopJavaFP=callersFP;
  if (VM.traceJNI) {
    RVMMethod m=CompiledMethods.getCompiledMethod(Magic.getCompiledMethodID(callersFP)).getMethod();
    VM.sysWrite("String_Node_Str");
    VM.sysWrite(m.getDeclaringClass().getDescriptor());
    VM.sysWrite("String_Node_Str");
    VM.sysWrite(m.getName());
    VM.sysWrite(m.getDescriptor());
    VM.sysWriteln();
  }
  if (JNIRefsTop > 0) {
    uninterruptiblePushJNIRef(Address.fromIntSignExtend(JNIRefsSavedFP),false);
    JNIRefsSavedFP=JNIRefsTop;
  }
  Address fp=Magic.getFramePointer();
  Offset argOffset=Offset.fromIntSignExtend(5 * BYTES_IN_ADDRESS);
  fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset),true),argOffset);
  while (encodedReferenceOffsets != 0) {
    argOffset=argOffset.plus(BYTES_IN_ADDRESS);
    if ((encodedReferenceOffsets & 1) != 0) {
      fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset),true),argOffset);
    }
    encodedReferenceOffsets>>>=1;
  }
  RVMThread.enterJNIFromCallIntoNative();
}
Program: 149730
Project: 149730
Buggy source:
/** 
 * Restore data, throw pending exceptions or convert return value for exit from JNI. NB only used for Intel.
 * @param offset offset into JNI reference tables of result
 * @return Object encoded by offset or null if offset is 0
 */
@Unpreemptible("String_Node_Str" + "String_Node_Str") @Entrypoint public Object exitFromJNI(int offset){
  RVMThread.leaveJNIFromCallIntoNative();
  JNIRefsTop=JNIRefsSavedFP;
  if (JNIRefsTop > 0) {
    JNIRefsSavedFP=JNIRefs.get((JNIRefsTop >> LOG_BYTES_IN_ADDRESS) + 1).toInt();
  }
  Throwable pe=pendingException;
  if (pe != null) {
    pendingException=null;
    RuntimeEntrypoints.athrow(pe);
  }
  Object result;
  if (offset == 0) {
    result=null;
  }
 else   if (offset < 0) {
    result=JNIGlobalRefTable.ref(offset);
  }
 else {
    result=Magic.addressAsObject(JNIRefs.get(offset >> LOG_BYTES_IN_ADDRESS));
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Restore data, throw pending exceptions or convert return value for exit from JNI. NB only used for Intel.
 * @param offset offset into JNI reference tables of result
 * @return Object encoded by offset or null if offset is 0
 */
@Unpreemptible("String_Node_Str" + "String_Node_Str") @Entrypoint public Object exitFromJNI(int offset){
  RVMThread.leaveJNIFromCallIntoNative();
  JNIRefsTop=0;
  if (JNIRefsSavedFP > 0) {
    JNIRefsTop=JNIRefsSavedFP - BYTES_IN_ADDRESS;
    JNIRefsSavedFP=JNIRefs.get(JNIRefsSavedFP >> LOG_BYTES_IN_ADDRESS).toInt();
  }
  Throwable pe=pendingException;
  if (pe != null) {
    pendingException=null;
    RuntimeEntrypoints.athrow(pe);
  }
  Object result;
  if (offset == 0) {
    result=null;
  }
 else   if (offset < 0) {
    result=JNIGlobalRefTable.ref(offset);
  }
 else {
    result=Magic.addressAsObject(JNIRefs.get(offset >> LOG_BYTES_IN_ADDRESS));
  }
  return result;
}