org.mmtk.plan.generational
Class Gen

java.lang.Object
  extended by org.mmtk.plan.Plan
      extended by org.mmtk.plan.Simple
          extended by org.mmtk.plan.StopTheWorld
              extended by org.mmtk.plan.generational.Gen
All Implemented Interfaces:
Constants
Direct Known Subclasses:
GenCopy, GenImmix, GenMS

public abstract class Gen
extends StopTheWorld

This abstract class implements the core functionality of generic two-generation copying collectors. Nursery collections occur when either the heap is full or the nursery is full. The nursery size is determined by an optional command line argument. If undefined, the nursery size is "infinite", so nursery collections only occur when the heap is full (this is known as a flexible-sized nursery collector). Thus both fixed and flexible nursery sizes are supported. Full heap collections occur when the nursery size has dropped to a statically defined threshold, NURSERY_THRESHOLD

See also Plan.java for general comments on local vs global plan classes.


Field Summary
static int ALLOC_MATURE
           
static int ALLOC_MATURE_MAJORGC
           
static int ALLOC_MATURE_MINORGC
           
static int ALLOC_NURSERY
           
 SharedDeque arrayRemsetPool
           
static float DEFAULT_PRETENURE_THRESHOLD_FRACTION
           
protected static BooleanCounter fullHeap
           
private static Timer fullHeapTime
           
 boolean gcFullHeap
           
static boolean IGNORE_REMSETS
           
protected static float MATURE_FRACTION
           
 SharedDeque modbufPool
           
 boolean nextGCFullHeap
           
static int NURSERY
           
private static Address NURSERY_START
           
protected static float NURSERY_VM_FRACTION
          Fraction of available virtual memory to give to the nursery (if contiguous)
static SizeCounter nurseryCons
           
static SizeCounter nurseryMark
           
static CopySpace nurserySpace
           
 Trace nurseryTrace
           
 SharedDeque remsetPool
           
static int SCAN_MATURE
           
static int SCAN_NURSERY
           
protected static float SURVIVAL_ESTIMATE
           
(package private) static boolean USE_DISCONTIGUOUS_NURSERY
          Switch between a contiguous and discontiguous nursery (experimental)
static boolean USE_NON_HEAP_OBJECT_REFERENCE_WRITE_BARRIER
           
static boolean USE_OBJECT_BARRIER
           
static boolean USE_OBJECT_BARRIER_FOR_AASTORE
           
static boolean USE_OBJECT_BARRIER_FOR_PUTFIELD
           
private static VMRequest vmRequest
           
protected static EventCounter wbFast
           
protected static EventCounter wbSlow
           
private static float WORST_CASE_COPY_EXPANSION
           
 
Fields inherited from class org.mmtk.plan.StopTheWorld
postSanityPhase, preSanityPhase
 
Fields inherited from class org.mmtk.plan.Simple
CLOSURE, collection, collectionAttempt, COMPLETE, completeClosurePhase, FINALIZABLE, finishPhase, FORWARD, FORWARD_FINALIZABLE, FORWARD_REFS, forwardPhase, INITIATE, initPhase, PHANTOM_REFS, POST_SANITY_PLACEHOLDER, PRE_SANITY_PLACEHOLDER, PREPARE, PREPARE_STACKS, prepareStacks, refTypeClosurePhase, RELEASE, rootClosurePhase, ROOTS, SANITY_BUILD_TABLE, SANITY_CHECK_TABLE, SANITY_COPY_ROOTS, SANITY_PREPARE, SANITY_RELEASE, SANITY_ROOTS, SANITY_SET_POSTGC, SANITY_SET_PREGC, sanityBuildPhase, sanityCheckPhase, SET_COLLECTION_KIND, SOFT_REFS, STACK_ROOTS, WEAK_REFS, WEAK_TRACK_REFS
 
