nus-yam/ex-repair huggingface dataset:
Program: 149968
Project: 149968
Buggy source:
/** 
 * Return the space into which an allocator is allocating.  This particular method will match against those spaces defined at this level of the class hierarchy.  Subclasses must deal with spaces they define and refer to superclasses appropriately.  This exists to support   {@link org.mmtk.plan.CollectorContext#getOwnAllocator(Allocator)}.
 * @see org.mmtk.plan.CollectorContext#getOwnAllocator(Allocator)
 * @param a An allocator
 * @return The space into which <code>a</code> is allocating, or<code>null</code> if there is no space associated with <code>a</code>.
 */
public final Space getSpaceFromAllocator(Allocator a){
  if (a == nursery)   return GenRC.nurserySpace;
  return super.getSpaceFromAllocator(a);
}

Fixed version (ground truth):
/** 
 * Return the space into which an allocator is allocating.  This particular method will match against those spaces defined at this level of the class hierarchy.  Subclasses must deal with spaces they define and refer to superclasses appropriately.  This exists to support   {@link org.mmtk.plan.MutatorContext#getOwnAllocator(Allocator)}.
 * @see org.mmtk.plan.MutatorContext#getOwnAllocator(Allocator)
 * @param a An allocator
 * @return The space into which <code>a</code> is allocating, or<code>null</code> if there is no space associated with <code>a</code>.
 */
public final Space getSpaceFromAllocator(Allocator a){
  if (a == nursery)   return GenRC.nurserySpace;
  return super.getSpaceFromAllocator(a);
}
Program: 149969
Project: 149969
Buggy source:
/** 
 * Constructor
 * @param name The name of the underlying deque.
 * @param trace The shared deque that is used.
 */
