Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the absence of hand-inlined scanning, or if specialization is globally disabled, scanning reverts to the fallback method in org.jikesrvm.mm.mminterface.SpecializedScanMethod.  This method can be regarded as the basic underlying mechanism, and is worth understanding in detail.

Code Block
languagejava
RVMType type = ObjectModel.getObjectType(objectRef.toObject());

...


    int[] offsets = type.getReferenceOffsets();

This code fetches the array of offsets that JikesRVM uses to identify the pointer fields in the object.  This array is constructed by the classloader when a class is resolved.

Code Block
languagejava
if (offsets != REFARRAY_OFFSET_ARRAY) {

...


  for(int i=0; i < offsets.length; i++)

...

 {

...


    trace.processEdge(objectRef, objectRef.toAddress().plus(offsets[i]));

...


  }

One distinguished value (actually null) is used to identify arrays of reference objects, and this block of code scans scalar objects by tracing each of the fields at the offsets given by the offset array.

...

Code Block
languagejava
} else {

...


   for(int i=0; i < ObjectModel.getArrayLength(objectRef.toObject()); i++) {

...


    trace.processEdge(objectRef, objectRef.toAddress().plus(i << LOG_BYTES_IN_ADDRESS));

...


  }
}

The other case is reference arrays, for which we fetch the array length and scan each of the elements.

...

The departure point from "standard" java into the specialized scanning method is SpecializedScanMethod.invoke(...), which looks like this

...

Code Block
languagejava
@SpecializedMethodInvoke
@NoInline

...


public static void invoke(int id, Object object, TransitiveClosure trace) {

...


...

  /* By default we call a non-specialized fallback */

...


...

  fallback(object, trace);

...


}

The `SpecializedMethodInvoke' annotation signals to the compiler that it should dispatch to one of the specialized method slots in the  

The SpecializedMethodInvoke annotation signals to the compiler that it should dispatch to one of the specialized method slots in the TIB.

Creation of specialized methods is handled by the class org.jikesrvm.classloader.SpecializedMethodManager.