public abstract class Plan extends Object
All plans make a clear distinction between global and thread-local activities, and divides global and local state into separate class hierarchies. Global activities must be synchronized, whereas no synchronization is required for thread-local activities. There is a single instance of Plan (or the appropriate sub-class), and a 1:1 mapping of PlanLocal to "kernel threads" (aka CPUs). Thus instance methods of PlanLocal allow fast, unsynchronized access to functions such as allocation and collection. The global instance defines and manages static resources (such as memory and virtual memory resources). This mapping of threads to instances is crucial to understanding the correctness and performance properties of MMTk plans.
Modifier and Type | Field and Description |
---|---|
static int |
ALLOC_CODE |
static int |
ALLOC_COLD_CODE |
static int |
ALLOC_DEFAULT |
static int |
ALLOC_GCSPY |
static int |
ALLOC_HOT_CODE |
static int |
ALLOC_IMMORTAL |
static int |
ALLOC_LARGE_CODE |
static int |
ALLOC_LOS |
static int |
ALLOC_NON_MOVING |
static int |
ALLOC_NON_REFERENCE |
static int |
ALLOC_PRIMITIVE_LOS |
static int |
ALLOC_STACK |
protected static int |
allocationSiteCount
Support for allocation-site identification
|
static int |
ALLOCATORS |
static ParallelCollectorGroup |
concurrentWorkers |
static ControllerCollectorContext |
controlCollectorContext |
static int |
DEFAULT_MAX_NURSERY |
static int |
DEFAULT_MIN_NURSERY |
static int |
DEFAULT_SITE |
protected Class<? extends ParallelCollector> |
defaultCollectorContext
Default collector context
|
protected static boolean |
emergencyCollection |
static boolean |
GATHER_WRITE_BARRIER_STATS |
static int |
GC_PREPARE |
static int |
GC_PROPER |
private static int |
gcStatus |
static int |
IMMORTAL |
static ImmortalSpace |
immortalSpace
Any immortal objects allocated after booting are allocated here.
|
private static boolean |
initialized |
protected static boolean |
insideHarness |
protected static boolean |
internalTriggeredCollection |
static int |
LARGE_CODE |
static LargeObjectSpace |
largeCodeSpace |
protected static boolean |
lastInternalTriggeredCollection |
private long |
lastStressPages |
static int |
LOS |
static LargeObjectSpace |
loSpace
Large objects are allocated into a special large object space.
|
static int |
MAX_NON_LOS_COPY_BYTES |
static int |
MAX_NON_LOS_DEFAULT_ALLOC_BYTES |
static int |
MAX_NON_LOS_NONMOVING_ALLOC_BYTES |
static int |
META |
static RawPageSpace |
metaDataSpace
All meta data that is used by MMTk is allocated (and accounted for) in the meta data space.
|
static boolean |
NEEDS_LOG_BIT_IN_HEADER |
static int |
NON_MOVING |
static int |
NON_PARTICIPANT |
static MarkSweepSpace |
nonMovingSpace
Space used to allocate objects that cannot be moved. we do not need a large space as the LOS is non-moving.
|
static int |
NOT_IN_GC |
static ParallelCollectorGroup |
parallelWorkers |
static int |
pretenureThreshold |
static int |
SANITY |
static SanityChecker |
sanityChecker
Global sanity checking state
|
static RawPageSpace |
sanitySpace
Space used by the sanity checker (used at runtime only if sanity checking enabled
|
static boolean |
SCAN_BOOT_IMAGE |
static int |
SMALL_CODE |
static MarkSweepSpace |
smallCodeSpace |
protected static boolean |
stacksPrepared |
static Timer |
totalTime
Timer that counts total time
|
static boolean |
USE_CODE_SPACE |
protected static boolean |
userTriggeredCollection |
static int |
VM_SPACE |
static Space |
vmSpace
The space that holds any VM specific objects (e.g. a boot image)
|
Constructor and Description |
---|
Plan()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static Extent |
availableMemory()
Return the amount of available memory, in bytes.
|
Word |
bootTimeWriteBarrier(Word reference)
Perform any required write barrier action when installing an object reference
a boot time.
|
abstract void |
collectionPhase(short phaseId)
Perform a (global) collection phase.
|
protected boolean |
collectionRequired(boolean spaceFull,
Space space)
This method controls the triggering of a GC.
|
protected boolean |
concurrentCollectionRequired()
This method controls the triggering of an atomic phase of a concurrent
collection.
|
protected int |
determineThreadCount()
Determines the number of threads that will be used for collection.
|
void |
enableAllocation()
The enableAllocation method is called early in the boot process to allow
allocation.
|
void |
enableCollection()
The enableCollection method is called by the runtime after it is
safe to spawn collector contexts and allow garbage collection.
|
void |
forceFullHeapCollection()
Force the next collection to be full heap.
|
static Extent |
freeMemory()
Return the amount of free memory, in bytes (where free is
defined as not in use).
|
void |
fullyBooted() |
static boolean |
gcInProgress()
Return
true if a collection is in progress. |
static boolean |
gcInProgressProper()
Return
true if a collection is in progress and past the preparatory stage. |
static int |
getAllocationSite(boolean compileTime) |
int |
getCollectionReserve()
Return the number of pages reserved for collection.
|
int |
getPagesAvail()
Return the number of pages available for allocation.
|
int |
getPagesReserved()
Return the number of pages reserved for use given the pending
allocation.
|
int |
getPagesUsed()
Return the number of pages reserved for use given the pending
allocation.
|
Class<?> |
getSpecializedScanClass(int id) |
int |
getTotalPages()
Return the total amount of memory managed to the memory
management system, in pages.
|
static void |
handleUserCollectionRequest()
The application code has requested a collection.
|
static void |
harnessBegin()
Generic hook to allow benchmarks to be harnessed.
|
static void |
harnessEnd()
Generic hook to allow benchmarks to be harnessed.
|
void |
insertPhaseAfter(int markerScheduledPhase,
int scheduledPhase)
Insert a phase.
|
boolean |
isCurrentGCNursery() |
static boolean |
isEmergencyCollection() |
static boolean |
isInitialized() |
static boolean |
isInternalTriggeredCollection() |
static boolean |
isUserTriggeredCollection() |
boolean |
lastCollectionFullHeap() |
boolean |
lastCollectionWasExhaustive() |
ObjectReference |
loadObjectReference(Address slot)
Load an object reference
|
protected void |
logPoll(Space space,
String message) |
void |
notifyExit(int value)
The VM is about to exit.
|
boolean |
poll(boolean spaceFull,
Space space)
This method is called periodically by the allocation subsystem
(by default, each time a page is consumed), and provides the
collector with an opportunity to collect.
|
protected void |
preCollectorSpawn()
Prepares for spawning of collectors.
|
protected void |
printDetailedTiming(boolean totals)
Any Plan can override this to provide additional plan specific
timing information.
|
void |
printPostStats()
Print out statistics at the end of a GC
|
void |
printPreStats()
Print pre-collection statistics.
|
void |
printUsedPages() |
void |
processOptions()
The processOptions method is called by the runtime immediately after
command-line arguments are available.
|
protected void |
registerSpecializedMethods()
Registers specialized methods.
|
void |
replacePhase(int oldScheduledPhase,
int scheduledPhase)
Replace a phase.
|
static Extent |
reservedMemory()
Return the amount of memory in use, in bytes.
|
static void |
resetCollectionTrigger()
Reset collection state information.
|
int |
sanityExpectedRC(ObjectReference object,
int sanityRootRC)
Return the expected reference count.
|
void |
sanityLinearScan(LinearScan scanner)
Perform a linear scan of all spaces to check for possible leaks.
|
byte |
setBuildTimeGCByte(Address object,
ObjectReference typeRef,
int size)
Performs any required initialization of the GC portion of the header.
|
static void |
setGCStatus(int s)
Sets the GC status.
|
protected void |
spawnCollectorThreads(int numThreads)
Spawns the collector threads.
|
static boolean |
stacksPrepared()
Return
true if stacks have been prepared in this collection cycle. |
void |
startGCspyServer(int port,
boolean wait)
Start GCspy server.
|
void |
storeObjectReference(Address slot,
ObjectReference value)
Store an object reference
|
boolean |
stressTestGCRequired() |
static Extent |
totalMemory()
Return the total amount of memory managed to the memory
management system, in bytes.
|
static void |
triggerInternalCollectionRequest()
MMTK has requested stop-the-world activity (e.g., stw within a concurrent gc).
|
static Extent |
usedMemory()
Return the amount of memory in use, in bytes.
|
boolean |
willNeverMove(ObjectReference object)
Can this object ever move.
|
public static final int NOT_IN_GC
public static final int GC_PREPARE
public static final int GC_PROPER
public static final boolean USE_CODE_SPACE
public static final int ALLOC_DEFAULT
public static final int ALLOC_NON_REFERENCE
public static final int ALLOC_NON_MOVING
public static final int ALLOC_IMMORTAL
public static final int ALLOC_LOS
public static final int ALLOC_PRIMITIVE_LOS
public static final int ALLOC_GCSPY
public static final int ALLOC_CODE
public static final int ALLOC_LARGE_CODE
public static final int ALLOC_HOT_CODE
public static final int ALLOC_COLD_CODE
public static final int ALLOC_STACK
public static final int ALLOCATORS
public static final int DEFAULT_SITE
public static final int NON_PARTICIPANT
public static final boolean GATHER_WRITE_BARRIER_STATS
public static final int DEFAULT_MIN_NURSERY
public static final int DEFAULT_MAX_NURSERY
public static final boolean SCAN_BOOT_IMAGE
public static final int MAX_NON_LOS_DEFAULT_ALLOC_BYTES
public static final int MAX_NON_LOS_NONMOVING_ALLOC_BYTES
public static final int MAX_NON_LOS_COPY_BYTES
public static final boolean NEEDS_LOG_BIT_IN_HEADER
public static final Space vmSpace
public static final ImmortalSpace immortalSpace
public static final RawPageSpace metaDataSpace
public static final LargeObjectSpace loSpace
public static final RawPageSpace sanitySpace
public static final MarkSweepSpace nonMovingSpace
public static final MarkSweepSpace smallCodeSpace
public static final LargeObjectSpace largeCodeSpace
public static int pretenureThreshold
public static final int IMMORTAL
public static final int VM_SPACE
public static final int META
public static final int LOS
public static final int SANITY
public static final int NON_MOVING
public static final int SMALL_CODE
public static final int LARGE_CODE
protected static int allocationSiteCount
public static final SanityChecker sanityChecker
protected final Class<? extends ParallelCollector> defaultCollectorContext
public static final ParallelCollectorGroup parallelWorkers
public static final ParallelCollectorGroup concurrentWorkers
public static final ControllerCollectorContext controlCollectorContext
private long lastStressPages
protected static boolean userTriggeredCollection
protected static boolean internalTriggeredCollection
protected static boolean lastInternalTriggeredCollection
protected static boolean emergencyCollection
protected static boolean stacksPrepared
private static boolean initialized
private static int gcStatus
protected static boolean insideHarness
public Plan()
public void enableAllocation()
public void processOptions()
public void enableCollection()
protected int determineThreadCount()
Collectors that need fine-grained control over the number of spawned collector threads may override this method. Subclasses must ensure that the return value of this method is consistent with the number of collector threads in the active plan.
setting only the maximum number
of collectors
protected void preCollectorSpawn()
This is a good place to do initialization work that depends on options that are only known at runtime. Collectors must keep allocation to a minimum because collection is not yet enabled.
protected void spawnCollectorThreads(int numThreads)
Collection is enabled after this method returns.
numThreads
- the number of collector threads to spawnpublic void fullyBooted()
public void notifyExit(int value)
value
- The exit valueprotected void printDetailedTiming(boolean totals)
totals
- Print totalspublic Word bootTimeWriteBarrier(Word reference)
reference
- the reference value that is to be storedpublic byte setBuildTimeGCByte(Address object, ObjectReference typeRef, int size)
object
- the Address representing the storage to be initializedtypeRef
- the type reference for the instance being createdsize
- the number of bytes allocated by the GC system for
this object.public static int getAllocationSite(boolean compileTime)
compileTime
- is this a call by the compiler?public abstract void collectionPhase(short phaseId)
phaseId
- The unique id of the phase to perform.public void replacePhase(int oldScheduledPhase, int scheduledPhase)
oldScheduledPhase
- The scheduled phase to insert afterscheduledPhase
- The scheduled phase to insertpublic void insertPhaseAfter(int markerScheduledPhase, int scheduledPhase)
markerScheduledPhase
- The scheduled phase to insert afterscheduledPhase
- The scheduled phase to insertpublic boolean lastCollectionWasExhaustive()
public boolean lastCollectionFullHeap()
public static boolean isEmergencyCollection()
public void forceFullHeapCollection()
public boolean isCurrentGCNursery()
public int sanityExpectedRC(ObjectReference object, int sanityRootRC)
true/false
relationship.object
- The object to check.sanityRootRC
- The number of root references to the object.public void sanityLinearScan(LinearScan scanner)
scanner
- The scanner callback to use.public final boolean stressTestGCRequired()
true
is a stress test GC is requiredpublic static boolean isInitialized()
public static boolean stacksPrepared()
true
if stacks have been prepared in this collection cycle.true
if stacks have been prepared in this collection cycle.public static boolean gcInProgress()
true
if a collection is in progress.true
if a collection is in progress.public static boolean gcInProgressProper()
true
if a collection is in progress and past the preparatory stage.true
if a collection is in progress and past the preparatory stage.public static void setGCStatus(int s)
s
- The new GC status.public void printPreStats()
public final void printPostStats()
public final void printUsedPages()
public static void handleUserCollectionRequest()
public static void triggerInternalCollectionRequest()
public static void resetCollectionTrigger()
public static boolean isUserTriggeredCollection()
true
if this collection was triggered by application code.public static boolean isInternalTriggeredCollection()
true
if this collection was triggered internally.public static void harnessBegin()
public static void harnessEnd()
public static Extent freeMemory()
public static Extent availableMemory()
public static Extent usedMemory()
public static Extent reservedMemory()
public static Extent totalMemory()
public final int getTotalPages()
public int getPagesAvail()
public final int getPagesReserved()
public int getCollectionReserve()
public int getPagesUsed()
public void storeObjectReference(Address slot, ObjectReference value)
slot
- The location of the referencevalue
- The value to storepublic ObjectReference loadObjectReference(Address slot)
slot
- The location of the referencepublic final boolean poll(boolean spaceFull, Space space)
spaceFull
- Space request failed, must recover pages within 'space'.space
- The space that triggered the poll.true
if a collection is required.protected boolean collectionRequired(boolean spaceFull, Space space)
true
to trigger a collection.spaceFull
- Space request failed, must recover pages within 'space'.space
- TODOtrue
if a collection is requested by the plan.protected boolean concurrentCollectionRequired()
true
if a collection is requested by the plan.public void startGCspyServer(int port, boolean wait)
port
- The port to listen on,wait
- Should we wait for a client to connect?public boolean willNeverMove(ObjectReference object)
object
- The object in questiontrue
if it is not possible that the object will ever move.protected void registerSpecializedMethods()
public final Class<?> getSpecializedScanClass(int id)
id
- the id of the specialized scan class