org.jikesrvm.mm.mmtk
Class Scanning

java.lang.Object
  extended by org.mmtk.vm.Scanning
      extended by org.jikesrvm.mm.mmtk.Scanning
All Implemented Interfaces:
Constants

public final class Scanning
extends Scanning
implements Constants


Field Summary
private static SynchronizedCounter threadCounter
          Counter to track index into thread table for root tracing.
private static boolean threadStacksScanned
          Status flag used to determine if stacks were scanned in this collection increment
private static boolean TRACE_PRECOPY
          Class variables
 
Fields inherited from interface org.mmtk.utility.Constants
ALIGNMENT_VALUE, ARRAY_ELEMENT, BITS_IN_ADDRESS, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_INT, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_INT, BYTES_IN_KBYTE, BYTES_IN_MBYTE, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, CARD_MASK, CARD_META_PAGES_PER_REGION, INSTANCE_FIELD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_INT, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_ADDRESS_SPACE, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_INT, LOG_BYTES_IN_KBYTE, LOG_BYTES_IN_MBYTE, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD, LOG_CARD_BYTES, LOG_CARD_GRAIN, LOG_CARD_META_BYTES, LOG_CARD_META_PAGES, LOG_CARD_META_SIZE, LOG_CARD_UNITS, LOG_MIN_ALIGNMENT, MAX_ALIGNMENT, MAX_BYTES_PADDING, MAX_INT, MIN_ALIGNMENT, MIN_INT, SUPPORT_CARD_SCANNING
 
Constructor Summary
Scanning()
           
 
Method Summary
static void clearThreadStacksScanned()
          Clear the flag that indicates thread stacks have been scanned.
 void computeBootImageRoots(TraceLocal trace)
          Compute all roots out of the VM's boot image (if any).
 void computeGlobalRoots(TraceLocal trace)
          Computes global roots.
 void computeStaticRoots(TraceLocal trace)
          Computes static roots.
 void computeThreadRoots(TraceLocal trace)
          Computes roots pointed to by threads, their associated registers and stacks.
 void precopyChildren(TraceLocal trace, ObjectReference object)
          Precopying of a object's fields, processing each pointer field encountered.
 void preCopyGCInstances(TraceLocal trace)
          Pre-copy all potentially movable instances used in the course of GC.
 void resetThreadCounter()
          Prepares for using the computeAllRoots method.
 void scanObject(TransitiveClosure trace, ObjectReference object)
          Scanning of a object, processing each pointer field encountered.
 void specializedScanObject(int id, TransitiveClosure trace, ObjectReference object)
          Invoke a specialized scan method.
static boolean threadStacksScanned()
          Were thread stacks scanned in this collection increment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_PRECOPY

private static final boolean TRACE_PRECOPY
Class variables

See Also:
Constant Field Values

threadCounter

private static final SynchronizedCounter threadCounter
Counter to track index into thread table for root tracing.


threadStacksScanned

private static boolean threadStacksScanned
Status flag used to determine if stacks were scanned in this collection increment

Constructor Detail

Scanning

public Scanning()
Method Detail

threadStacksScanned

public static boolean threadStacksScanned()
Were thread stacks scanned in this collection increment.


clearThreadStacksScanned

public static void clearThreadStacksScanned()
Clear the flag that indicates thread stacks have been scanned.


scanObject

public void scanObject(TransitiveClosure trace,
                       ObjectReference object)
Scanning of a object, processing each pointer field encountered.

Specified by:
scanObject in class Scanning
Parameters:
trace - The closure being used.
object - The object to be scanned.

specializedScanObject

public void specializedScanObject(int id,
                                  TransitiveClosure trace,
                                  ObjectReference object)
Invoke a specialized scan method. Note that these methods must have been allocated explicitly through Plan and PlanConstraints.

Specified by:
specializedScanObject in class Scanning
Parameters:
id - The specialized method id
trace - The trace the method has been specialized for
object - The object to be scanned

precopyChildren

public void precopyChildren(TraceLocal trace,
                            ObjectReference object)
Precopying of a object's fields, processing each pointer field encountered.

Specified by:
precopyChildren in class Scanning
Parameters:
trace - The trace being used.
object - The object to be scanned.

resetThreadCounter

public void resetThreadCounter()
Prepares for using the computeAllRoots method. The thread counter allows multiple GC threads to co-operatively iterate through the thread data structure (if load balancing parallel GC threads were not important, the thread counter could simply be replaced by a for loop).

Specified by:
resetThreadCounter in class Scanning

preCopyGCInstances

public void preCopyGCInstances(TraceLocal trace)
Pre-copy all potentially movable instances used in the course of GC. This includes the thread objects representing the GC threads themselves. It is crucial that these instances are forwarded prior to the GC proper. Since these instances are not enqueued for scanning, it is important that when roots are computed the same instances are explicitly scanned and included in the set of roots. The existence of this method allows the actions of calculating roots and forwarding GC instances to be decoupled. The thread table is scanned in parallel by each processor, by striding through the table at a gap of chunkSize*numProcs. Feel free to adjust chunkSize if you want to tune a parallel collector. Explicitly no-inlined to prevent over-inlining of collectionPhase. TODO Experiment with specialization to remove virtual dispatch ?

Specified by:
preCopyGCInstances in class Scanning

computeStaticRoots

public void computeStaticRoots(TraceLocal trace)
Computes static roots. This method establishes all such roots for collection and places them in the root locations queue. This method should not have side effects (such as copying or forwarding of objects). There are a number of important preconditions:

Specified by:
computeStaticRoots in class Scanning
Parameters:
trace - The trace to use for computing roots.

computeGlobalRoots

public void computeGlobalRoots(TraceLocal trace)
Computes global roots. This method establishes all such roots for collection and places them in the root locations queue. This method should not have side effects (such as copying or forwarding of objects). There are a number of important preconditions:

Specified by:
computeGlobalRoots in class Scanning
Parameters:
trace - The trace to use for computing roots.

computeThreadRoots

public void computeThreadRoots(TraceLocal trace)
Computes roots pointed to by threads, their associated registers and stacks. This method places these roots in the root values, root locations and interior root locations queues. This method should not have side effects (such as copying or forwarding of objects). There are a number of important preconditions: TODO rewrite to avoid the per-thread synchronization, like precopy.

Specified by:
computeThreadRoots in class Scanning
Parameters:
trace - The trace to use for computing roots.

computeBootImageRoots

public void computeBootImageRoots(TraceLocal trace)
Compute all roots out of the VM's boot image (if any). This method is a no-op in the case where the VM does not maintain an MMTk-visible Java space. However, when the VM does maintain a space (such as a boot image) which is visible to MMTk, that space could either be scanned by MMTk as part of its transitive closure over the whole heap, or as a (considerable) performance optimization, MMTk could avoid scanning the space if it is aware of all pointers out of that space. This method is used to establish the root set out of the scannable space in the case where such a space exists.

Specified by:
computeBootImageRoots in class Scanning
Parameters:
trace - The trace object to use to report root locations.