nus-yam/ex-repair huggingface dataset:
Program: 150218
Project: 150218
Buggy source:
/** 
 * Perform post-allocation actions.  For many allocators none are required.
 * @param ref The newly allocated object
 * @param tib The TIB of the newly allocated object
 * @param bytes The size of the space to be allocated (in bytes)
 * @param isScalar True if the object occupying this space will be a scalar
 * @param allocator The allocator number to be used for this allocation
 */
public final void postAlloc(VM_Address ref,Object[] tib,int bytes,boolean isScalar,int allocator) throws VM_PragmaInline {
  int linkSite=((allocator == DEFAULT_SPACE && bytes > LOS_SIZE_THRESHOLD) ? LOS_SPACE : allocator);
  TraceGenerator.addTraceObject(ref,linkSite);
  if (allocator == DEFAULT_SPACE && bytes > LOS_SIZE_THRESHOLD) {
    Header.initializeLOSHeader(ref,tib,bytes,isScalar);
  }
 else {
switch (allocator) {
case DEFAULT_SPACE:
      break;
case IMMORTAL_SPACE:
    ImmortalSpace.postAlloc(ref);
  break;
case LOS_SPACE:
Header.initializeLOSHeader(ref,tib,bytes,isScalar);
break;
default :
if (VM_Interface.VerifyAssertions) VM_Interface.sysFail("String_Node_Str");
}
}
traceInducedGC=TraceGenerator.MERLIN_ANALYSIS;
TraceGenerator.traceAlloc(allocator == IMMORTAL_SPACE,ref,tib,bytes);
}

Fixed version (ground truth):
/** 
 * Perform post-allocation actions.  For many allocators none are required.
 * @param ref The newly allocated object
 * @param tib The TIB of the newly allocated object
 * @param bytes The size of the space to be allocated (in bytes)
 * @param isScalar True if the object occupying this space will be a scalar
 * @param allocator The allocator number to be used for this allocation
 */
public final void postAlloc(VM_Address ref,Object[] tib,int bytes,boolean isScalar,int allocator) throws VM_PragmaInline {
  TraceGenerator.addTraceObject(ref,allocator);
switch (allocator) {
case DEFAULT_SPACE:
    break;
case IMMORTAL_SPACE:
  ImmortalSpace.postAlloc(ref);
break;
case LOS_SPACE:
Header.initializeLOSHeader(ref,tib,bytes,isScalar);
break;
default :
if (VM_Interface.VerifyAssertions) VM_Interface.sysFail("String_Node_Str");
}
traceInducedGC=TraceGenerator.MERLIN_ANALYSIS;
TraceGenerator.traceAlloc(allocator == IMMORTAL_SPACE,ref,tib,bytes);
}
Program: 150219
Project: 150219
Buggy source:
/** 
 * A new reference is about to be created.  Take appropriate write barrier actions.<p>  In this case, we remember the address of the source of the pointer if the new reference points into the nursery from non-nursery space.
 * @param src The object into which the new reference will be stored
 * @param slot The address into which the new reference will bestored.
 * @param tgt The target of the new reference
 * @param locationMetadata an int that encodes the source location being modified
 * @param mode The mode of the store (eg putfield, putstatic etc)
 */
public final void writeBarrier(VM_Address src,VM_Address slot,VM_Address tgt,int locationMetadata,int mode) throws VM_PragmaInline {
  TraceGenerator.processPointerUpdate(mode == PUTFIELD_WRITE_BARRIER,src,slot,tgt);
  VM_Magic.setMemoryAddress(slot,tgt,locationMetadata);
}

Fixed version (ground truth):
/** 
 * A number of references are about to be copied from object <code>src</code> to object <code>dst</code> (as in an array copy).  Thus, <code>dst</code> is the mutated object.  Take appropriate write barrier actions.<p>
 * @param src The source of the values to be copied
 * @param srcOffset The offset of the first source address, inbytes, relative to <code>src</code> (in principle, this could be negative).
 * @param dst The mutated object, i.e. the destination of the copy.
 * @param dstOffset The offset of the first destination address, inbytes relative to <code>tgt</code> (in principle, this could be negative).
 * @param bytes The size of the region being copied, in bytes.
 * @return True if the update was performed by the barrier, false ifleft to the caller (always false in this case).
 */
public boolean writeBarrier(VM_Address src,int srcOffset,VM_Address dst,int dstOffset,int bytes){
  VM_Address slot=dst.add(dstOffset);
  VM_Address tgtLoc=src.add(srcOffset);
  for (int i=0; i < bytes; i+=BYTES_IN_ADDRESS) {
    VM_Address tgt=VM_Magic.getMemoryAddress(tgtLoc);
    TraceGenerator.processPointerUpdate(false,dst,slot,tgt);
    slot=slot.add(BYTES_IN_ADDRESS);
    tgtLoc=tgtLoc.add(BYTES_IN_ADDRESS);
  }
  return false;
}
Program: 150220
Project: 150220
Buggy source:
/** 
 * Perform any post-copy actions.  In this case nothing is required.
 * @param ref The newly allocated object
 * @param tib The TIB of the newly allocated object
 * @param bytes The size of the space to be allocated (in bytes)
 * @param isScalar True if the object occupying this space will be a scalar
 */
public final void postCopy(VM_Address ref,Object[] tib,int bytes,boolean isScalar){
}

Fixed version (ground truth):
/** 
 * Perform any post-copy actions.  In this case nothing is required.
 * @param ref The newly allocated object
 * @param tib The TIB of the newly allocated object
 * @param bytes The size of the space to be allocated (in bytes)
 * @param isScalar True if the object occupying this space will be a scalar
 */
public final void postCopy(VM_Address ref,Object[] tib,int bytes,boolean isScalar){
  CopyingHeader.clearGCBits(ref);
}
Program: 150221
Project: 150221
Buggy source:
/** 
 * Forward the object referred to by a given address and update the address if necessary.  This <i>does not</i> enqueue the referent for processing; the referent must be explicitly enqueued if it is to be processed.
 * @param location The location whose referent is to be forwarded ifnecessary.  The location will be updated if the referent is forwarded.
 */
public static void forwardObjectLocation(VM_Address location) throws VM_PragmaInline {
  VM_Address obj=VM_Magic.getMemoryAddress(location);
  if (!obj.isZero()) {
    VM_Address addr=VM_Interface.refToAddress(obj);
    byte space=VMResource.getSpace(addr);
    if ((hi && space == LOW_SS_SPACE) || (!hi && space == HIGH_SS_SPACE))     VM_Magic.setMemoryAddress(location,CopySpace.forwardObject(obj));
  }
}

