org.mmtk.plan
Class TraceLocal

java.lang.Object
  extended by org.mmtk.plan.TransitiveClosure
      extended by org.mmtk.plan.TraceLocal
All Implemented Interfaces:
Constants
Direct Known Subclasses:
BTTraceLocal, CMSTraceLocal, CopyMSTraceLocal, GenMatureTraceLocal, GenNurseryTraceLocal, GenRCFindRootSetTraceLocal, ImmixDefragTraceLocal, ImmixTraceLocal, MCForwardTraceLocal, MCMarkTraceLocal, MSTraceLocal, NoGCTraceLocal, RCFindRootSetTraceLocal, SanityRootTraceLocal, SanityTraceLocal, SSTraceLocal, StickyImmixNurseryTraceLocal, StickyMSNurseryTraceLocal

public abstract class TraceLocal
extends TransitiveClosure
implements Constants

This abstract class and its global counterpart implement the core functionality for a transitive closure over the heap graph. This class specifically implements the unsynchronized thread-local component (ie the 'fast path') of the trace mechanism.

See Also:
Plan, Trace

Field Summary
protected  AddressDeque rootLocations
          delayed root slots
protected  ObjectReferenceDeque values
          gray objects
 
Fields inherited from class org.mmtk.plan.TransitiveClosure
specializedScan
 
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
TraceLocal(int specializedScan, Trace trace)
          Constructor
TraceLocal(Trace trace)
          Constructor
 
Method Summary
private  void assertMutatorRemsetsFlushed()
          Assert that the remsets have been flushed.
 void completeTrace()
          Finishing processing all GC work.
 void flush()
          Flush the local buffers of all deques.
 ObjectReference getForwardedFinalizable(ObjectReference object)
          If a Finalizable object has moved, return the new location.
 ObjectReference getForwardedReference(ObjectReference object)
          If the referenced object has moved, return the new location.
 ObjectReference getForwardedReferenceType(ObjectReference object)
          If the Reference Type object has moved, return the new location.
 ObjectReference getForwardedReferent(ObjectReference object)
          If the reference object (from a Reference Type) has object has moved, return the new location.
 boolean incrementalTrace(int workLimit)
          Process GC work until either complete or workLimit units of work are completed.
 boolean isLive(ObjectReference object)
          Is the specified object live?
 boolean isReachable(ObjectReference object)
          Is the specified object reachable?
 boolean isReferentLive(ObjectReference object)
          Is the specified referent of a reference type object live?
protected  void logMessage(int minVerbose, String message)
          This method logs a message with prepended thread id, if the verbosity level is greater or equal to the passed level.
protected  boolean overwriteReferenceDuringTrace()
          Should reference values be overwritten as the heap is traced?
 void prepare()
          TODO write JavaDoc comment
 void processEdge(ObjectReference source, Address slot)
          Trace a reference during GC.
 void processInteriorEdge(ObjectReference target, Address slot, boolean root)
          Trace a reference during GC.
 void processNode(ObjectReference object)
          Add a gray object
protected  void processRememberedSets()
          Flush any remembered sets pertaining to the current collection.
 void processRootEdge(Address slot, boolean untraced)
          Trace a reference during GC.
 void processRoots()
          Process any roots for which processing was delayed.
 boolean readyToFinalize(ObjectReference object)
          Return true if an object is ready to move to the finalizable queue, i.e. it has no regular references to it.
 void release()
           
 void reportDelayedRootEdge(Address slot)
          Report a root edge to be processed during GC.
 ObjectReference retainForFinalize(ObjectReference object)
          An object is unreachable and is about to be added to the finalizable queue.
 ObjectReference retainReferent(ObjectReference object)
          Make alive a referent object that is known not to be live (isLive is false).