public ObjectReferenceBuffer(String name,SharedDeque queue){
  values=new ObjectReferenceDeque(name,queue);
  queue.newConsumer();
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param name The name of the underlying deque.
 * @param queue The shared deque that is used.
 */
public ObjectReferenceBuffer(String name,SharedDeque queue){
  values=new ObjectReferenceDeque(name,queue);
  queue.newConsumer();
}
Program: 149970
Project: 149970
Buggy source:
/** 
 * Force the resolution of the type reference. May cause class loading if a required class file hasn't been loaded before.
 * @return the VM_Type instance that this references resolves to.
 * @throws NoClassDefFoundError When it cannot resolve a class.  we go to the trouble of converting the class loader's <code>ClassNotFoundException</code> into this error,  since we need to be able to throw  <code>NoClassDefFoundError</code> for classes that we're loading whose existence was compile-time checked.
 * @throws IllegalArgumentException In case of a malformed class name(should never happen, since the right thing to do is probably to validate them as soon as we insert them into a VM_TypeReference. This stinks. XXX)
 */
public final synchronized VM_Type resolve() throws NoClassDefFoundError, IllegalArgumentException {
  if (resolvedType != null)   return resolvedType;
  if (isClassType()) {
    VM_Type ans;
    if (VM.runningVM) {
      Class klass;
      String myName=name.classNameFromDescriptor();
      try {
        klass=classloader.loadClass(myName);
      }
 catch (      ClassNotFoundException cnf) {
        NoClassDefFoundError ncdfe=new NoClassDefFoundError("String_Node_Str" + myName + "String_Node_Str"+ cnf.getMessage());
        ncdfe.initCause(cnf);
        throw ncdfe;
      }
      ans=java.lang.JikesRVMSupport.getTypeForClass(klass);
    }
 else {
      ans=((VM_BootstrapClassLoader)classloader).loadVMClass(name.classNameFromDescriptor());
    }
    if (VM.VerifyAssertions)     VM._assert(resolvedType == null || resolvedType == ans);
    resolvedType=ans;
  }
 else   if (isArrayType()) {
    if (isWordArrayType() || isCodeArrayType()) {
      resolvedType=getArrayElementType().getArrayTypeForElementType().resolve();
    }
 else {
      VM_Type elementType=getArrayElementType().resolve();
      if (elementType.getClassLoader() != classloader) {
        VM_TypeReference canonical=VM_TypeReference.findOrCreate(elementType.getClassLoader(),name);
        resolvedType=canonical.resolve();
      }
 else {
        resolvedType=new VM_Array(this,elementType);
      }
    }
  }
 else {
    resolvedType=new VM_Primitive(this);
  }
  return resolvedType;
}

Fixed version (ground truth):
/** 
 * Force the resolution of the type reference. May cause class loading if a required class file hasn't been loaded before.
 * @return the VM_Type instance that this references resolves to.
 * @throws NoClassDefFoundError When it cannot resolve a class.  we go to the trouble of converting the class loader's <code>ClassNotFoundException</code> into this error,  since we need to be able to throw  <code>NoClassDefFoundError</code> for classes that we're loading whose existence was compile-time checked.
 * @throws IllegalArgumentException In case of a malformed class name(should never happen, since the right thing to do is probably to validate them as soon as we insert them into a VM_TypeReference. This stinks. XXX)
 */
public final VM_Type resolve() throws NoClassDefFoundError, IllegalArgumentException {
synchronized (classloader) {
    return resolveInternal();
  }
}
Program: 149971
Project: 149971
Buggy source:
/** 
 * When an exception occurs, registers are saved temporarily.  If the stack being scanned is in this state, we need to scan those registers for code pointers.  If the codeLocations deque is null, then scanning for code pointers is not required, so we don't need to do anything. (SB: Why only code pointers?)
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void getHWExceptionRegisters(int verbosity){
  if (processCodeLocations && thread.hardwareExceptionRegisters.inuse) {
    Address ip=thread.hardwareExceptionRegisters.ip;
    VM_CompiledMethod compiledMethod=VM_CompiledMethods.findMethodForInstruction(ip);
    if (VM.VerifyAssertions) {
      VM._assert(compiledMethod != null);
      VM._assert(compiledMethod.containsReturnAddress(ip));
    }
    compiledMethod.setObsolete(false);
    ObjectReference code=ObjectReference.fromObject(compiledMethod.getEntryCodeArray());
    Address ipLoc=thread.hardwareExceptionRegisters.getIPLocation();
    if (VM.VerifyAssertions)     VM._assert(ip == ipLoc.loadAddress());
    codeLocationsPush(code,ipLoc);
  }
}

Fixed version (ground truth):
/** 
 * When an exception occurs, registers are saved temporarily.  If the stack being scanned is in this state, we need to scan those registers for code pointers.  If the codeLocations deque is null, then scanning for code pointers is not required, so we don't need to do anything. (SB: Why only code pointers?)
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void getHWExceptionRegisters(int verbosity){
  if (processCodeLocations && thread.hardwareExceptionRegisters.inuse) {
    Address ip=thread.hardwareExceptionRegisters.ip;
    VM_CompiledMethod compiledMethod=VM_CompiledMethods.findMethodForInstruction(ip);
    if (VM.VerifyAssertions) {
      VM._assert(compiledMethod != null);
      VM._assert(compiledMethod.containsReturnAddress(ip));
    }
    compiledMethod.setActiveOnStack();
    ObjectReference code=ObjectReference.fromObject(compiledMethod.getEntryCodeArray());
    Address ipLoc=thread.hardwareExceptionRegisters.getIPLocation();
    if (VM.VerifyAssertions)     VM._assert(ip == ipLoc.loadAddress());
    codeLocationsPush(code,ipLoc);
  }
}
Program: 149972
Project: 149972
Buggy source:
/** 
 * Set up to scan the current stack frame.  This means examining the frame to discover the method being invoked and then retrieving the associated metadata (stack maps etc).  Certain frames should not be scanned---these are identified and skipped.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 * @return True if the frame should be scanned, false if it shouldbe skipped.
 */
private boolean setUpFrame(int verbosity){
  int compiledMethodId=VM_Magic.getCompiledMethodID(fp);
  if (compiledMethodId == VM_Constants.INVISIBLE_METHOD_ID) {
    if (verbosity >= 1)     Log.writeln("String_Node_Str");
    return false;
  }
  compiledMethod=VM_CompiledMethods.getCompiledMethod(compiledMethodId);
  compiledMethod.setObsolete(false);
  compiledMethodType=compiledMethod.getCompilerType();
  if (verbosity >= 1)   printMethodHeader();
  Offset offset=compiledMethod.getInstructionOffset(ip);
  iterator=iteratorGroup.selectIterator(compiledMethod);
  iterator.setupIterator(compiledMethod,offset,fp);
  if (verbosity >= 2)   dumpStackFrame(verbosity);
  if (verbosity >= 3)   Log.writeln("String_Node_Str");
  return true;
}

Fixed version (ground truth):
/** 
 * Set up to scan the current stack frame.  This means examining the frame to discover the method being invoked and then retrieving the associated metadata (stack maps etc).  Certain frames should not be scanned---these are identified and skipped.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 * @return True if the frame should be scanned, false if it shouldbe skipped.
 */
private boolean setUpFrame(int verbosity){
  int compiledMethodId=VM_Magic.getCompiledMethodID(fp);
  if (compiledMethodId == VM_Constants.INVISIBLE_METHOD_ID) {
    if (verbosity >= 1)     Log.writeln("String_Node_Str");
    return false;
  }
  compiledMethod=VM_CompiledMethods.getCompiledMethod(compiledMethodId);
  compiledMethod.setActiveOnStack();
  compiledMethodType=compiledMethod.getCompilerType();
  if (verbosity >= 1)   printMethodHeader();
  Offset offset=compiledMethod.getInstructionOffset(ip);
  iterator=iteratorGroup.selectIterator(compiledMethod);
  iterator.setupIterator(compiledMethod,offset,fp);
  if (verbosity >= 2)   dumpStackFrame(verbosity);
  if (verbosity >= 3)   Log.writeln("String_Node_Str");
  return true;
}
Program: 149978
Project: 149978
Buggy source:
/** 
 * Mark the compiled method as obsolete (ie a candidate for eventual GC)
 */
public final void setObsolete(boolean sense) throws UninterruptiblePragma {
  if (sense) {
    bitField1|=OBSOLETE;
  }
 else {
    bitField1&=~OBSOLETE;
  }
}

Fixed version (ground truth):
/** 
 * Mark the compiled method as obsolete (ie a candidate for eventual GC)
 */
public final void setObsolete() throws UninterruptiblePragma {
  bitField1|=OBSOLETE;
}
Program: 149979
Project: 149979
Buggy source:
public static synchronized void setCompiledMethodObsolete(VM_CompiledMethod compiledMethod){
  if (compiledMethod.isObsolete())   return;
  int cmid=compiledMethod.getId();
  if (compiledMethod.getMethod().getDeclaringClass().isJavaLangObjectType())   return;
  if (VM.VerifyAssertions)   VM._assert(compiledMethods[cmid] != null);
  if (obsoleteMethods == null) {
    obsoleteMethods=new int[100];
  }
 else   if (obsoleteMethodCount >= obsoleteMethods.length) {
    int newArray[]=new int[obsoleteMethods.length * 2];
    VM.disableGC();
    for (int i=0, n=obsoleteMethods.length; i < n; ++i) {
      newArray[i]=obsoleteMethods[i];
    }
    VM.enableGC();
    obsoleteMethods=newArray;
  }
  compiledMethod.setObsolete(true);
  obsoleteMethods[obsoleteMethodCount++]=cmid;
}

Fixed version (ground truth):
public static void setCompiledMethodObsolete(VM_CompiledMethod compiledMethod){
  if (compiledMethod.getMethod().getDeclaringClass().isJavaLangObjectType())   return;
  compiledMethod.setObsolete();
  VM_Magic.sync();
  scanForObsoleteMethods=true;
}
Program: 149980
Project: 149980
Buggy source:
public synchronized static void snipObsoleteCompiledMethods(){
  if (obsoleteMethods == null)   return;
  int oldCount=obsoleteMethodCount;
  obsoleteMethodCount=0;
  for (int i=0; i < oldCount; i++) {
    int currCM=obsoleteMethods[i];
    if (compiledMethods[currCM].isObsolete()) {
      compiledMethods[currCM]=null;
    }
 else {
      obsoleteMethods[obsoleteMethodCount++]=currCM;
      compiledMethods[currCM].setObsolete(true);
    }
  }
}

Fixed version (ground truth):
public static void snipObsoleteCompiledMethods(){
  VM_Magic.isync();
  if (!scanForObsoleteMethods)   return;
  scanForObsoleteMethods=false;
  VM_Magic.sync();
  int max=numCompiledMethods();
  for (int i=0; i < numCompiledMethods(); i++) {
    VM_CompiledMethod cm=compiledMethods[i];
    if (cm != null) {
      if (cm.isActiveOnStack()) {
        if (cm.isObsolete()) {
          scanForObsoleteMethods=true;
          VM_Magic.sync();
        }
        cm.clearActiveOnStack();
      }
 else {
        if (cm.isObsolete()) {
          compiledMethods[i]=null;
        }
      }
    }
  }
}
Program: 149981
Project: 149981
Buggy source:
/** 
 * Scan the current stack frame.<p> First the various iterators are set up, then the frame is scanned for regular pointers, before scanning for code pointers.  The iterators are then cleaned up, and native frames skipped if necessary.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private Address scanFrame(int verbosity){
  if (!setUpFrame(verbosity))   return fp;
  scanFrameForObjects(verbosity);
  if (processCodeLocations)   processFrameForCode(verbosity);
  iterator.cleanupPointers();
  if (compiledMethod.getMethod().getDeclaringClass().isBridgeFromNative()) {
    fp=VM_Runtime.unwindNativeStackFrameForGC(fp);
    if (verbosity >= 1)     Log.write("String_Node_Str");
  }
  return fp;
}

Fixed version (ground truth):
/** 
 * Scan the current stack frame.<p> First the various iterators are set up, then the frame is scanned for regular pointers, before scanning for code pointers.  The iterators are then cleaned up, and native frames skipped if necessary.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private Address scanFrame(int verbosity){
  if (!setUpFrame(verbosity))   return fp;
  scanFrameForObjects(verbosity);
  if (processCodeLocations && compiledMethodType != VM_CompiledMethod.TRAP)   processFrameForCode(verbosity);
  iterator.cleanupPointers();
  if (compiledMethodType != VM_CompiledMethod.TRAP && compiledMethod.getMethod().getDeclaringClass().isBridgeFromNative()) {
    fp=VM_Runtime.unwindNativeStackFrameForGC(fp);
    if (verbosity >= 1)     Log.write("String_Node_Str");
  }
  return fp;
}
Program: 149982
Project: 149982
Buggy source:
/** 
 * Check that a reference encountered during scanning is valid.  If the reference is invalid, dump stack and die.
 * @param refaddr The address of the reference in question.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void checkReference(Address refaddr,int verbosity){
  ObjectReference ref=refaddr.loadObjectReference();
  if (!MM_Interface.validRef(ref)) {
    Log.write("String_Node_Str");
    printMethodHeader();
    Log.write(refaddr);
    Log.write("String_Node_Str");
    MM_Interface.dumpRef(ref);
    dumpStackFrame(verbosity);
    Log.write("String_Node_Str");
    VM_Scheduler.dumpStack(ip,fp);
    Address top_ip=thread.contextRegisters.getInnermostInstructionAddress();
    Address top_fp=thread.contextRegisters.getInnermostFramePointer();
    VM_Scheduler.dumpStack(top_ip,top_fp);
    VM.sysFail("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Check that a reference encountered during scanning is valid.  If the reference is invalid, dump stack and die.
 * @param refaddr The address of the reference in question.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void checkReference(Address refaddr,int verbosity){
  ObjectReference ref=refaddr.loadObjectReference();
  if (!MM_Interface.validRef(ref)) {
    Log.writeln();
    Log.writeln("String_Node_Str");
    printMethodHeader();
    Log.write(refaddr);
    Log.write("String_Node_Str");
    Log.flush();
    MM_Interface.dumpRef(ref);
    dumpStackFrame(verbosity);
    Log.writeln();
    Log.writeln("String_Node_Str");
    VM_Scheduler.dumpStack(ip,fp);
    Address top_ip=thread.contextRegisters.getInnermostInstructionAddress();
    Address top_fp=thread.contextRegisters.getInnermostFramePointer();
    VM_Scheduler.dumpStack(top_ip,top_fp);
    VM.sysFail("String_Node_Str");
  }
}
Program: 149983
Project: 149983
Buggy source:
/** 
 * Dump the contents of a stack frame. Attempts to interpret each word as an object reference
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void dumpStackFrame(int verbosity){
  Address start, end;
  if (VM.BuildForIA32) {
    if (prevFp.isZero()) {
      start=fp.minus(20 * BYTES_IN_ADDRESS);
      Log.writeln("String_Node_Str",fp);
    }
 else {
      start=prevFp;
    }
    end=fp;
  }
 else {
    start=fp;
    end=fp.loadAddress();
  }
  for (Address loc=start; loc.LT(end); loc=loc.plus(BYTES_IN_ADDRESS)) {
    Log.write(loc);
    Log.write("String_Node_Str");
    Log.write(loc.diff(start));
    Log.write("String_Node_Str");
    ObjectReference value=loc.loadObjectReference();
    Log.write(value);
    Log.write("String_Node_Str");
    Log.flush();
    if (verbosity >= 3 && MM_Interface.objectInVM(value) && loc.NE(start) && loc.NE(end))     MM_Interface.dumpRef(value);
 else     Log.write("String_Node_Str");
  }
  Log.write("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Dump the contents of a stack frame. Attempts to interpret each word as an object reference
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void dumpStackFrame(int verbosity){
  Address start, end;
  if (VM.BuildForIA32) {
    if (prevFp.isZero()) {
      start=fp.minus(20 * BYTES_IN_ADDRESS);
      Log.writeln("String_Node_Str",fp);
    }
 else {
      start=prevFp;
    }
    end=fp;
  }
 else {
    start=fp;
    end=fp.loadAddress();
  }
  for (Address loc=start; loc.LT(end); loc=loc.plus(BYTES_IN_ADDRESS)) {
    Log.write(loc);
    Log.write("String_Node_Str");
    Log.write(loc.diff(start));
    Log.write("String_Node_Str");
    ObjectReference value=loc.loadObjectReference();
    Log.write(value);
    Log.write("String_Node_Str");
    Log.flush();
    if (verbosity >= 3 && MM_Interface.objectInVM(value) && loc.NE(start) && loc.NE(end))     MM_Interface.dumpRef(value);
 else     Log.writeln();
  }
  Log.writeln();
}
Program: 149984
Project: 149984
Buggy source:
/** 
 * Set up to scan the current stack frame.  This means examining the frame to discover the method being invoked and then retrieving the associated metadata (stack maps etc).  Certain frames should not be scanned---these are identified and skipped.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 * @return True if the frame should be scanned, false if it shouldbe skipped.
 */
private boolean setUpFrame(int verbosity){
  int compiledMethodId=VM_Magic.getCompiledMethodID(fp);
  if (compiledMethodId == VM_Constants.INVISIBLE_METHOD_ID) {
    if (verbosity >= 1)     Log.writeln("String_Node_Str");
    return false;
  }
  compiledMethod=VM_CompiledMethods.getCompiledMethod(compiledMethodId);
  compiledMethod.setObsolete(false);
  compiledMethodType=compiledMethod.getCompilerType();
  if (verbosity >= 1)   printMethodHeader();
  if (compiledMethodType == VM_CompiledMethod.TRAP)   return false;
  Offset offset=compiledMethod.getInstructionOffset(ip);
  iterator=iteratorGroup.selectIterator(compiledMethod);
  iterator.setupIterator(compiledMethod,offset,fp);
  if (verbosity >= 2)   dumpStackFrame(verbosity);
  if (verbosity >= 3)   Log.writeln("String_Node_Str");
  return true;
}

Fixed version (ground truth):
/** 
 * Set up to scan the current stack frame.  This means examining the frame to discover the method being invoked and then retrieving the associated metadata (stack maps etc).  Certain frames should not be scanned---these are identified and skipped.
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 * @return True if the frame should be scanned, false if it shouldbe skipped.
 */
private boolean setUpFrame(int verbosity){
  int compiledMethodId=VM_Magic.getCompiledMethodID(fp);
  if (compiledMethodId == VM_Constants.INVISIBLE_METHOD_ID) {
    if (verbosity >= 1)     Log.writeln("String_Node_Str");
    return false;
  }
  compiledMethod=VM_CompiledMethods.getCompiledMethod(compiledMethodId);
  compiledMethod.setObsolete(false);
  compiledMethodType=compiledMethod.getCompilerType();
  if (verbosity >= 1)   printMethodHeader();
  Offset offset=compiledMethod.getInstructionOffset(ip);
  iterator=iteratorGroup.selectIterator(compiledMethod);
  iterator.setupIterator(compiledMethod,offset,fp);
  if (verbosity >= 2)   dumpStackFrame(verbosity);
  if (verbosity >= 3)   Log.writeln("String_Node_Str");
  return true;
}
Program: 149985
Project: 149985
Buggy source:
public Address getNextReturnAddressAddress(){
  if (mapId >= 0) {
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapId);
      VM.sysWrite("String_Node_Str");
    }
    return Address.zero();
  }
  mapIndex=maps.getNextJSRReturnAddrIndex(mapIndex);
  if (VM.TraceStkMaps) {
    VM.sysWrite("String_Node_Str");
    VM.sysWrite(mapIndex);
    VM.sysWrite("String_Node_Str");
  }
  if (mapIndex == VM_QuickReferenceMaps.NOMORE) {
    return Address.zero();
  }
 else {
    int location=maps.getLocation(mapId,mapIndex);
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(location);
      VM.sysWriteln();
    }
    if (VM_QuickCompiler.isRegister(location))     return registerLocations.get(VM_QuickCompiler.locationToRegister(location)).toAddress();
 else     return framePtr.add(VM_QuickCompiler.locationToOffset(location));
  }
}