Fields inherited from class org.mmtk.plan.Plan
ALLOC_CODE, ALLOC_COLD_CODE, ALLOC_DEFAULT, ALLOC_GCSPY, ALLOC_HOT_CODE, ALLOC_IMMORTAL, ALLOC_LARGE_CODE, ALLOC_LOS, ALLOC_NON_MOVING, ALLOC_NON_REFERENCE, ALLOC_PRIMITIVE_LOS, ALLOC_STACK, allocationSiteCount, ALLOCATORS, concurrentWorkers, controlCollectorContext, DEFAULT_MAX_NURSERY, DEFAULT_MIN_NURSERY, DEFAULT_SITE, defaultCollectorContext, emergencyCollection, GATHER_WRITE_BARRIER_STATS, GC_PREPARE, GC_PROPER, IMMORTAL, immortalSpace, insideHarness, internalTriggeredCollection, LARGE_CODE, largeCodeSpace, lastInternalTriggeredCollection, LOS, loSpace, MAX_NON_LOS_COPY_BYTES, MAX_NON_LOS_DEFAULT_ALLOC_BYTES, MAX_NON_LOS_NONMOVING_ALLOC_BYTES, META, metaDataSpace, NEEDS_LOG_BIT_IN_HEADER, NON_MOVING, NON_PARTICIPANT, nonMovingSpace, NOT_IN_GC, parallelWorkers, pretenureThreshold, SANITY, sanityChecker, sanitySpace, SCAN_BOOT_IMAGE, SMALL_CODE, smallCodeSpace, stacksPrepared, totalTime, USE_CODE_SPACE, userTriggeredCollection, VM_SPACE, vmSpace
 
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
Gen()
           
 
Method Summary
protected abstract  Space activeMatureSpace()
          Accessor method to allow the generic generational code in Gen.java to access the mature space.
 void collectionPhase(short phaseId)
          Perform a (global) collection phase.
 boolean collectionRequired(boolean spaceFull, Space space)
          This method controls the triggering of a GC.
protected  boolean copyMature()
           
 void forceFullHeapCollection()
          Force the next collection to be full heap.
 void fullyBooted()
           
 int getCollectionReserve()
          Return the number of pages reserved for collection.
abstract  int getMaturePhysicalPagesAvail()
          Return the number of pages available for allocation into the mature space.
 int getPagesAvail()
          Return the number of pages available for allocation, assuming all future allocation is to the nursery.
 int getPagesUsed()
          Return the number of pages reserved for use given the pending allocation.
(package private) static boolean inNursery(Address addr)
          Return true if the address resides within the nursery
(package private) static boolean inNursery(ObjectReference obj)
          Return true if the object resides within the nursery
 boolean isCurrentGCNursery()
           
 boolean lastCollectionFullHeap()
           
 void printPreStats()
          Print pre-collection statistics.
protected  void registerSpecializedMethods()
          Register specialized methods.
protected  boolean requiresFullHeapCollection()
          Determine if this GC should be a full heap collection.
 int sanityExpectedRC(ObjectReference object, int sanityRootRC)
          Return the expected reference count.
 boolean traceFullHeap()
           
private  boolean virtualMemoryExhausted()
          Independent of how many pages remain in the page budget (a function of heap size), we must ensure we never exhaust virtual memory.
 boolean willNeverMove(ObjectReference object)
          Can this object ever move.
 
Methods inherited from class org.mmtk.plan.StopTheWorld
processOptions
 
Methods inherited from class org.mmtk.plan.Simple
replacePhase, replacePlaceholderPhase, switchNurseryZeroingApproach
 
Methods inherited from class org.mmtk.plan.Plan
availableMemory, bootTimeWriteBarrier, concurrentCollectionRequired, enableAllocation, enableCollection, freeMemory, gcInProgress, gcInProgressProper, getAllocationSite, getPagesReserved, getSpecializedScanClass, getTotalPages, handleUserCollectionRequest, harnessBegin, harnessEnd, insertPhaseAfter, isEmergencyCollection, isInitialized, isInternalTriggeredCollection, isUserTriggeredCollection, lastCollectionWasExhaustive, loadObjectReference, logPoll, notifyExit, poll, printDetailedTiming, printPostStats, printUsedPages, reservedMemory, resetCollectionTrigger, sanityLinearScan, setGCStatus, stacksPrepared, startGCspyServer, storeObjectReference, stressTestGCRequired, totalMemory, triggerInternalCollectionRequest, usedMemory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PRETENURE_THRESHOLD_FRACTION