Fixed version (ground truth):
/** 
 * Forward the object referred to by a given address and update the address if necessary.  This <i>does not</i> enqueue the referent for processing; the referent must be explicitly enqueued if it is to be processed.
 * @param location The location whose referent is to be forwarded ifnecessary.  The location will be updated if the referent is forwarded.
 */
public static void forwardObjectLocation(VM_Address location) throws VM_PragmaInline {
  if (traceInducedGC) {
    VM_Address obj=VM_Magic.getMemoryAddress(location);
    if (!obj.isZero()) {
      TraceGenerator.rootEnumerate(obj);
    }
  }
 else {
    VM_Address obj=VM_Magic.getMemoryAddress(location);
    if (!obj.isZero()) {
      VM_Address addr=VM_Interface.refToAddress(obj);
      byte space=VMResource.getSpace(addr);
      if ((hi && space == LOW_SS_SPACE) || (!hi && space == HIGH_SS_SPACE))       VM_Magic.setMemoryAddress(location,CopySpace.forwardObject(obj));
    }
  }
}
Program: 150222
Project: 150222
Buggy source:
/** 
 * Allocate space (for an object)
 * @param bytes The size of the space to be allocated (in bytes)
 * @param isScalar True if the object occupying this space will be a scalar
 * @param allocator The allocator number to be used for this allocation
 * @param advice Statically-generated allocation advice for this allocation
 * @return The address of the first byte of the allocated region
 */
public final VM_Address alloc(int bytes,boolean isScalar,int allocator,AllocAdvice advice) throws VM_PragmaInline {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(bytes == (bytes & (~(BYTES_IN_ADDRESS - 1))));
  if (allocator == DEFAULT_SPACE && bytes > LOS_SIZE_THRESHOLD) {
    return los.alloc(isScalar,bytes);
  }
 else {
switch (allocator) {
case DEFAULT_SPACE:
      return ss.alloc(isScalar,bytes);
case IMMORTAL_SPACE:
    return immortal.alloc(isScalar,bytes);
case LOS_SPACE:
  return los.alloc(isScalar,bytes);
default :
if (VM_Interface.VerifyAssertions) VM_Interface.sysFail("String_Node_Str");
return VM_Address.zero();
}
}
}

Fixed version (ground truth):
/** 
 * Allocate space (for an object)
 * @param bytes The size of the space to be allocated (in bytes)
 * @param isScalar True if the object occupying this space will be a scalar
 * @param allocator The allocator number to be used for this allocation
 * @param advice Statically-generated allocation advice for this allocation
 * @return The address of the first byte of the allocated region
 */
public final VM_Address alloc(int bytes,boolean isScalar,int allocator) throws VM_PragmaInline {
switch (allocator) {
case DEFAULT_SPACE:
    return ss.alloc(isScalar,bytes);
case IMMORTAL_SPACE:
  return immortal.alloc(isScalar,bytes);
case LOS_SPACE:
return los.alloc(isScalar,bytes);
default :
if (VM_Interface.VerifyAssertions) VM_Interface.sysFail("String_Node_Str");
return VM_Address.zero();
}
}
Program: 150224
Project: 150224
Buggy source:
/** 
 * Process GC parameters.
 */
public static void processCommandLineArg(String arg) throws VM_PragmaInterruptible {
  Options.process(arg);
}

Fixed version (ground truth):
/** 
 * Process GC parameters.
 */
public static void processCommandLineArg(String arg) throws VM_PragmaInterruptible {
  if (!Options.process(arg)) {
    VM.sysWriteln("String_Node_Str" + p.value + arg);
    VM.sysExit(VM.exitStatusBogusCommandLineArg);
  }
}
Program: 150225
Project: 150225
Buggy source:
/** 
 * Common code shared by the JNI functions NewObjectA, NewObjectV, NewObject (object creation)
 * @param methodID the method ID for a constructor
 * @return a new object created by the specified constructor
 */
public static Object invokeInitializer(Class cls,int methodID,VM_Address argAddress,boolean isJvalue,boolean isDotDotStyle) throws Exception {
  VM_Method mth=VM_MemberReference.getMemberRef(methodID).asMethodReference().resolve();
  VM_TypeReference[] argTypes=mth.getParameterTypes();
  Class[] argClasses=new Class[argTypes.length];
  for (int i=0; i < argClasses.length; i++) {
    argClasses[i]=argTypes[i].resolve().getClassForType();
  }
  Constructor constMethod=cls.getConstructor(argClasses);
  if (constMethod == null)   throw new Exception("String_Node_Str");
  Object argObjs[];
  if (isJvalue) {
    argObjs=packageParameterFromJValue(mth,argAddress);
  }
 else {
    if (isDotDotStyle) {
      VM_Address varargAddress=pushVarArgToSpillArea(methodID,false);
      argObjs=packageParameterFromVarArg(mth,varargAddress);
      VM_Address gluefp=VM_Magic.getCallerFramePointer(VM_Magic.getCallerFramePointer(VM_Magic.getFramePointer()));
      argObjs=packageParameterFromDotArgSVR4(mth,gluefp,false);
    }
 else {
      argObjs=packageParameterFromVarArg(mth,argAddress);
      argObjs=packageParameterFromVarArgSVR4(mth,argAddress);
    }
  }
  return constMethod.newInstance(argObjs);
}

Fixed version (ground truth):
/** 
 * Common code shared by the JNI functions NewObjectA, NewObjectV, NewObject (object creation)
 * @param methodID the method ID for a constructor
 * @return a new object created by the specified constructor
 */
public static Object invokeInitializer(Class cls,int methodID,VM_Address argAddress,boolean isJvalue,boolean isDotDotStyle) throws Exception {
  VM_Method mth=VM_MemberReference.getMemberRef(methodID).asMethodReference().resolve();
  Constructor constMethod=java.lang.reflect.JikesRVMSupport.createConstructor(mth);
  if (!mth.isPublic()) {
    constMethod.setAccessible(true);
  }
  Object argObjs[];
  if (isJvalue) {
    argObjs=packageParameterFromJValue(mth,argAddress);
  }
 else {
    if (isDotDotStyle) {
      VM_Address varargAddress=pushVarArgToSpillArea(methodID,false);
      argObjs=packageParameterFromVarArg(mth,varargAddress);
      VM_Address gluefp=VM_Magic.getCallerFramePointer(VM_Magic.getCallerFramePointer(VM_Magic.getFramePointer()));
      argObjs=packageParameterFromDotArgSVR4(mth,gluefp,false);
    }
 else {
      argObjs=packageParameterFromVarArg(mth,argAddress);
      argObjs=packageParameterFromVarArgSVR4(mth,argAddress);
    }
  }
  return constMethod.newInstance(argObjs);
}
Program: 150226
Project: 150226
Buggy source:
/** 
 * Common code shared by the JNI functions Call<type>Method (virtual method invocation)
 * @param obj the object instance 
 * @param methodID the method ID
 * @param expectReturnType the return type for checking purpose
 * @param skip4Args  true if the calling JNI Function takes 4 args before the varargfalse if the calling JNI Function takes 3 args before the vararg
 * @return an object that may be the return object or a wrapper for the primitive return value 
 */