protected  void scanObject(ObjectReference object)
          Collectors that move objects must override this method.
 ObjectReference traceObject(ObjectReference object)
          This method is the core method during the trace of the object graph.
 ObjectReference traceObject(ObjectReference object, boolean root)
          This method traces an object with knowledge of the fact that object is a root or not.
 boolean willNotMoveInCurrentCollection(ObjectReference object)
          Ensure that the referenced object will not move from this point through to the end of the collection.
 
Methods inherited from class org.mmtk.plan.TransitiveClosure
getSpecializedScanClass, registerSpecializedScan
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected final ObjectReferenceDeque values
gray objects


rootLocations

protected final AddressDeque rootLocations
delayed root slots

Constructor Detail

TraceLocal

public TraceLocal(Trace trace)
Constructor

Parameters:
trace - The global trace class to use.

TraceLocal

public TraceLocal(int specializedScan,
                  Trace trace)
Constructor

Parameters:
specializedScan - The specialized scan id.
trace - The global trace class to use.
Method Detail

overwriteReferenceDuringTrace

protected boolean overwriteReferenceDuringTrace()
Should reference values be overwritten as the heap is traced?


processEdge

public final void processEdge(ObjectReference source,
                              Address slot)
Trace a reference during GC. This involves determining which collection policy applies and calling the appropriate trace method.

Overrides:
processEdge in class TransitiveClosure
Parameters:
source - The source of the reference.
slot - The location containing the object reference to be traced. The object reference is NOT an interior pointer.

reportDelayedRootEdge

public final void reportDelayedRootEdge(Address slot)
Report a root edge to be processed during GC. As the given reference may theoretically point to an object required during root scanning, the caller has requested processing be delayed. NOTE: delayed roots are assumed to be raw.

Parameters:
slot - The location containing the object reference to be traced. The object reference is NOT an interior pointer.

processRootEdge

public final void processRootEdge(Address slot,
                                  boolean untraced)
Trace a reference during GC. This involves determining which collection policy applies and calling the appropriate trace method.

Parameters:
slot - The location containing the object reference to be traced. The object reference is NOT an interior pointer.
untraced - true if objLoc is an untraced root.

processInteriorEdge

public final void processInteriorEdge(ObjectReference target,
                                      Address slot,
                                      boolean root)
Trace a reference during GC. This involves determining which collection policy applies and calling the appropriate trace method.

Parameters:
target - The object the interior edge points within.
slot - The location of the interior edge.
root - true if this is a root edge.

scanObject

protected void scanObject(ObjectReference object)
Collectors that move objects must override this method. It performs the deferred scanning of objects which are forwarded during bootstrap of each copying collection. Because of the complexities of the collection bootstrap (such objects are generally themselves gc-critical), the forwarding and scanning of the objects must be dislocated. It is an error for a non-moving collector to call this method.

Parameters:
object - The forwarded object to be scanned

processNode

public final void processNode(ObjectReference object)
Add a gray object

Overrides:
processNode in class TransitiveClosure
Parameters:
object - The object to be enqueued

flush

public final void flush()
Flush the local buffers of all deques.


isLive

public boolean isLive(ObjectReference object)
Is the specified object live?

Parameters:
object - The object.
Returns:
true if the object is live.

isReachable

public boolean isReachable(ObjectReference object)
Is the specified object reachable? Used for GC Trace

Parameters:
object - The object.
Returns:
true if the object is live.

isReferentLive

public boolean isReferentLive(ObjectReference object)
Is the specified referent of a reference type object live?

Parameters:
object - The object.
Returns:
true if the reference object is live.

traceObject

public ObjectReference traceObject(ObjectReference object)
This method is the core method during the trace of the object graph. The role of this method is to:
  1. Ensure the traced object is not collected.
  2. If this is the first visit to the object enqueue it to be scanned.
  3. Return the forwarded reference to the object.

Parameters:
object - The object to be traced.
Returns:
The new reference to the same object instance.

traceObject

public ObjectReference traceObject(ObjectReference object,
                                   boolean root)
This method traces an object with knowledge of the fact that object is a root or not. In simple collectors the fact it is a root is not important so this is the default implementation given here.