public static final float DEFAULT_PRETENURE_THRESHOLD_FRACTION
See Also:
Constant Field Values

SURVIVAL_ESTIMATE

protected static final float SURVIVAL_ESTIMATE
See Also:
Constant Field Values

MATURE_FRACTION

protected static final float MATURE_FRACTION
See Also:
Constant Field Values

WORST_CASE_COPY_EXPANSION

private static final float WORST_CASE_COPY_EXPANSION
See Also:
Constant Field Values

IGNORE_REMSETS

public static final boolean IGNORE_REMSETS
See Also:
Constant Field Values

USE_NON_HEAP_OBJECT_REFERENCE_WRITE_BARRIER

public static final boolean USE_NON_HEAP_OBJECT_REFERENCE_WRITE_BARRIER
See Also:
Constant Field Values

USE_OBJECT_BARRIER_FOR_AASTORE

public static final boolean USE_OBJECT_BARRIER_FOR_AASTORE
See Also:
Constant Field Values

USE_OBJECT_BARRIER_FOR_PUTFIELD

public static final boolean USE_OBJECT_BARRIER_FOR_PUTFIELD
See Also:
Constant Field Values

USE_OBJECT_BARRIER

public static final boolean USE_OBJECT_BARRIER
See Also:
Constant Field Values

NURSERY_VM_FRACTION

protected static final float NURSERY_VM_FRACTION
Fraction of available virtual memory to give to the nursery (if contiguous)

See Also:
Constant Field Values

USE_DISCONTIGUOUS_NURSERY

static final boolean USE_DISCONTIGUOUS_NURSERY
Switch between a contiguous and discontiguous nursery (experimental)

See Also:
Constant Field Values

ALLOC_NURSERY

public static final int ALLOC_NURSERY
See Also:
Constant Field Values

ALLOC_MATURE

public static final int ALLOC_MATURE
See Also:
Constant Field Values

ALLOC_MATURE_MINORGC

public static final int ALLOC_MATURE_MINORGC
See Also:
Constant Field Values

ALLOC_MATURE_MAJORGC

public static final int ALLOC_MATURE_MAJORGC
See Also:
Constant Field Values

SCAN_NURSERY

public static final int SCAN_NURSERY
See Also:
Constant Field Values

SCAN_MATURE

public static final int SCAN_MATURE
See Also:
Constant Field Values

fullHeap

protected static final BooleanCounter fullHeap

fullHeapTime

private static final Timer fullHeapTime

wbFast

protected static final EventCounter wbFast

wbSlow

protected static final EventCounter wbSlow

nurseryMark

public static final SizeCounter nurseryMark

nurseryCons

public static final SizeCounter nurseryCons

vmRequest

private static final VMRequest vmRequest

nurserySpace

public static final CopySpace nurserySpace

NURSERY

public static final int NURSERY

NURSERY_START

private static final Address NURSERY_START

gcFullHeap

public boolean gcFullHeap

nextGCFullHeap

public boolean nextGCFullHeap

nurseryTrace

public final Trace nurseryTrace

modbufPool

public final SharedDeque modbufPool

remsetPool

public final SharedDeque remsetPool

arrayRemsetPool

public final SharedDeque arrayRemsetPool
Constructor Detail

Gen

public Gen()
Method Detail

forceFullHeapCollection

public void forceFullHeapCollection()
Force the next collection to be full heap.

Overrides:
forceFullHeapCollection in class Plan

collectionPhase

public void collectionPhase(short phaseId)
Description copied from class: Simple
Perform a (global) collection phase.

Overrides:
collectionPhase in class Simple
Parameters:
phaseId - The unique id of the phase to perform.

collectionRequired

public final boolean collectionRequired(boolean spaceFull,
                                        Space space)