public static Object invokeWithDotDotVarArg(Object obj,int methodID,VM_TypeReference expectReturnType,boolean skip4Args) throws Exception {
  VM_Address varargAddress=pushVarArgToSpillArea(methodID,skip4Args);
  return packageAndInvoke(obj,methodID,varargAddress,expectReturnType,skip4Args,AIX_VARARG);
  VM_Address glueFP=VM_Magic.getCallerFramePointer(VM_Magic.getCallerFramePointer(VM_Magic.getFramePointer()));
  return packageAndInvoke(obj,methodID,glueFP,expectReturnType,skip4Args,SVR4_DOTARG);
}

Fixed version (ground truth):
/** 
 * Common code shared by the JNI functions Call<type>Method (virtual method invocation)
 * @param obj the object instance 
 * @param methodID the method ID
 * @param expectReturnType the return type for checking purpose
 * @param skip4Args  true if the calling JNI Function takes 4 args before the varargfalse if the calling JNI Function takes 3 args before the vararg
 * @return an object that may be the return object or a wrapper for the primitive return value 
 */
public static Object invokeWithDotDotVarArg(Object obj,int methodID,VM_TypeReference expectReturnType,boolean skip4Args) throws Exception, VM_PragmaNoInline {
  VM_Address varargAddress=pushVarArgToSpillArea(methodID,skip4Args);
  return packageAndInvoke(obj,methodID,varargAddress,expectReturnType,skip4Args,AIX_VARARG);
  VM_Address glueFP=VM_Magic.getCallerFramePointer(VM_Magic.getCallerFramePointer(VM_Magic.getFramePointer()));
  return packageAndInvoke(obj,methodID,glueFP,expectReturnType,skip4Args,SVR4_DOTARG);
}
Program: 150230
Project: 150230
Buggy source:
/** 
 * Called from VM_Processor.dispatch when a thread is about to stop executing.
 */
void endQuantum(long now){
  if (startCycle != -1) {
    totalCycles+=now - startCycle;
  }
  startCycle=0;
}

Fixed version (ground truth):
/** 
 * Called from VM_Processor.dispatch when a thread is about to stop executing.
 */
void endQuantum(long now){
  totalCycles+=now - startCycle;
  startCycle=0;
}
Program: 150231
Project: 150231
Buggy source:
/** 
 * Common code shared by the JNI functions NewObjectA, NewObjectV, NewObject (object creation)
 * @param methodID the method ID for a constructor
 * @return a new object created by the specified constructor
 */
static Object invokeInitializer(Class cls,int methodID,VM_Address argAddress,boolean isJvalue,boolean isDotDotStyle) throws Exception {
  VM_Method mth=VM_MemberReference.getMemberRef(methodID).asMethodReference().resolve();
  VM_TypeReference[] argTypes=mth.getParameterTypes();
  Class[] argClasses=new Class[argTypes.length];
  for (int i=0; i < argClasses.length; i++) {
    argClasses[i]=argTypes[i].resolve().getClassForType();
  }
  Constructor constMethod=java.lang.reflect.JikesRVMSupport.createConstructor(mth);
  if (!mth.isPublic()) {
    constMethod.setAccessible(true);
  }
  VM_Address varargAddress;
  if (isDotDotStyle)   varargAddress=getVarArgAddress(false);
 else   varargAddress=argAddress;
  Object argObjs[];
  if (isJvalue)   argObjs=packageParameterFromJValue(mth,argAddress);
 else   argObjs=packageParameterFromVarArg(mth,varargAddress);
  return constMethod.newInstance(argObjs);
}

Fixed version (ground truth):
/** 
 * Common code shared by the JNI functions NewObjectA, NewObjectV, NewObject (object creation)
 * @param methodID the method ID for a constructor
 * @return a new object created by the specified constructor
 */
static Object invokeInitializer(Class cls,int methodID,VM_Address argAddress,boolean isJvalue,boolean isDotDotStyle) throws Exception {
  VM_Method mth=VM_MemberReference.getMemberRef(methodID).asMethodReference().resolve();
  Constructor constMethod=java.lang.reflect.JikesRVMSupport.createConstructor(mth);
  if (!mth.isPublic()) {
    constMethod.setAccessible(true);
  }
  VM_Address varargAddress;
  if (isDotDotStyle)   varargAddress=getVarArgAddress(false);
 else   varargAddress=argAddress;
  Object argObjs[];
  if (isJvalue)   argObjs=packageParameterFromJValue(mth,argAddress);
 else   argObjs=packageParameterFromVarArg(mth,varargAddress);
  return constMethod.newInstance(argObjs);
}
Program: 150233
Project: 150233
Buggy source:
/** 
 * Run <clinit> method of specified class, if that class appears  in bootimage and actually has a clinit method (we are flexible to allow one list of classes to work with different bootimages and  different version of classpath (eg 0.05 vs. cvs head). This method is called only while the VM boots.
 * @param className
 */
static void runClassInitializer(String className) throws VM_PragmaInterruptible {
  if (verboseBoot >= 2) {
    sysWrite("String_Node_Str");
    sysWriteln(className);
  }
  VM_Atom classDescriptor=VM_Atom.findOrCreateAsciiAtom(className.replace('.','/')).descriptorFromClassName();
  VM_TypeReference tRef=VM_TypeReference.findOrCreate(VM_SystemClassLoader.getVMClassLoader(),classDescriptor);
  VM_Class cls=(VM_Class)tRef.peekResolvedType();
  if (cls != null && cls.isInBootImage()) {
    VM_Method clinit=cls.getClassInitializerMethod();
    if (clinit != null) {
      clinit.compile();
      if (verboseBoot >= 10)       VM.sysWriteln("String_Node_Str" + clinit);
      try {
        VM_Magic.invokeClassInitializer(clinit.getCurrentInstructions());
      }
 catch (      Error e) {
        throw e;
      }
catch (      Throwable t) {
        ExceptionInInitializerError eieio=new ExceptionInInitializerError("String_Node_Str" + className);
        eieio.initCause(t);
        throw eieio;
      }
    }
 else {
      if (verboseBoot >= 10)       VM.sysWriteln("String_Node_Str");
    }
    cls.setAllFinalStaticJTOCEntries();
  }
}