Fixed version (ground truth):
public Address getNextReturnAddressAddress(){
  if (mapId >= 0) {
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(mapId);
      VM.sysWrite("String_Node_Str");
    }
    return Address.zero();
  }
  mapIndex=maps.getNextJSRReturnAddrIndex(mapIndex);
  if (VM.TraceStkMaps) {
    VM.sysWrite("String_Node_Str");
    VM.sysWrite(mapIndex);
    VM.sysWrite("String_Node_Str");
  }
  if (mapIndex == VM_QuickReferenceMaps.NOMORE) {
    return Address.zero();
  }
 else {
    int location=maps.getLocation(mapId,mapIndex);
    if (VM.TraceStkMaps) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite(location);
      VM.sysWriteln();
    }
    if (VM_QuickCompiler.isRegister(location))     return registerLocations.get(VM_QuickCompiler.locationToRegister(location)).toAddress();
 else     return framePtr.plus(VM_QuickCompiler.locationToOffset(location));
  }
}
Program: 149986
Project: 149986
Buggy source:
private void updateCallerRegisterLocations(){
  Address addr=framePtr.add(VM_QuickCompiler.getCallerSaveOffset(currentMethod));
  for (int i=VM_QuickCompiler.min(maps.firstFixedLocalRegister,maps.firstFixedStackRegister); i <= VM_QuickCompiler.max(maps.lastFixedLocalRegister,maps.lastFixedStackRegister); i++) {
    registerLocations.set(i,addr);
    addr=addr.sub(4);
  }
  registerLocations.set(S1,addr);
  addr=addr.sub(4);
  registerLocations.set(S0,addr);
}

