if (debug) { showInfo(); VM.sysWrite(" VM_ReferenceMaps-locateGCPoint located index  = "); VM.sysWrite(index); VM.sysWrite("  byte  = "); VM.sysWrite(referenceMaps[index]); VM.sysWrite( "\n");
if (VM.TraceStkMaps) { showInfo(); VM.sysWrite(" VM_ReferenceMaps-locateGCPoint located index  = "); VM.sysWrite(index); VM.sysWrite("  byte  = "); VM.sysWrite(referenceMaps[index]); VM.sysWrite( "\n"); if (index - 1 >= 0) { VM.sysWrite(" MCSites[index-1] = "); VM.sysWrite(machCodeOffset - MCSites[index-1]); VM.sysWrite("\n"); } VM.sysWrite(" MCSites[index  ] = "); VM.sysWrite(machCodeOffset - MCSites[index  ]); VM.sysWrite("\n"); if (index + 1 < MCSites.length) { VM.sysWrite(" MCSites[index+1] = "); VM.sysWrite(machCodeOffset - MCSites[index+1]); VM.sysWrite("\n"); }
  locateGCPoint(int machCodeOffset, VM_Method method) {   machCodeOffset = machCodeOffset - (1 << VM.LG_INSTRUCTION_WIDTH);  // this assumes that machCodeOffset points                                        // to "next" instruction eg bal type instruction    if (VM.TraceStkMaps)      {      VM.sysWrite("VM_ReferenceMaps-locateGCPoint for machine code offset = ");      VM.sysWrite(machCodeOffset);      VM.sysWrite("  --- in  method = ");      VM.sysWrite(method.getName());      VM.sysWrite("\n");      }    // test if maps are to be build dynamically    if(VM.DynamicReferenceMaps) {      if (VM.TraceStkMaps) {	VM.sysWrite("VM_ReferenceMaps-locateGCPoint.  doing dynamic reference maps\n");	VM.sysWrite("   bytesPerMap = ");	VM.sysWrite( bytesPerMap);	VM.sysWrite("   bitsPerMap = ");	VM.sysWrite( bitsPerMap);      }      // test if they have been built previously and we have cached this site      if (cacheMCSite != machCodeOffset) {	// tracing and statistics	if (VM.TraceTimes) VM_Timer.start(VM_Timer.REFERENCEMAP_GEN);	if (VM.TraceStkMaps) VM.sysWrite("VM_ReferenceMaps-locateGCPoint.  building reference maps\n");	// define the basic blocks	VM_BuildBB buildBB = new VM_BuildBB();	buildBB.determineTheBasicBlocks(method);	// now the related reference maps	VM_BuildReferenceMaps buildRefMaps = new VM_BuildReferenceMaps();	buildRefMaps.buildReferenceMaps(method, null, this, buildBB);      } else {	// cached site is valid - copy over map for the site	//  VM.sysWrite("VM_ReferenceMaps-locateGCPoint.cached map found\n");	referenceMaps = cacheMap; // use cached map	MCSites = new int[1];	MCSites[0] = cacheMCSite;	mapCount = 1;	return 0;      }    } // end dynamic reference map    //Scan the list of machine code addresses to find the    //  closest site offset BEFORE the input machine code index ( offset in the code)    int dist;    int distance = 0;    int index = 0;    // get the first possible location    for ( int i = 0; i < mapCount; i++)    {      // get an initial non zero distance     distance = machCodeOffset - MCSites[i];     if (distance >= 0)     {       index = i;       break;     }    }    // scan to find any better location ie closer to the site    for( int i = index+1; i < mapCount; i++)    {       dist =  machCodeOffset- MCSites[i];       if ( dist < 0 ) continue;       if ( dist <= distance)       {         index = i;         distance = dist;       }    }    //      if (VM.TraceStkMaps)       if (debug)        {         showInfo();         VM.sysWrite(" VM_ReferenceMaps-locateGCPoint located index  = ");         VM.sysWrite(index);         VM.sysWrite("  byte  = ");         VM.sysWrite(referenceMaps[index]);         VM.sysWrite( "\n");	}    // test for a site within a jsr subroutine     if ((0x000000FF & (referenceMaps[index*bytesPerMap] &  JSR_MASK)) == (0x000000FF & JSR_MASK))  // test for jsr map       {       index = -index;                       // indicate site within a jsr to caller       if (VM.TraceStkMaps)        {         VM.sysWrite(" VM_ReferenceMaps-locateGCPoint jsr mapid = ");         VM.sysWrite( -index);         VM.sysWrite( "\n");        }       }     if (VM.TraceStkMaps)       {         VM.sysWrite(" VM_ReferenceMaps-locateGCPoint  machine offset = ");         VM.sysWrite(  machCodeOffset);         VM.sysWrite("  - return map index = ");         VM.sysWrite( index);         VM.sysWrite( "\n");       }     if(VM.DynamicReferenceMaps){       // This code caches the last site for potential future use.. Note that       // JSR sites are not cached because that requires special locateGCPoint support       //  and the JSR path must somhow be saved.. Since JSRs are a low frequency instruction       //  we are not supporting the caching of JSR sites.       if ( index >= 0)       {	 // cache this site for future use	 cacheMCSite = machCodeOffset;        // location         // save the map         int j = index * bytesPerMap;         for (int i = j; i < (j + bytesPerMap); i++)              cacheMap[i - j] = referenceMaps[i];       }     }   // end dynmaic reference maps     return index;   }