Fixed version (ground truth):
/** 
 * Run <clinit> method of specified class, if that class appears  in bootimage and actually has a clinit method (we are flexible to allow one list of classes to work with different bootimages and  different version of classpath (eg 0.05 vs. cvs head). This method is called only while the VM boots.
 * @param className
 */
static void runClassInitializer(String className) throws VM_PragmaInterruptible {
  if (verboseBoot >= 2) {
    sysWrite("String_Node_Str");
    sysWriteln(className);
  }
  VM_Atom classDescriptor=VM_Atom.findOrCreateAsciiAtom(className.replace('.','/')).descriptorFromClassName();
  VM_TypeReference tRef=VM_TypeReference.findOrCreate(VM_SystemClassLoader.getVMClassLoader(),classDescriptor);
  VM_Class cls=(VM_Class)tRef.peekResolvedType();
  if (cls != null && cls.isInBootImage()) {
    VM_Method clinit=cls.getClassInitializerMethod();
    if (clinit != null) {
      clinit.compile();
      if (verboseBoot >= 10)       VM.sysWriteln("String_Node_Str" + clinit);
      try {
        VM_Magic.invokeClassInitializer(clinit.getCurrentInstructions());
      }
 catch (      Error e) {
        throw e;
      }
catch (      Throwable t) {
        ExceptionInInitializerError eieio=new ExceptionInInitializerError("String_Node_Str" + className);
        eieio.initCause(t);
        throw eieio;
      }
      clinit.invalidateCompiledMethod(clinit.getCurrentCompiledMethod());
    }
 else {
      if (verboseBoot >= 10)       VM.sysWriteln("String_Node_Str");
    }
    cls.setAllFinalStaticJTOCEntries();
  }
}
Program: 150236
Project: 150236
Buggy source:
/** 
 * Perform operations with <i>thread-local</i> scope to release resources after a collection.  This is called by <code>release()</code> which will ensure that <i>all threads</i> execute this.
 */
private final void baseThreadLocalRelease(int order){
  values.reset();
  remset.reset();
  forwardPool.reset();
  rootLocations.reset();
  interiorRootLocations.reset();
  threadLocalRelease(order);
}

Fixed version (ground truth):
/** 
 * Perform operations with <i>thread-local</i> scope to release resources after a collection.  This is called by <code>release()</code> which will ensure that <i>all threads</i> execute this.
 */
private final void baseThreadLocalRelease(int order){
  values.reset();
  remset.reset();
  forwardedObjects.reset();
  rootLocations.reset();
  interiorRootLocations.reset();
  threadLocalRelease(order);
}
Program: 150237
Project: 150237
Buggy source:
/** 
 * Perform operations with <i>thread-local</i> scope to release resources after a collection.  This is called by <code>release()</code> which will ensure that <i>all threads</i> execute this.
 */
private final void baseThreadLocalRelease(int order){
  values.reset();
  remset.reset();
  forwardPool.reset();
  rootLocations.reset();
  interiorRootLocations.reset();
  threadLocalRelease(order);
}

Fixed version (ground truth):
/** 
 * Perform operations with <i>thread-local</i> scope to release resources after a collection.  This is called by <code>release()</code> which will ensure that <i>all threads</i> execute this.
 */
private final void baseThreadLocalRelease(int order){
  values.reset();
  remset.reset();
  forwardedObjects.reset();
  rootLocations.reset();
  interiorRootLocations.reset();
  threadLocalRelease(order);
}
Program: 150239
Project: 150239
Buggy source:
public void reset(){
  mapOffset=0;
  if (bridgeTarget != null) {
    bridgeParameterMappingRequired=true;
    bridgeParameterIndex=bridgeParameterInitialIndex;
    bridgeRegisterIndex=FIRST_VOLATILE_GPR;
    bridgeRegisterLocation=VM_Magic.getMemoryAddress(framePtr);
    bridgeRegisterLocation=bridgeRegisterLocation.sub(8 * (LAST_NONVOLATILE_FPR - FIRST_VOLATILE_FPR + 1) + 4 * (LAST_NONVOLATILE_GPR - FIRST_VOLATILE_GPR + 1));
  }
}

Fixed version (ground truth):
public void reset(){
  mapOffset=0;
  if (bridgeTarget != null) {
    bridgeParameterMappingRequired=true;
    bridgeParameterIndex=bridgeParameterInitialIndex;
    bridgeRegisterIndex=FIRST_VOLATILE_GPR;
    bridgeRegisterLocation=VM_Magic.getMemoryAddress(framePtr);
    bridgeRegisterLocation=bridgeRegisterLocation.sub(BYTES_IN_DOUBLE * (LAST_NONVOLATILE_FPR - FIRST_VOLATILE_FPR + 1) + BYTES_IN_ADDRESS * (LAST_NONVOLATILE_GPR - FIRST_VOLATILE_GPR + 1));
  }
}
Program: 150240
Project: 150240
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){
  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)   totalCount+=value;
}
Program: 150241
Project: 150241
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){
  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)   totalCount+=value;
}
Program: 150242
Project: 150242
Buggy source:
/** 
 * Sort the address on the shared stack.
 */
public final void sort(){
  ((SortSharedDeque)queue).sort();
}

Fixed version (ground truth):
/** 
 * Sort the address on the shared stack.
 */
public final void sort(){
  flushLocal();
  ((SortSharedDeque)queue).sort();
}
Program: 150243
Project: 150243
Buggy source:
/** 
 * Emit code to allocate an array
 * @param array the VM_Array to instantiate
 */
protected final void emit_resolved_newarray(VM_Array array){
  int width=array.getLogElementSize();
  int tibOffset=array.getTibOffset();
  int headerSize=VM_ObjectModel.computeArrayHeaderSize(array);
  int whichAllocator=MM_Interface.pickAllocator(array,method);
  int align=VM_ObjectModel.getAlignment(array);
  int offset=VM_ObjectModel.getOffsetForAlignment(array);
  asm.emitLAddrToc(T0,VM_Entrypoints.resolvedNewArrayMethod.getOffset());
  asm.emitMTCTR(T0);
  peekInt(T0,0);
  asm.emitLVAL(T1,width);
  asm.emitLVAL(T2,headerSize);
  asm.emitLAddrToc(T3,tibOffset);
  asm.emitLVAL(T4,whichAllocator);
  asm.emitLVAL(T5,align);
  asm.emitLVAL(T6,align);
  asm.emitBCCTRL();
  pokeAddr(T0,0);
}

