org.jikesrvm.mm.mmtk
Class Collection

java.lang.Object
  extended by org.mmtk.vm.Collection
      extended by org.jikesrvm.mm.mmtk.Collection
All Implemented Interfaces:
Constants, HeapLayoutConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public class Collection
extends Collection
implements Constants, Constants


Field Summary
private static Atom collectorThreadAtom
          The fully qualified name of the collector thread.
private static RVMThread.SoftHandshakeVisitor mutatorFlushVisitor
           
private static Atom runAtom
          The string "run".
 
Fields inherited from class org.mmtk.vm.Collection
EXTERNAL_GC_TRIGGER, INTERNAL_GC_TRIGGER, INTERNAL_PHASE_GC_TRIGGER, RESOURCE_GC_TRIGGER, TRIGGER_REASONS, triggerReasons, UNKNOWN_GC_TRIGGER
 
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
 
Fields inherited from interface org.jikesrvm.Constants
NOT_REACHED, REFLECTION_FPRS_BITS, REFLECTION_FPRS_MASK, REFLECTION_GPRS_BITS, REFLECTION_GPRS_MASK
 
Fields inherited from interface org.jikesrvm.objectmodel.ThinLockConstants
TL_DEDICATED_U16_OFFSET, TL_DEDICATED_U16_SHIFT, TL_LOCK_COUNT_MASK, TL_LOCK_COUNT_SHIFT, TL_LOCK_COUNT_UNIT, TL_LOCK_ID_MASK, TL_LOCK_ID_SHIFT, TL_NUM_BITS_RC, TL_NUM_BITS_STAT, TL_NUM_BITS_TID, TL_STAT_BIASABLE, TL_STAT_FAT, TL_STAT_MASK, TL_STAT_SHIFT, TL_STAT_THIN, TL_THREAD_ID_MASK, TL_THREAD_ID_SHIFT, TL_UNLOCK_MASK
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_BOOLEAN, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_LONG, BITS_IN_OFFSET, BYTES_IN_BOOLEAN, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_LONG, BYTES_IN_OFFSET, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Constructor Summary
Collection()
           
 
Method Summary
 int activeGCThreadOrdinal()
           
 int activeGCThreads()
           
private static void checkForOutOfMemoryError(boolean afterCollection)
          Check if there is an out of memory error waiting.
static void init()
          Initialization that occurs at build time.
 boolean isEmergencyAllocation()
          Does the VM consider this an emergency allocation, where the normal heap size rules can be ignored.
 void joinCollection()
          Joins a collection.
 int maximumCollectionAttempt()
          The maximum number collection attempts across threads.
 boolean noThreadsInGC()
          Determine whether a collection cycle has fully completed (this is used to ensure a GC is not in the process of completing, to avoid, for example, an async GC being triggered on the switch from GC to mutator thread before all GC threads have switched.
 void prepareCollector(CollectorContext c)
          Prepare a collector for a collection.
 void prepareMutator(MutatorContext m)
          Prepare a mutator for a collection.
 int rendezvous(int where)
          Rendezvous with all other processors, returning the rank (that is, the order this processor arrived at the barrier).
 void reportAllocationSuccess()
          Report that the the physical allocation has succeeded.
 void reportPhysicalAllocationFailed()
          Report that a physical allocation has failed.
 void requestMutatorFlush()
          Request each mutator flush remembered sets.
static void scheduleFinalizerThread()
          Schedule the finalizerThread, if there are objects to be finalized and the finalizerThread is on its queue (ie. currently idle).
 void triggerAsyncCollection(int why)
          Trigger an asynchronous collection, checking for memory exhaustion first.
 void triggerCollection(int why)
          Triggers a collection.
static void triggerCollectionStatic(int why)
          Triggers a collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collectorThreadAtom

private static Atom collectorThreadAtom
The fully qualified name of the collector thread.


runAtom

private static Atom runAtom
The string "run".


mutatorFlushVisitor

private static RVMThread.SoftHandshakeVisitor mutatorFlushVisitor
Constructor Detail

Collection

public Collection()
Method Detail

init

public static void init()
Initialization that occurs at build time. The values of statics at the completion of this routine will be reflected in the boot image. Any objects referenced by those statics will be transitively included in the boot image. This is called from MemoryManager.


triggerCollection

public final void triggerCollection(int why)
Triggers a collection.

Specified by:
triggerCollection in class Collection
Parameters:
why - the reason why a collection was triggered. 0 to TRIGGER_REASONS - 1.

joinCollection

public final void joinCollection()
Joins a collection.

Specified by:
joinCollection in class Collection

triggerCollectionStatic

public static void triggerCollectionStatic(int why)
Triggers a collection.

Parameters:
why - the reason why a collection was triggered. 0 to TRIGGER_REASONS - 1.

checkForOutOfMemoryError

private static void checkForOutOfMemoryError(boolean afterCollection)
Check if there is an out of memory error waiting.


maximumCollectionAttempt

public int maximumCollectionAttempt()
The maximum number collection attempts across threads.

Specified by:
maximumCollectionAttempt in class Collection

reportAllocationSuccess

public void reportAllocationSuccess()
Report that the the physical allocation has succeeded.

Specified by:
reportAllocationSuccess in class Collection

reportPhysicalAllocationFailed

public void reportPhysicalAllocationFailed()
Report that a physical allocation has failed.

Specified by:
reportPhysicalAllocationFailed in class Collection

isEmergencyAllocation

public boolean isEmergencyAllocation()
Does the VM consider this an emergency allocation, where the normal heap size rules can be ignored.

Specified by:
isEmergencyAllocation in class Collection

triggerAsyncCollection

public final void triggerAsyncCollection(int why)
Trigger an asynchronous collection, checking for memory exhaustion first.

Specified by:
triggerAsyncCollection in class Collection
Parameters:
why - the reason why a collection was triggered. 0 to TRIGGER_REASONS - 1.

noThreadsInGC

public final boolean noThreadsInGC()
Determine whether a collection cycle has fully completed (this is used to ensure a GC is not in the process of completing, to avoid, for example, an async GC being triggered on the switch from GC to mutator thread before all GC threads have switched.

Specified by:
noThreadsInGC in class Collection
Returns:
True if GC is not in progress.

prepareMutator

public final void prepareMutator(MutatorContext m)
Prepare a mutator for a collection.

Specified by:
prepareMutator in class Collection
Parameters:
m - the mutator to prepare

prepareCollector

public final void prepareCollector(CollectorContext c)
Prepare a collector for a collection.

Specified by:
prepareCollector in class Collection
Parameters:
c - the collector to prepare

rendezvous

public final int rendezvous(int where)
Rendezvous with all other processors, returning the rank (that is, the order this processor arrived at the barrier).

Specified by:
rendezvous in class Collection

activeGCThreads

public final int activeGCThreads()
Specified by:
activeGCThreads in class Collection
Returns:
The number of active collector threads

activeGCThreadOrdinal

public final int activeGCThreadOrdinal()
Specified by:
activeGCThreadOrdinal in class Collection
Returns:
The ordinal ID of the running collector thread w.r.t. the set of active collector threads (zero based)

requestMutatorFlush

public void requestMutatorFlush()
Request each mutator flush remembered sets. This method will trigger the flush and then yield until all processors have flushed.

Specified by:
requestMutatorFlush in class Collection

scheduleFinalizerThread

public static void scheduleFinalizerThread()
Schedule the finalizerThread, if there are objects to be finalized and the finalizerThread is on its queue (ie. currently idle). Should be called at the end of GC after moveToFinalizable has been called, and before mutators are allowed to run.