Fixed version (ground truth):
private void updateCallerRegisterLocations(){
  Address addr=framePtr.plus(VM_QuickCompiler.getCallerSaveOffset(currentMethod));
  for (int i=VM_QuickCompiler.min(maps.firstFixedLocalRegister,maps.firstFixedStackRegister); i <= VM_QuickCompiler.max(maps.lastFixedLocalRegister,maps.lastFixedStackRegister); i++) {
    registerLocations.set(i,addr);
    addr=addr.minus(4);
  }
  registerLocations.set(S1,addr);
  addr=addr.minus(4);
  registerLocations.set(S0,addr);
}
Program: 149988
Project: 149988
Buggy source:
public void reset(){
  mapIndex=VM_QuickReferenceMaps.STARTINDEX;
  state=CHECK_REFERENCE_STATE;
  checkSavedThisPtr=true;
  if (bridgeTarget != null) {
    bridgeParameterMappingRequired=true;
    bridgeParameterIndex=bridgeParameterInitialIndex;
    bridgeRegisterIndex=FIRST_VOLATILE_GPR;
    bridgeRegisterLocation=framePtr.loadAddress();
    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(){
  mapIndex=VM_QuickReferenceMaps.STARTINDEX;
  state=CHECK_REFERENCE_STATE;
  checkSavedThisPtr=true;
  if (bridgeTarget != null) {
    bridgeParameterMappingRequired=true;
    bridgeParameterIndex=bridgeParameterInitialIndex;
    bridgeRegisterIndex=FIRST_VOLATILE_GPR;
    bridgeRegisterLocation=framePtr.loadAddress();
    bridgeRegisterLocation=bridgeRegisterLocation.minus(8 * (LAST_NONVOLATILE_FPR - FIRST_VOLATILE_FPR + 1) + 4 * (LAST_NONVOLATILE_GPR - FIRST_VOLATILE_GPR + 1));
  }
}
Program: 149991
Project: 149991
Buggy source:
/** 
 * Pass control to a catch block.
 */
public void deliverException(VM_CompiledMethod compiledMethod,Address catchBlockInstructionAddress,Throwable exceptionObject,VM_Registers registers){
  Address fp=registers.getInnermostFramePointer();
  VM_NormalMethod method=(VM_NormalMethod)compiledMethod.getMethod();
  Address exceptionSlot=fp.add(VM_QuickCompiler.getExceptionObjectOffset(method));
  exceptionSlot.store(VM_Magic.objectAsAddress(exceptionObject));
  registers.ip=catchBlockInstructionAddress;
  VM.enableGC();
  if (VM.VerifyAssertions)   VM._assert(registers.inuse == true);
  registers.inuse=false;
  VM_Magic.restoreHardwareExceptionState(registers);
  if (VM.VerifyAssertions)   VM._assert(NOT_REACHED);
}

Fixed version (ground truth):
/** 
 * Pass control to a catch block.
 */
public void deliverException(VM_CompiledMethod compiledMethod,Address catchBlockInstructionAddress,Throwable exceptionObject,VM_Registers registers){
  Address fp=registers.getInnermostFramePointer();
  VM_NormalMethod method=(VM_NormalMethod)compiledMethod.getMethod();
  Address exceptionSlot=fp.plus(VM_QuickCompiler.getExceptionObjectOffset(method));
  exceptionSlot.store(VM_Magic.objectAsAddress(exceptionObject));
  registers.ip=catchBlockInstructionAddress;
  VM.enableGC();
  if (VM.VerifyAssertions)   VM._assert(registers.inuse == true);
  registers.inuse=false;
  VM_Magic.restoreHardwareExceptionState(registers);
  if (VM.VerifyAssertions)   VM._assert(NOT_REACHED);
}
Program: 149992
Project: 149992
Buggy source:
/** 
 * When an exception occurs, registers are saved temporarily.  If the stack being scanned is in this state, we need to scan those registers for code pointers.  If the codeLocations deque is null, then scanning for code pointers is not required, so we don't need to do anything. (SB: Why only code pointers?)
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void getHWExceptionRegisters(int verbosity){
  if (processCodeLocations && thread.hardwareExceptionRegisters.inuse) {
    Address ip=thread.hardwareExceptionRegisters.ip;
    VM_CompiledMethod compiledMethod=VM_CompiledMethods.findMethodForInstruction(ip);
    if (VM.VerifyAssertions)     VM._assert(compiledMethod != null);
    compiledMethod.setObsolete(false);
    ObjectReference code=ObjectReference.fromObject(compiledMethod.getEntryCodeArray());
    Address ipLoc=thread.hardwareExceptionRegisters.getIPLocation();
    codeLocationsPush(code,ipLoc);
  }
}

Fixed version (ground truth):
/** 
 * When an exception occurs, registers are saved temporarily.  If the stack being scanned is in this state, we need to scan those registers for code pointers.  If the codeLocations deque is null, then scanning for code pointers is not required, so we don't need to do anything. (SB: Why only code pointers?)
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void getHWExceptionRegisters(int verbosity){
  if (processCodeLocations && thread.hardwareExceptionRegisters.inuse) {
    Address ip=thread.hardwareExceptionRegisters.ip;
    VM_CompiledMethod compiledMethod=VM_CompiledMethods.findMethodForInstruction(ip);
    if (VM.VerifyAssertions) {
      VM._assert(compiledMethod != null);
      VM._assert(compiledMethod.containsReturnAddress(ip));
    }
    compiledMethod.setObsolete(false);
    ObjectReference code=ObjectReference.fromObject(compiledMethod.getEntryCodeArray());
    Address ipLoc=thread.hardwareExceptionRegisters.getIPLocation();
    if (VM.VerifyAssertions)     VM._assert(ip == ipLoc.loadAddress());
    codeLocationsPush(code,ipLoc);
  }
}
Program: 149993
Project: 149993
Buggy source:
/** 
 * Find the method whose machine code contains the specified instruction. Assumption: caller has disabled gc (otherwise collector could move objects without fixing up the raw <code>ip</code> pointer) Note: this method is highly inefficient. Normally you should use the following instead:  <code> VM_ClassLoader.getCompiledMethod(VM_Magic.getCompiledMethodID(fp)) </code>
 * @param ip  instruction addressUsage note: <code>ip</code> must point to the instruction *following* the actual instruction whose method is sought. This allows us to properly handle the case where the only address we have to work with is a return address (ie. from a stackframe) or an exception address (ie. from a null pointer dereference, array bounds check, or divide by zero) on a machine architecture with variable length instructions.  In such situations we'd have no idea how far to back up the instruction pointer to point to the "call site" or "exception site".
 * @return method (<code>null</code> --> not found)
 */
public static VM_CompiledMethod findMethodForInstruction(Address ip) throws UninterruptiblePragma {
  for (int i=0, n=numCompiledMethods(); i < n; ++i) {
    VM_CompiledMethod compiledMethod=compiledMethods[i];
    if (compiledMethod == null || !compiledMethod.isCompiled())     continue;
    if (compiledMethod.containsReturnAddress(ip))     return compiledMethod;
    return compiledMethod;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Find the method whose machine code contains the specified instruction. Assumption: caller has disabled gc (otherwise collector could move objects without fixing up the raw <code>ip</code> pointer) Note: this method is highly inefficient. Normally you should use the following instead:  <code> VM_ClassLoader.getCompiledMethod(VM_Magic.getCompiledMethodID(fp)) </code>
 * @param ip  instruction addressUsage note: <code>ip</code> must point to the instruction *following* the actual instruction whose method is sought. This allows us to properly handle the case where the only address we have to work with is a return address (ie. from a stackframe) or an exception address (ie. from a null pointer dereference, array bounds check, or divide by zero) on a machine architecture with variable length instructions.  In such situations we'd have no idea how far to back up the instruction pointer to point to the "call site" or "exception site".
 * @return method (<code>null</code> --> not found)
 */
public static VM_CompiledMethod findMethodForInstruction(Address ip) throws UninterruptiblePragma {
  for (int i=0, n=numCompiledMethods(); i < n; ++i) {
    VM_CompiledMethod compiledMethod=compiledMethods[i];
    if (compiledMethod == null || !compiledMethod.isCompiled())     continue;
    if (compiledMethod.containsReturnAddress(ip))     return compiledMethod;
  }
  return null;
}
Program: 149997
Project: 149997
Buggy source:
public static void main(String args[]) throws Exception {
  tField t=new tField();
  Class tf_type=Class.forName("String_Node_Str");
  Field fields[]=tf_type.getFields();
  Arrays.sort(fields,new Comparator(){
    public int compare(    Object x,    Object y){
      return x.toString().compareTo(y.toString());
    }
  }
);
  t.printFields(fields);
  t.testBoolean(fields);
  t.testByte(fields);
  t.testShort(fields);
  t.testInt(fields);
  t.testLong(fields);
  t.testFloat(fields);
  t.testDouble(fields);
  t.printFields(fields);
}

Fixed version (ground truth):
public static void main(String args[]) throws Exception {
  tField t=new tField();
  Class tf_type=Class.forName("String_Node_Str");
  Field fields[]=tf_type.getFields();
  Arrays.sort(fields,new Comparator(){
    public int compare(    Object x,    Object y){
      return x.toString().compareTo(y.toString());
    }
  }
);
  t.printFields(fields);
  t.testBoolean(fields);
  t.testByte(fields);
  t.testShort(fields);
  t.testInt(fields);
  t.testLong(fields);
  t.testFloat(fields);
  t.testDouble(fields);
  t.printFields(fields);
  t.testType("String_Node_Str",boolean.class);
  t.testType("String_Node_Str",byte.class);
  t.testType("String_Node_Str",short.class);
  t.testType("String_Node_Str",int.class);
  t.testType("String_Node_Str",long.class);
  t.testType("String_Node_Str",float.class);
  t.testType("String_Node_Str",double.class);
  t.testType("String_Node_Str",boolean.class);
  t.testType("String_Node_Str",byte.class);
  t.testType("String_Node_Str",short.class);
  t.testType("String_Node_Str",int.class);
  t.testType("String_Node_Str",long.class);
  t.testType("String_Node_Str",float.class);
  t.testType("String_Node_Str",double.class);
}
Program: 149999
Project: 149999
Buggy source:
/** 
 * Dump the contents of a stack frame. Attempts to interpret each word as an object reference
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void dumpStackFrame(int verbosity){
  Address start, end;
  if (VM.BuildForIA32) {
    if (prevFp.isZero()) {
      start=fp.minus(20 * BYTES_IN_ADDRESS);
      Log.writeln("String_Node_Str",fp);
    }
 else {
      start=prevFp;
    }
    end=fp;
  }
 else {
    start=fp;
    end=fp.loadAddress();
  }
  for (Address loc=start; loc.LT(end); loc=loc.plus(BYTES_IN_ADDRESS)) {
    Log.write(loc);
    Log.write("String_Node_Str");
    Log.write(loc.diff(start));
    ObjectReference value=loc.loadObjectReference();
    Log.write("String_Node_Str");
    Log.write(value);
    Log.write("String_Node_Str");
    if (verbosity >= 3 && MM_Interface.objectInVM(value) && loc.NE(start) && loc.NE(end))     MM_Interface.dumpRef(value);
 else     Log.write("String_Node_Str");
  }
  Log.write("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Dump the contents of a stack frame. Attempts to interpret each word as an object reference
 * @param verbosity The level of verbosity to be used whenperforming the scan.
 */
private void dumpStackFrame(int verbosity){
  Address start, end;
  if (VM.BuildForIA32) {
    if (prevFp.isZero()) {
      start=fp.minus(20 * BYTES_IN_ADDRESS);
      Log.writeln("String_Node_Str",fp);
    }
 else {
      start=prevFp;
    }
    end=fp;
  }
 else {
    start=fp;
    end=fp.loadAddress();
  }
  for (Address loc=start; loc.LT(end); loc=loc.plus(BYTES_IN_ADDRESS)) {
    Log.write(loc);
    Log.write("String_Node_Str");
    Log.write(loc.diff(start));
    Log.write("String_Node_Str");
    ObjectReference value=loc.loadObjectReference();
    Log.write(value);
    Log.write("String_Node_Str");
    Log.flush();
    if (verbosity >= 3 && MM_Interface.objectInVM(value) && loc.NE(start) && loc.NE(end))     MM_Interface.dumpRef(value);
 else     Log.write("String_Node_Str");
  }
  Log.write("String_Node_Str");
}
Program: 150000
Project: 150000
Buggy source:
/** 
 * Push a code pointer location onto the code locations deque, optionally performing a sanity check first.<p>
 * @param code The code object into which this interior pointer points
 * @param ipLoc The location of the pointer into this code object
 */
private void codeLocationsPush(ObjectReference code,Address ipLoc) throws InlinePragma {
  if (VALIDATE_REFS) {
    Address ip=ipLoc.loadAddress();
    Offset offset=ip.diff(code.toAddress());
    if (offset.sLT(Offset.zero()) || offset.sGT(Offset.fromIntZeroExtend(1 << 24))) {
      Log.writeln("String_Node_Str");
      Log.write("String_Node_Str");
      Log.writeln(code);
      Log.write("String_Node_Str");
      Log.writeln(ip);
      Log.write("String_Node_Str");
      Log.writeln(offset);
      Log.write("String_Node_Str");
      Log.writeln(ipLoc);
      if (!failed)       failed=true;
    }
  }
  trace.addInteriorRootLocation(code,ipLoc);
}

Fixed version (ground truth):
/** 
 * Push a code pointer location onto the code locations deque, optionally performing a sanity check first.<p>
 * @param code The code object into which this interior pointer points
 * @param ipLoc The location of the pointer into this code object
 */
private void codeLocationsPush(ObjectReference code,Address ipLoc) throws InlinePragma {
  if (VALIDATE_REFS) {
    Address ip=ipLoc.loadAddress();
    Offset offset=ip.diff(code.toAddress());
    if (offset.sLT(Offset.zero()) || offset.sGT(Offset.fromIntZeroExtend(ObjectModel.getObjectSize(code)))) {
      Log.writeln("String_Node_Str");
      Log.write("String_Node_Str");
      Log.writeln(code);
      Log.write("String_Node_Str");
      Log.writeln(ip);
      Log.write("String_Node_Str");
      Log.writeln(offset);
      Log.write("String_Node_Str");
      Log.writeln(ipLoc);
      if (!failed)       failed=true;
    }
  }
  trace.addInteriorRootLocation(code,ipLoc);
}
Program: 150001
Project: 150001
Buggy source:
/** 
 * Check if object might be a TIB.
 * @param obj address of object to check
 * @return <code>false</code> if the object is in the wrongallocation scheme/area for a TIB, <code>true</code> otherwise
 */
public static boolean mightBeTIB(ObjectReference obj) throws InlinePragma, UninterruptiblePragma {
  return !obj.isNull() && Space.isImmortal(obj);
}

Fixed version (ground truth):
/** 
 * Check if object might be a TIB.
 * @param obj address of object to check
 * @return <code>false</code> if the object is in the wrongallocation scheme/area for a TIB, <code>true</code> otherwise
 */
public static boolean mightBeTIB(ObjectReference obj) throws InlinePragma, UninterruptiblePragma {
  return !obj.isNull() && Space.isMappedObject(obj) && Space.isImmortal(obj)&& Space.isMappedObject(ObjectReference.fromObject(VM_ObjectModel.getTIB(obj)));
}
Program: 150002
Project: 150002
Buggy source:
/** 
 * Internal allocation slow path.  This is called whenever the bump pointer reaches the internal limit.  The code is forced out of line.  If required we perform an external slow path take, which we inline into this method since this is already out of line.
 * @param start The start address for the pending allocation
 * @param end The end address for the pending allocation
 * @param align The requested alignment
 * @param offset The offset from the alignment 
 * @param inGC Is the allocation request occuring during GC.
 * @return The address of the first byte of the allocated region
 * @throws NoInlinePragma
 */
private final Address allocSlow(Address start,Address end,int align,int offset,boolean inGC) throws NoInlinePragma {
  Address rtn=null;
  Address card=null;
  if (SUPPORT_CARD_SCANNING)   getCard(start.plus(CARD_MASK));
  if (end.GT(limit)) {
    rtn=allocSlowInline(end.diff(start).toInt(),align,offset,inGC);
    if (SUPPORT_CARD_SCANNING && card.NE(getCard(rtn.plus(CARD_MASK))))     card=getCard(rtn);
  }
 else {
    while (internalLimit.LE(end))     internalLimit=internalLimit.plus(STEP_SIZE);
    if (internalLimit.GT(limit))     internalLimit=limit;
    fillAlignmentGap(cursor,start);
    cursor=end;
    rtn=start;
  }
  if (SUPPORT_CARD_SCANNING && !rtn.isZero())   createCardAnchor(card,rtn,end.diff(start).toInt());
  return rtn;
}

Fixed version (ground truth):
/** 
 * Internal allocation slow path.  This is called whenever the bump pointer reaches the internal limit.  The code is forced out of line.  If required we perform an external slow path take, which we inline into this method since this is already out of line.
 * @param start The start address for the pending allocation
 * @param end The end address for the pending allocation
 * @param align The requested alignment
 * @param offset The offset from the alignment 
 * @param inGC Is the allocation request occuring during GC.
 * @return The address of the first byte of the allocated region
 * @throws NoInlinePragma
 */
private final Address allocSlow(Address start,Address end,int align,int offset,boolean inGC) throws NoInlinePragma {
  Address rtn=null;
  Address card=null;
  if (SUPPORT_CARD_SCANNING)   card=getCard(start.plus(CARD_MASK));
  if (end.GT(limit)) {
    rtn=allocSlowInline(end.diff(start).toInt(),align,offset,inGC);
    if (SUPPORT_CARD_SCANNING && card.NE(getCard(rtn.plus(CARD_MASK))))     card=getCard(rtn);
  }
 else {
    while (internalLimit.LE(end))     internalLimit=internalLimit.plus(STEP_SIZE);
    if (internalLimit.GT(limit))     internalLimit=limit;
    fillAlignmentGap(cursor,start);
    cursor=end;
    rtn=start;
  }
  if (SUPPORT_CARD_SCANNING && !rtn.isZero())   createCardAnchor(card,rtn,end.diff(start).toInt());
  return rtn;
}
Program: 150003
Project: 150003
Buggy source:
/** 
 * Create a new Lock instance using the appropriate VM-specific concrete Lock sub-class.
 * @param name The string to be associated with this lock instance
 * @return A concrete VM-specific Lock instance.
 */
public static Lock newLock(String name){
  try {
    return (Lock)lockClass.newInstance();
  }
 catch (  Exception e) {
    assertions.fail("String_Node_Str");
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Create a new Lock instance using the appropriate VM-specific concrete Lock sub-class.
 * @param name The string to be associated with this lock instance
 * @return A concrete VM-specific Lock instance.
 */
public static Lock newLock(String name){
  Lock lock=null;
  try {
    lock=(Lock)lockClass.newInstance();
    lock.setName(name);
    return lock;
  }
 catch (  Exception e) {
    assertions.fail("String_Node_Str");
    return null;
  }
}
Program: 150004
Project: 150004
Buggy source:
/** 
 * Return a slot (location of an address) given an object address and a reference number.
 * @param object The address of an object
 * @param reference The number of a field in a scalar or the indexinto an array
 * @return The address of the relevant slot within the object
 */
Address getSlot(ObjectReference object,int reference) throws InlinePragma {
  Address addr=object.toAddress();
  if (isReferenceArray)   return addr.plus(arrayOffset).plus(reference << LOG_BYTES_IN_ADDRESS);
 else   return addr.plus(offsets[reference]);
}

Fixed version (ground truth):
/** 
 * Return a slot (location of an address) given an object address and a reference number.
 * @param object The address of an object
 * @param reference The number of a field in a scalar or the indexinto an array
 * @return The address of the relevant slot within the object
 */
Address getSlot(ObjectReference object,int reference) throws InlinePragma {
  Address addr=object.toAddress();
  if (isReferenceArray)   return addr.plus(VM.ARRAY_BASE_OFFSET).plus(reference << LOG_BYTES_IN_ADDRESS);
 else   return addr.plus(offsets[reference]);
}
Program: 150005
Project: 150005
Buggy source:
/** 
 * Check for memory exhaustion, possibly throwing an out of memory exception and/or triggering another GC.
 * @param why Why the collection was triggered
 * @param async True if this collection was asynchronously triggered.
 */
private static final void checkForExhaustion(int why,boolean async) throws LogicallyUninterruptiblePragma {
  double usage=Plan.reservedMemory().toLong() / ((double)Plan.totalMemory().toLong());
  if (usage > OUT_OF_MEMORY_THRESHOLD) {
    if (why == INTERNAL_GC_TRIGGER) {
      if (Options.verbose.getValue() >= 2) {
        VM.sysWriteln("String_Node_Str",usage);
        VM.sysWriteln("String_Node_Str",(long)(Plan.reservedMemory().toLong() / 1024));
        VM.sysWriteln("String_Node_Str",(long)(Plan.totalMemory().toLong() / 1024));
      }
      if (VM.debugOOM || Options.verbose.getValue() >= 5)       VM.sysWriteln("String_Node_Str");
      MM_Interface.emergencyGrowHeap(512 * (1 << 10));
      OutOfMemoryError oome=new OutOfMemoryError();
      MM_Interface.emergencyGrowHeap(-(512 * (1 << 10)));
      if (VM.debugOOM || Options.verbose.getValue() >= 5)       VM.sysWriteln("String_Node_Str");
      throw oome;
    }
    ReferenceProcessor.setClearSoftReferences(true);
    if (!async)     triggerCollection(INTERNAL_GC_TRIGGER);
  }
}

Fixed version (ground truth):
/** 
 * Check for memory exhaustion, possibly throwing an out of memory exception and/or triggering another GC.
 * @param why Why the collection was triggered
 * @param async True if this collection was asynchronously triggered.
 */
private static final void checkForExhaustion(int why,boolean async) throws LogicallyUninterruptiblePragma {
  double usage=Plan.reservedMemory().toLong() / ((double)Plan.totalMemory().toLong());
  if (usage > OUT_OF_MEMORY_THRESHOLD) {
    if (why == INTERNAL_GC_TRIGGER) {
      if (Options.verbose.getValue() >= 2) {
        VM.sysWriteln("String_Node_Str",usage);
        VM.sysWriteln("String_Node_Str",(long)(Plan.reservedMemory().toLong() / 1024));
        VM.sysWriteln("String_Node_Str",(long)(Plan.totalMemory().toLong() / 1024));
      }
      if (VM.debugOOM || Options.verbose.getValue() >= 5)       VM.sysWriteln("String_Node_Str");
      int currentAvail=ActivePlan.global().getPagesAvail() << LOG_BYTES_IN_PAGE;
      int headroom=OOM_EXN_HEADROOM_BYTES - currentAvail;
      MM_Interface.emergencyGrowHeap(headroom);
      OutOfMemoryError oome=new OutOfMemoryError();
      MM_Interface.emergencyGrowHeap(-headroom);
      if (VM.debugOOM || Options.verbose.getValue() >= 5)       VM.sysWriteln("String_Node_Str");
      throw oome;
    }
    ReferenceProcessor.setClearSoftReferences(true);
    if (!async)     triggerCollection(INTERNAL_GC_TRIGGER);
  }
}
Program: 150006
Project: 150006
Buggy source:
/** 
 * Write boot image to disk.
 * @param imageFileName the name of the image file
 */
public void write(String imageCodeFileName,String imageDataFileName,String imageRMapFileName) throws IOException {
  if (trace) {
    say((numObjects / 1024) + "String_Node_Str");
    say((numAddresses / 1024) + "String_Node_Str");
    say(numNulledReferences + "String_Node_Str" + "String_Node_Str");
    say((VM_Statics.getNumberOfSlots() / 1024) + "String_Node_Str");
    say((getDataSize() / 1024) + "String_Node_Str");
    say((getCodeSize() / 1024) + "String_Node_Str");
    say("String_Node_Str" + imageDataFileName);
  }
  FileOutputStream dataOut=new FileOutputStream(imageDataFileName);
  dataOut.write(bootImageData,0,getDataSize());
  dataOut.flush();
  dataOut.close();
  if (trace) {
    say("String_Node_Str" + imageCodeFileName);
  }
  FileOutputStream codeOut=new FileOutputStream(imageCodeFileName);
  codeOut.write(bootImageCode,0,getCodeSize());
  codeOut.flush();
  codeOut.close();
  if (trace) {
    say("String_Node_Str" + imageRMapFileName);
  }
  bootImageData=null;
  bootImageCode=null;
  System.gc();
  bootImageRMap=new byte[referenceMapReferences << BYTES_IN_WORD];
  rMapSize=org.mmtk.vm.ScanBootImage.encodeRMap(bootImageRMap,referenceMap,referenceMapLimit);
  FileOutputStream rmapOut=new FileOutputStream(imageRMapFileName);
  rmapOut.write(bootImageRMap,0,rMapSize);
  rmapOut.flush();
  rmapOut.close();
  if (trace) {
    say("String_Node_Str" + referenceMapReferences);
  }
  org.mmtk.vm.ScanBootImage.encodingStats();
}

Fixed version (ground truth):
/** 
 * Write boot image to disk.
 * @param imageFileName the name of the image file
 */
public void write(String imageCodeFileName,String imageDataFileName,String imageRMapFileName) throws IOException {
  if (trace) {
    say((numObjects / 1024) + "String_Node_Str");
    say((numAddresses / 1024) + "String_Node_Str");
    say(numNulledReferences + "String_Node_Str" + "String_Node_Str");
    say((VM_Statics.getNumberOfSlots() / 1024) + "String_Node_Str");
    say((getDataSize() / 1024) + "String_Node_Str");
    say((getCodeSize() / 1024) + "String_Node_Str");
    say("String_Node_Str" + imageDataFileName);
  }
  FileOutputStream dataOut=new FileOutputStream(imageDataFileName);
  dataOut.write(bootImageData,0,getDataSize());
  dataOut.flush();
  dataOut.close();
  if (trace) {
    say("String_Node_Str" + imageCodeFileName);
  }
  FileOutputStream codeOut=new FileOutputStream(imageCodeFileName);
  codeOut.write(bootImageCode,0,getCodeSize());
  codeOut.flush();
  codeOut.close();
  if (trace) {
    say("String_Node_Str" + imageRMapFileName);
  }
  bootImageData=null;
  bootImageCode=null;
  System.gc();
  bootImageRMap=new byte[referenceMapReferences << LOG_BYTES_IN_WORD];
  rMapSize=org.mmtk.vm.ScanBootImage.encodeRMap(bootImageRMap,referenceMap,referenceMapLimit);
  FileOutputStream rmapOut=new FileOutputStream(imageRMapFileName);
  rmapOut.write(bootImageRMap,0,rMapSize);
  rmapOut.flush();
  rmapOut.close();
  if (trace) {
    say("String_Node_Str" + referenceMapReferences);
  }
  org.mmtk.vm.ScanBootImage.encodingStats();
}