Fixed version (ground truth):
/** 
 * Emit code to allocate an array
 * @param array the VM_Array to instantiate
 */
protected final void emit_resolved_newarray(VM_Array array){
  int width=array.getLogElementSize();
  int tibOffset=array.getTibOffset();
  int headerSize=VM_ObjectModel.computeArrayHeaderSize(array);
  int whichAllocator=MM_Interface.pickAllocator(array,method);
  int align=VM_ObjectModel.getAlignment(array);
  int offset=VM_ObjectModel.getOffsetForAlignment(array);
  asm.emitLAddrToc(T0,VM_Entrypoints.resolvedNewArrayMethod.getOffset());
  asm.emitMTCTR(T0);
  peekInt(T0,0);
  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: 150245
Project: 150245
Buggy source:
/** 
 * Allocate a scalar object.
 * @param size Size in bytes of the object, including any headersthat need space.
 * @param tib  Type of the object (pointer to TIB).
 * @param allocator Specify which allocation scheme/area JMTk shouldallocate the memory from.
 * @param align the alignment requested; must be a power of 2.
 * @param offset the offset at which the alignment is desired.
 * @return the initialized Object
 */
public static Object allocateScalar(int size,Object[] tib,int allocator,int align,int offset) throws VM_PragmaUninterruptible, VM_PragmaInline {
  Plan plan=VM_Interface.getPlan();
  if (BYTES_IN_ADDRESS != BYTES_IN_INT)   size=VM_Memory.alignUp(size,BYTES_IN_ADDRESS);
  int rawSize=(align != BYTES_IN_ADDRESS) ? (size + align) : size;
  AllocAdvice advice=plan.getAllocAdvice(null,rawSize,null,null);
  VM_Address region=plan.alloc(rawSize,true,allocator,advice);
  if (CHECK_MEMORY_IS_ZEROED)   Memory.assertIsZeroed(region,rawSize);
  if (align != BYTES_IN_ADDRESS) {
    VM_Word mask=VM_Word.fromIntSignExtend(align - 1);
    VM_Word negOff=VM_Word.fromIntSignExtend(-offset);
    VM_Offset delta=negOff.sub(region.toWord()).and(mask).toOffset();
    region=region.add(delta);
  }
  Object result=VM_ObjectModel.initializeScalar(region,tib,size);
  plan.postAlloc(VM_Magic.objectAsAddress(result),tib,rawSize,true,allocator);
  return result;
}

Fixed version (ground truth):
/** 
 * Allocate a scalar object.
 * @param size Size in bytes of the object, including any headersthat need space.
 * @param tib  Type of the object (pointer to TIB).
 * @param allocator Specify which allocation scheme/area JMTk shouldallocate the memory from.
 * @param align the alignment requested; must be a power of 2.
 * @param offset the offset at which the alignment is desired.
 * @return the initialized Object
 */
public static Object allocateScalar(int size,Object[] tib,int allocator,int align,int offset) throws VM_PragmaUninterruptible, VM_PragmaInline {
  Plan plan=VM_Interface.getPlan();
  int alignedSize=size;
  if (BYTES_IN_ADDRESS != BYTES_IN_INT)   alignedSize=VM_Memory.alignUp(size,BYTES_IN_ADDRESS);
  int rawSize=(align != BYTES_IN_ADDRESS) ? (alignedSize + align) : alignedSize;
  AllocAdvice advice=plan.getAllocAdvice(null,rawSize,null,null);
  VM_Address region=plan.alloc(rawSize,true,allocator,advice);
  if (CHECK_MEMORY_IS_ZEROED)   Memory.assertIsZeroed(region,rawSize);
  if (align != BYTES_IN_ADDRESS) {
    VM_Word mask=VM_Word.fromIntSignExtend(align - 1);
    VM_Word negOff=VM_Word.fromIntSignExtend(-offset);
    VM_Offset delta=negOff.sub(region.toWord()).and(mask).toOffset();
    region=region.add(delta);
  }
  Object result=VM_ObjectModel.initializeScalar(region,tib,size);
  plan.postAlloc(VM_Magic.objectAsAddress(result),tib,rawSize,true,allocator);
  return result;
}
Program: 150247
Project: 150247
Buggy source:
/** 
 * A collection has fully completed.  Decrement the collectionInitiated state variable appropriately.
 */
public static void collectionComplete() throws VM_PragmaUninterruptible {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(collectionsInitiated > 0);
  collectionsInitiated--;
}

Fixed version (ground truth):
/** 
 * A collection has fully completed.  Decrement the collectionInitiated state variable appropriately.
 */
public static void collectionComplete() throws VM_PragmaUninterruptible {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(collectionsInitiated > 0);
  collectionsInitiated=0;
}
Program: 150248
Project: 150248
Buggy source:
/** 
 * A collection has fully completed.  Decrement the collectionInitiated state variable appropriately.
 */
public static void collectionComplete() throws VM_PragmaUninterruptible {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(collectionsInitiated > 0);
  collectionsInitiated--;
}

Fixed version (ground truth):
/** 
 * A collection has fully completed.  Decrement the collectionInitiated state variable appropriately.
 */
public static void collectionComplete() throws VM_PragmaUninterruptible {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(collectionsInitiated > 0);
  collectionsInitiated=0;
}
Program: 150249
Project: 150249
Buggy source:
protected final int getEdgeCounterOffset(){
  return method.getId() << 2;
}

Fixed version (ground truth):
protected final int getEdgeCounterOffset(){
  return method.getId() << LOG_BYTES_IN_ADDRESS;
}
Program: 150250
Project: 150250
Buggy source:
/** 
 * Forward an object.  If the object has not already been forwarded, then conditionally enqueue it for scanning.
 * @param object The object to be forwarded.
 * @param scan If <code>true</code>, then enqueue the object forscanning if the object was previously unforwarded.
 * @return The forwarded object.
 */
private static VM_Address forwardObject(VM_Address object,boolean scan) throws VM_PragmaInline {
  int forwardingPtr=CopyingHeader.attemptToForward(object);
  VM_Magic.isync();
  if (CopyingHeader.stateIsForwardedOrBeingForwarded(forwardingPtr)) {
    while (CopyingHeader.stateIsBeingForwarded(forwardingPtr))     forwardingPtr=CopyingHeader.getForwardingWord(object);
    VM_Magic.isync();
    VM_Address newObject=VM_Address.fromInt(forwardingPtr & ~CopyingHeader.GC_FORWARDING_MASK);
    return newObject;
  }
  VM_Address newObject=VM_Interface.copy(object,forwardingPtr);
  CopyingHeader.setForwardingPointer(object,newObject);
  if (scan) {
    Plan.enqueue(newObject);
  }
 else {
    Plan.enqueueForwardedUnscannedObject(newObject);
  }
  return newObject;
}

Fixed version (ground truth):
/** 
 * Forward an object.  If the object has not already been forwarded, then conditionally enqueue it for scanning.
 * @param object The object to be forwarded.
 * @param scan If <code>true</code>, then enqueue the object forscanning if the object was previously unforwarded.
 * @return The forwarded object.
 */
private static VM_Address forwardObject(VM_Address object,boolean scan) throws VM_PragmaInline {
  VM_Word forwardingPtr=CopyingHeader.attemptToForward(object);
  VM_Magic.isync();
  if (CopyingHeader.stateIsForwardedOrBeingForwarded(forwardingPtr)) {
    while (CopyingHeader.stateIsBeingForwarded(forwardingPtr))     forwardingPtr=CopyingHeader.getForwardingWord(object);
    VM_Magic.isync();
    VM_Address newObject=forwardingPtr.and(CopyingHeader.GC_FORWARDING_MASK.not()).toAddress();
    return newObject;
  }
  VM_Address newObject=VM_Interface.copy(object,forwardingPtr);
  CopyingHeader.setForwardingPointer(object,newObject);
  if (scan) {
    Plan.enqueue(newObject);
  }
 else {
    Plan.enqueueForwardedUnscannedObject(newObject);
  }
  return newObject;
}
Program: 150251
Project: 150251
Buggy source:
/** 
 * test to see if the mark bit has the given value
 */
private static boolean testMarkBit(VM_Address ref,int value){
  return (VM_Interface.readAvailableBitsWord(ref) & value) != 0;
}

Fixed version (ground truth):
/** 
 * test to see if the mark bit has the given value
 */
private static boolean testMarkBit(VM_Address ref,VM_Word value){
  return !(VM_Interface.readAvailableBitsWord(ref).and(value).isZero());
}
Program: 150252
Project: 150252
Buggy source:
/** 
 * write the given value in the mark bit.
 */
private static void writeMarkBit(VM_Address ref,int value){
  int oldValue=VM_Interface.readAvailableBitsWord(ref);
  int newValue=(oldValue & ~GC_MARK_BIT_MASK) | value;
  VM_Interface.writeAvailableBitsWord(ref,newValue);
}

Fixed version (ground truth):
/** 
 * write the given value in the mark bit.
 */
private static void writeMarkBit(VM_Address ref,VM_Word value){
  VM_Word oldValue=VM_Interface.readAvailableBitsWord(ref);
  VM_Word newValue=oldValue.and(GC_MARK_BIT_MASK.not()).or(value);
  VM_Interface.writeAvailableBitsWord(ref,newValue);
}
Program: 150253
Project: 150253
Buggy source:
/** 
 * Prepare for a new collection increment.  For the immortal collector we must flip the state of the mark bit between collections.
 */
public static void prepare(VMResource vm,MemoryResource mr){
  immortalMarkState=GC_MARK_BIT_MASK - immortalMarkState;
}

Fixed version (ground truth):
/** 
 * Prepare for a new collection increment.  For the immortal collector we must flip the state of the mark bit between collections.
 */
public static void prepare(VMResource vm,MemoryResource mr){
  immortalMarkState=GC_MARK_BIT_MASK.sub(immortalMarkState);
}
Program: 150254
Project: 150254
Buggy source:
/** 
 * Used to mark boot image objects during a parallel scan of objects during GC Returns true if marking was done.
 */
private static boolean testAndMark(VM_Address ref,int value) throws VM_PragmaInline {
  int oldValue;
  do {
    oldValue=VM_Interface.prepareAvailableBits(ref);
    int markBit=oldValue & GC_MARK_BIT_MASK;
    if (markBit == value)     return false;
  }
 while (!VM_Interface.attemptAvailableBits(ref,oldValue,oldValue ^ GC_MARK_BIT_MASK));
  return true;
}

Fixed version (ground truth):
/** 
 * Used to mark boot image objects during a parallel scan of objects during GC Returns true if marking was done.
 */
private static boolean testAndMark(VM_Address ref,VM_Word value) throws VM_PragmaInline {
  VM_Word oldValue;
  do {
    oldValue=VM_Interface.prepareAvailableBits(ref);
    VM_Word markBit=oldValue.and(GC_MARK_BIT_MASK);
    if (markBit.EQ(value))     return false;
  }
 while (!VM_Interface.attemptAvailableBits(ref,oldValue,oldValue.xor(GC_MARK_BIT_MASK)));
  return true;
}
Program: 150255
Project: 150255
Buggy source:
/** 
 * atomically write the given value in the mark bit.
 */
private static void atomicWriteMarkBit(VM_Address ref,int value){
  while (true) {
    int oldValue=VM_Interface.prepareAvailableBits(ref);
    int newValue=(oldValue & ~GC_MARK_BIT_MASK) | value;
    if (VM_Interface.attemptAvailableBits(ref,oldValue,newValue))     break;
  }
}

Fixed version (ground truth):
/** 
 * atomically write the given value in the mark bit.
 */
private static void atomicWriteMarkBit(VM_Address ref,VM_Word value){
  while (true) {
    VM_Word oldValue=VM_Interface.prepareAvailableBits(ref);
    VM_Word newValue=oldValue.and(GC_MARK_BIT_MASK.not()).or(value);
    if (VM_Interface.attemptAvailableBits(ref,oldValue,newValue))     break;
  }
}
Program: 150256
Project: 150256
Buggy source:
/** 
 * Initialize any header information for a new block.  In this case, this just means zeroing the header bits.
 * @param block The new block whose header is to be zeroed
 * @param sizeClass The sizeClass of the new block
 */
protected final void postExpandSizeClass(VM_Address block,int sizeClass){
  Memory.zeroSmall(block.add(MARK_BITMAP_BASE),VM_Extent.fromInt(bitmaps[sizeClass] << LOG_BYTES_IN_BITMAP));
}

Fixed version (ground truth):
/** 
 * Initialize any header information for a new block.  In this case, this just means zeroing the header bits.
 * @param block The new block whose header is to be zeroed
 * @param sizeClass The sizeClass of the new block
 */
protected final void postExpandSizeClass(VM_Address block,int sizeClass){
  Memory.zeroSmall(block.add(MARK_BITMAP_BASE),VM_Word.fromInt(bitmaps[sizeClass]).lsh(LOG_BYTES_IN_BITMAP).toExtent());
}
Program: 150257
Project: 150257
Buggy source:
/** 
 * Prepare for a new collection increment.  For the mark-sweep collector we must flip the state of the mark bit between collections.
 * @param vm (unused)
 * @param mr (unused)
 */
public void prepare(VMResource vm,MemoryResource mr){
  markState=MarkSweepHeader.MARK_BIT_MASK - markState;
  inMSCollection=true;
}

Fixed version (ground truth):
/** 
 * Prepare for a new collection increment.  For the mark-sweep collector we must flip the state of the mark bit between collections.
 * @param vm (unused)
 * @param mr (unused)
 */
public void prepare(VMResource vm,MemoryResource mr){
  markState=MarkSweepHeader.MARK_BIT_MASK.sub(markState);
  inMSCollection=true;
}
Program: 150258
Project: 150258
Buggy source:
/** 
 * Return the initial value for the header of a new object instance. The header for this collector includes a mark bit.
 */
public final int getInitialHeaderValue() throws VM_PragmaInline {
  return markState;
}

Fixed version (ground truth):
/** 
 * Return the initial value for the header of a new object instance. The header for this collector includes a mark bit.
 */
public final VM_Word getInitialHeaderValue() throws VM_PragmaInline {
  return markState;
}
Program: 150259
Project: 150259
Buggy source:
/** 
 * Return the initial value for the header of a new object instance. The header for this collector includes a mark bit and a small object flag.
 * @param size The size of the newly allocated object
 */
public final int getInitialHeaderValue(int size) throws VM_PragmaInline {
  return 0;
}

Fixed version (ground truth):
/** 
 * Return the initial value for the header of a new object instance. The header for this collector includes a mark bit and a small object flag.
 * @param size The size of the newly allocated object
 */
public final VM_Word getInitialHeaderValue(int size) throws VM_PragmaInline {
  return VM_Word.zero();
}
Program: 150260
Project: 150260
Buggy source:
/** 
 * Prepare for a new collection increment.  For the mark-sweep collector we must flip the state of the mark bit between collections.
 * @param vm (unused)
 * @param mr (unused)
 */
public void prepare(VMResource vm,MemoryResource mr){
  markState=MarkSweepHeader.MARK_BIT_MASK - markState;
  inTreadmillCollection=true;
}

Fixed version (ground truth):
/** 
 * Prepare for a new collection increment.  For the mark-sweep collector we must flip the state of the mark bit between collections.
 * @param vm (unused)
 * @param mr (unused)
 */
public void prepare(VMResource vm,MemoryResource mr){
  markState=MarkSweepHeader.MARK_BIT_MASK.sub(markState);
  inTreadmillCollection=true;
}
Program: 150261
Project: 150261
Buggy source:
/** 
 * Return the initial value for the header of a new object instance. The header for this collector includes a mark bit and a small object flag.
 * @param size The size of the newly allocated object
 */
public final int getInitialHeaderValue(int size) throws VM_PragmaInline {
  return markState;
}

Fixed version (ground truth):
/** 
 * Return the initial value for the header of a new object instance. The header for this collector includes a mark bit and a small object flag.
 * @param size The size of the newly allocated object
 */
public final VM_Word getInitialHeaderValue(int size) throws VM_PragmaInline {
  return markState;
}
Program: 150262
Project: 150262
Buggy source:
public static int addressToMmapChunksUp(VM_Address addr){
  return ((addr.toInt()) + (LazyMmapper.MMAP_CHUNK_SIZE - 1)) >>> LazyMmapper.LOG_MMAP_CHUNK_SIZE;
}

Fixed version (ground truth):
public static int addressToMmapChunksUp(VM_Address addr){
  VM_Word chunk=addr.add(LazyMmapper.MMAP_CHUNK_SIZE - 1).toWord().rshl(LazyMmapper.LOG_MMAP_CHUNK_SIZE);
  return chunk.toInt();
}
Program: 150263
Project: 150263
Buggy source:
public static int bytesToPages(int bytes){
  int pages=bytesToPagesUp(bytes);
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(pagesToBytes(pages) == bytes);
  return pages;
}

Fixed version (ground truth):
public static int bytesToPages(VM_Extent bytes){
  int pages=bytesToPagesUp(bytes);
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(pagesToAddress(pages).toWord().toExtent().EQ(bytes));
  return pages;
}
Program: 150264
Project: 150264
Buggy source:
public static int bytesToPagesUp(int bytes){
  return (bytes + BYTES_IN_PAGE - 1) >>> LOG_BYTES_IN_PAGE;
}

Fixed version (ground truth):
public static int bytesToPagesUp(VM_Extent bytes){
  return bytes.add(BYTES_IN_PAGE - 1).toWord().rshl(LOG_BYTES_IN_PAGE).toInt();
}
Program: 150265
Project: 150265
Buggy source:
public final boolean isNode(VM_Address node){
  VM_Word n=node.toWord();
  return (n.toInt() / granularity * granularity) == n.toInt();
}

Fixed version (ground truth):
public final boolean isNode(VM_Address node){
  if (BITS_IN_ADDRESS == 64)   return (node.toLong() / granularity * granularity) == node.toLong();
 else   return (node.toInt() / granularity * granularity) == node.toInt();
}
Program: 150266
Project: 150266
Buggy source:
public static void set(VM_Address start,int len,int v) throws VM_PragmaInline {
  for (int i=0; i < len; i+=4)   VM_Magic.setMemoryInt(start.add(i),v);
}

Fixed version (ground truth):
public static void set(VM_Address start,int len,int v) throws VM_PragmaInline {
  for (int i=0; i < len; i+=BYTES_IN_INT)   VM_Magic.setMemoryInt(start.add(i),v);
}
Program: 150267
Project: 150267
Buggy source:
private static boolean isSetHelper(VM_Address start,int size,boolean verbose,int v) throws VM_PragmaNoInline {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert(size == (size & (~3)));
  for (int i=0; i < size; i+=4)   if (VM_Magic.getMemoryInt(start.add(i)) != v) {
    if (verbose) {
      Log.prependThreadId();
      Log.write("String_Node_Str");
      Log.writeln(v);
      Log.write("String_Node_Str");
      Log.write(start);
      Log.write("String_Node_Str");
      Log.writeln(start.add(size));
      Log.write("String_Node_Str");
      Log.writeln(start.add(i));
      dumpMemory(start,0,size);
    }
    return false;
  }
  return true;
}

Fixed version (ground truth):
private static boolean isSetHelper(VM_Address start,int size,boolean verbose,int v) throws VM_PragmaNoInline {
  if (VM_Interface.VerifyAssertions)   VM_Interface._assert((size & (BYTES_IN_INT - 1)) == 0);
  for (int i=0; i < size; i+=BYTES_IN_INT)   if (VM_Magic.getMemoryInt(start.add(i)) != v) {
    if (verbose) {
      Log.prependThreadId();
      Log.write("String_Node_Str");
      Log.writeln(v);
      Log.write("String_Node_Str");
      Log.write(start);
      Log.write("String_Node_Str");
      Log.writeln(start.add(size));
      Log.write("String_Node_Str");
      Log.writeln(start.add(i));
      dumpMemory(start,0,size);
    }
    return false;
  }
  return true;
}
Program: 150268
Project: 150268
Buggy source:
public static void zeroSmall(VM_Address start,VM_Extent len) throws VM_PragmaInline {
  for (int i=0; VM_Extent.fromIntZeroExtend(i).LT(len); i+=4)   VM_Magic.setMemoryInt(start.add(i),0);
}

Fixed version (ground truth):
public static void zeroSmall(VM_Address start,VM_Extent len) throws VM_PragmaInline {
  VM_Address end=start.add(len);
  for (VM_Address i=start; i.LT(end); i=i.add(BYTES_IN_INT))   VM_Magic.setMemoryInt(i,0);
}
Program: 150269
Project: 150269
Buggy source:
/** 
 * Allocate a large object.  Large objects are directly allocted and freed in page-grained units via the vm resource.  This routine returned zeroed memory.
 * @param isScalar True if the object to occupy this space will be a scalar.
 * @param bytes The required size of this space in bytes.
 * @param inGC If true, this allocation is occuring with respect toa space that is currently being collected.
 * @return The address of the start of the newly allocated region atleast <code>bytes</code> bytes in size.
 */
final protected VM_Address allocSlowOnce(boolean isScalar,int bytes,boolean inGC){
  int header=superPageHeaderSize() + cellHeaderSize();
  int pages=(bytes + header + BYTES_IN_PAGE - 1) >> LOG_BYTES_IN_PAGE;
  VM_Address sp=allocSuperPage(pages);
  if (sp.isZero())   return sp;
  VM_Address cell=sp.add(header);
  Memory.zero(cell,VM_Extent.fromInt(bytes));
  return cell;
}

Fixed version (ground truth):
/** 
 * Allocate a large object.  Large objects are directly allocted and freed in page-grained units via the vm resource.  This routine returned zeroed memory.
 * @param isScalar True if the object to occupy this space will be a scalar.
 * @param bytes The required size of this space in bytes.
 * @param inGC If true, this allocation is occuring with respect toa space that is currently being collected.
 * @return The address of the start of the newly allocated region atleast <code>bytes</code> bytes in size.
 */
final protected VM_Address allocSlowOnce(boolean isScalar,int bytes,boolean inGC){
  int header=superPageHeaderSize() + cellHeaderSize();
  int pages=(bytes + header + BYTES_IN_PAGE - 1) >> LOG_BYTES_IN_PAGE;
  VM_Address sp=allocSuperPage(pages);
  if (sp.isZero())   return sp;
  VM_Address cell=sp.add(header);
  Memory.zero(cell,VM_Extent.fromIntZeroExtend(bytes));
  return cell;
}
Program: 150272
Project: 150272
Buggy source:
private static long getAddressValue(VM_Address addr,String msg,boolean warn){
  if (addr == null)   return 0L;
  long value=addr.toLong();
  if (warn)   check((int)value,msg);
  return value;
}

Fixed version (ground truth):
private static long getAddressValue(Object addr,String msg,boolean warn){
  if (addr == null)   return 0L;
  long value=0L;
  if (addr instanceof VM_Address) {
    value=((VM_Address)addr).toLong();
  }
 else   if (addr instanceof VM_Word) {
    value=((VM_Word)addr).toLong();
  }
 else   if (addr instanceof VM_Extent) {
    value=((VM_Extent)addr).toLong();
  }
 else   if (addr instanceof VM_Offset) {
    value=((VM_Offset)addr).toLong();
  }
 else {
    VM.sysWriteln("String_Node_Str" + addr);
    VM.sysFail("String_Node_Str");
  }
  if (warn)   check((int)value,msg);
  return value;
}
Program: 150277
Project: 150277
Buggy source:
/** 
 * Prepare for a collection.
 */
protected final void prepare(){
  long start=VM_Interface.cycles();
  int order=VM_Interface.rendezvous(4230);
  if (order == 1) {
    setGcStatus(GC_PREPARE);
    baseGlobalPrepare(start);
  }
  VM_Interface.rendezvous(4240);
  if (order == 1)   for (int i=0; i < planCount; i++) {
    Plan p=plans[i];
    if (VM_Interface.isNonParticipating(p))     p.baseThreadLocalPrepare(NON_PARTICIPANT);
  }
  baseThreadLocalPrepare(order);
  if (order == 1) {
    VM_Interface.resetThreadCounter();
    setGcStatus(GC_PROPER);
  }
  VM_Interface.rendezvous(4250);
  if (Plan.MOVES_OBJECTS) {
    VM_Interface.preCopyGCInstances();
    VM_Interface.rendezvous(4260);
    if (order == 1)     VM_Interface.resetThreadCounter();
    VM_Interface.rendezvous(4270);
  }
}

Fixed version (ground truth):
/** 
 * Prepare for a collection.
 */
protected final void prepare(){
  long start=VM_Interface.cycles();
  int order=VM_Interface.rendezvous(4230);
  if (order == 1) {
    setGcStatus(GC_PREPARE);
    baseGlobalPrepare(start);
  }
  VM_Interface.rendezvous(4240);
  if (order == 1)   for (int i=0; i < planCount; i++) {
    Plan p=plans[i];
    if (VM_Interface.isNonParticipating(p))     p.baseThreadLocalPrepare(NON_PARTICIPANT);
  }
  baseThreadLocalPrepare(order);
  VM_Interface.rendezvous(4250);
  if (Plan.MOVES_OBJECTS) {
    VM_Interface.preCopyGCInstances();
    VM_Interface.rendezvous(4260);
    if (order == 1)     VM_Interface.resetThreadCounter();
    VM_Interface.rendezvous(4270);
  }
}