Description copied from class: Plan
This method controls the triggering of a GC. It is called periodically during allocation. Returns true to trigger a collection.

Overrides:
collectionRequired in class Plan
Parameters:
spaceFull - Space request failed, must recover pages within 'space'.
space - TODO
Returns:
true if a collection is requested by the plan.

requiresFullHeapCollection

protected boolean requiresFullHeapCollection()
Determine if this GC should be a full heap collection.

Returns:
true is this GC should be a full heap collection.

virtualMemoryExhausted

private boolean virtualMemoryExhausted()
Independent of how many pages remain in the page budget (a function of heap size), we must ensure we never exhaust virtual memory. Therefore we must never let the nursery grow to the extent that it can't be copied into the mature space.

Returns:
true if the nursery has grown to the extent that it may not be able to be copied into the mature space.

getPagesUsed

public int getPagesUsed()
Return the number of pages reserved for use given the pending allocation. Simply add the nursery's contribution to that of the superclass.

Overrides:
getPagesUsed in class Plan
Returns:
The number of pages reserved given the pending allocation, excluding space reserved for copying.

getPagesAvail

public int getPagesAvail()
Return the number of pages available for allocation, assuming all future allocation is to the nursery.

Overrides:
getPagesAvail in class Plan
Returns:
The number of pages available for allocation, assuming all future allocation is to the nursery.

getCollectionReserve

public int getCollectionReserve()
Return the number of pages reserved for collection.

Overrides:
getCollectionReserve in class Plan
Returns:
The number of pages reserved given the pending allocation, including space reserved for collection.

getMaturePhysicalPagesAvail

public abstract int getMaturePhysicalPagesAvail()
Return the number of pages available for allocation into the mature space.

Returns:
The number of pages available for allocation into the mature space.

inNursery

static boolean inNursery(Address addr)
Return true if the address resides within the nursery

Parameters:
addr - The object to be tested
Returns:
true if the address resides within the nursery

inNursery

static boolean inNursery(ObjectReference obj)
Return true if the object resides within the nursery

Parameters:
obj - The object to be tested
Returns:
true if the object resides within the nursery

copyMature

protected boolean copyMature()
Returns:
Does the mature space do copying ?

printPreStats

public void printPreStats()
Print pre-collection statistics. In this class we prefix the output indicating whether the collection was full heap or not.

Overrides:
printPreStats in class Plan

activeMatureSpace

protected abstract Space activeMatureSpace()
Accessor method to allow the generic generational code in Gen.java to access the mature space.

Returns:
The mature space, set by each subclass of Gen.

traceFullHeap

public final boolean traceFullHeap()
Returns:
true if we should trace the whole heap during collection. True if we're ignoring remsets or if we're doing a full heap GC.

isCurrentGCNursery

public final boolean isCurrentGCNursery()
Overrides:
isCurrentGCNursery in class Plan
Returns:
Is current GC only collecting objects allocated since last GC.

lastCollectionFullHeap

public final boolean lastCollectionFullHeap()
Overrides:
lastCollectionFullHeap in class Plan
Returns:
Whether last GC is a full GC.

willNeverMove

public boolean willNeverMove(ObjectReference object)
Description copied from class: Plan
Can this object ever move. Used by the VM to make decisions about whether it needs to copy IO buffers etc.

Overrides:
willNeverMove in class Plan
Parameters:
object - The object in question
Returns:
true if it is not possible that the object will ever move.

sanityExpectedRC

public int sanityExpectedRC(ObjectReference object,
                            int sanityRootRC)
Description copied from class: Plan
Return the expected reference count. For non-reference counting collectors this becomes a true/false relationship.

Overrides:
sanityExpectedRC in class Plan
Parameters:
object - The object to check.
sanityRootRC - The number of root references to the object.
Returns:
The expected (root excluded) reference count.

registerSpecializedMethods

protected void registerSpecializedMethods()
Description copied from class: Plan
Register specialized methods.

Overrides:
registerSpecializedMethods in class Plan

fullyBooted

public void fullyBooted()
Overrides:
fullyBooted in class Plan