Parameters:
object - The object to be traced.
root - Is this object a root?
Returns:
The new reference to the same object instance.

willNotMoveInCurrentCollection

public boolean willNotMoveInCurrentCollection(ObjectReference object)
Ensure that the referenced object will not move from this point through to the end of the collection. This can involve forwarding the object if necessary. Non-copying collectors do nothing, copying collectors must override this method in each of their trace classes.

Parameters:
object - The object that must not move during the collection.
Returns:
true If the object will not move during collection

getForwardedFinalizable

public ObjectReference getForwardedFinalizable(ObjectReference object)
If a Finalizable object has moved, return the new location.

Parameters:
object - The object which may have been forwarded.
Returns:
The new location of object.

getForwardedReferent

public ObjectReference getForwardedReferent(ObjectReference object)
If the reference object (from a Reference Type) has object has moved, return the new location.

Parameters:
object - The object which may have been forwarded.
Returns:
The new location of object.

getForwardedReferenceType

public ObjectReference getForwardedReferenceType(ObjectReference object)
If the Reference Type object has moved, return the new location.

Parameters:
object - The object which may have been forwarded.
Returns:
The new location of object.

getForwardedReference

public ObjectReference getForwardedReference(ObjectReference object)
If the referenced object has moved, return the new location. Some copying collectors will need to override this method.

Parameters:
object - The object which may have been forwarded.
Returns:
The new location of object.

retainReferent

public ObjectReference retainReferent(ObjectReference object)
Make alive a referent object that is known not to be live (isLive is false). This is used by the ReferenceProcessor. For many collectors these semantics reflect those of traceObject, which is implemented here. Other collectors must override this method.

Parameters:
object - The object which is to be made alive.
Returns:
The possibly forwarded address of the object.

retainForFinalize

public ObjectReference retainForFinalize(ObjectReference object)
An object is unreachable and is about to be added to the finalizable queue. The collector must ensure the object is not collected (despite being otherwise unreachable), and should return its forwarded address if keeping the object alive involves forwarding. This is only ever called once for an object.

For many collectors these semantics reflect those of traceObject, which is implemented here. Other collectors must override this method.

Parameters:
object - The object which may have been forwarded.
Returns:
The forwarded value for object. In this case return object, copying collectors must override this method.

readyToFinalize

public boolean readyToFinalize(ObjectReference object)
Return true if an object is ready to move to the finalizable queue, i.e. it has no regular references to it. This method may (and in some cases is) be overridden by subclasses. If this method returns true then it can be assumed that retainForFinalize will be called during the current collection. For many collectors these semantics reflect those of isLive, which is implemented here. Other collectors must override this method.

Parameters:
object - The object being queried.
Returns:
true if the object has no regular references to it.

prepare

public void prepare()
TODO write JavaDoc comment


release

public void release()

processRoots

public void processRoots()
Process any roots for which processing was delayed.


completeTrace

public void completeTrace()
Finishing processing all GC work. This method iterates until all work queues are empty.


incrementalTrace

public boolean incrementalTrace(int workLimit)
Process GC work until either complete or workLimit units of work are completed.

Parameters:
workLimit - The maximum units of work to perform.
Returns:
true if all work was completed within workLimit.

processRememberedSets

protected void processRememberedSets()
Flush any remembered sets pertaining to the current collection. Non-generational collectors do nothing.


assertMutatorRemsetsFlushed

private void assertMutatorRemsetsFlushed()
Assert that the remsets have been flushed. This is critical to correctness. We need to maintain the invariant that remset entries do not accrue during GC. If the host JVM generates barrier entries it is its own responsibility to ensure that they are flushed before returning to MMTk.


logMessage

protected final void logMessage(int minVerbose,
                                String message)
This method logs a message with prepended thread id, if the verbosity level is greater or equal to the passed level.

Parameters:
minVerbose - The required verbosity level
message - The message to display