org.mmtk.plan.semispace.gcspy
Class SSGCspy

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.semispace.SS
                  extended by org.mmtk.plan.semispace.gcspy.SSGCspy
All Implemented Interfaces:
GCspyPlan, Constants

public class SSGCspy
extends SS
implements GCspyPlan

This class extends a simple semi-space collector to instrument it for GCspy.

See the Jones & Lins GC book, section 2.2 for an overview of the basic algorithm. This implementation also includes a large object space (LOS), and an uncollected "immortal" space.

All plans make a clear distinction between global and thread-local activities. Global activities must be synchronized, whereas no synchronization is required for thread-local activities. Instances of Plan map 1:1 to "kernel threads" (aka CPUs). Thus instance methods allow fast, unsychronized access to Plan utilities such as allocation and collection. Each instance rests on static resources (such as memory and virtual memory resources) which are "global" and therefore "static" members of Plan. This mapping of threads to instances is crucial to understanding the correctness and performance proprties of this plan.

FIXME This seems to have changed The order of phases and GCspy actions is important here. It is:

   PREPARE phase
      SSGCspyMutator.gcspyGatherData(SSGCspy.BEFORE_COLLECTION); // safepoint
      SSMutator.PREPARE // FIXME DOES NOT ss.rebind(SS.toSpace());

   PREPARE phase
      SS.PREPARE // flip semispaces
      gcspySpace.prepare();
      SSGCspyCollector.gcspyGatherData(SSGCspy.BEFORE_COLLECTION);
      SSCollector.PREPARE // ss.rebind(SS.toSpace());


   FORWARD_FINALIZABLE phase
      SSCollector.FORWARD_FINALIZABLE
      SSGCspyCollector.gcspyGatherData(SSGCspy.SEMISPACE_COPIED);

   RELEASE phase
      SSGCspyMutator.gcspyGatherData(SSGCspy.SEMISPACE_COPIED); // safepoint
      SSMutator.RELEASE // FIXME ss.rebind(SS.toSpace());
      SSGCspyMutator.gcspyGatherData(SSGCspy.AFTER_COLLECTION);

   RELEASE phase
      SSCollector.RELEASE
      SSGCspyCollector.gcspyGatherData(SSGCspy.AFTER_COLLECTION);
      SS.RELEASE
      gcspySpace.release();
      SSGCspy.gcspyGatherData(); // safepoint
Note that SSMutator has changed the point at which it rebinds toSpace from PREPARE (2.4.6) to after RELEASE (3.x.x).
 --Phase Collector.initiate
 --Phase Mutator.initiate-mutator
 --Phase Mutator.prepare-mutator
     SSGCspyMutator.gcspyGatherData, event=0
 --Phase Plan.prepare
 --Phase Collector.prepare
     SSGCspyCollector.gcspyGatherData, event=0
 --Phase Collector.bootimage-root
 --Phase Collector.root
 --Phase Plan.root
 --Phase Collector.start-closure
 --Phase Collector.soft-ref
 --Phase Collector.complete-closure
 --Phase Collector.weak-ref
 --Phase Collector.finalize
 --Phase Collector.complete-closure
 --Phase Collector.phantom-ref
 --Phase Collector.forward-ref
 --Phase Collector.forward-finalize
     SSGCspyCollector.gcspyGatherData, event=1
 --Phase Mutator.release-mutator
     SSGCspyMutator.gcspyGatherData, event=1
     SSGCspyMutator.gcspyGatherData, event=2
 --Phase Collector.release
     SSGCspyCollector.gcspyGatherData, event=2
 --Phase Plan.release
     SSGCspy.gcspyGatherData, event=2
 --Phase Collector.complete
 --Phase Plan.complete
 


Field Summary
(package private) static int AFTER_COLLECTION
          The collection is complete, i.e. immediately after SS.collectionPhase(SS.RELEASE,..).
(package private) static int BEFORE_COLLECTION
          Before a collection has started, i.e. before SS.collectionPhase(SS.PREPARE,..).
private static boolean DEBUG
           
(package private) static int gcspyEvent_
           
(package private) static ImmortalSpaceDriver immortalDriver
           
(package private) static TreadmillDriver losDriver
           
(package private) static TreadmillDriver losNurseryDriver
           
(package private) static TreadmillDriver plosDriver
           
(package private) static TreadmillDriver plosNurseryDriver
           
(package private) static int SEMISPACE_COPIED
          After the semispace has been copied and the large object space has been traced At this time the Large Object Space has not been swept.
(package private) static LinearSpaceDriver ss0Driver
           
(package private) static LinearSpaceDriver ss1Driver
           
 
Fields inherited from class org.mmtk.plan.semispace.SS
ALLOC_SS, copySpace0, copySpace1, hi, SCAN_SS, SS0, SS1, ssTrace
 
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.plan.GCspyPlan
GCSPY, gcspySpace
 
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
SSGCspy()
           
 
Method Summary
 void collectionPhase(short phaseId)
          Perform a (global) collection phase.
private  void gcspyGatherData(int event)
          Gather data for GCspy for the semispaces, the immortal space and the large object space.
 int getPagesUsed()
          Return the number of pages reserved for use given the pending allocation.
private  LinearSpaceDriver newLinearSpaceDriver(String name, CopySpace space, boolean mainSpace)
          Create a new LinearSpaceDriver TODO is this the best name or should we call it LargeObjectSpaceDriver?
private  TreadmillDriver newTreadmillDriver(String name, LargeObjectSpace space)
          Create a new TreadmillDriver TODO is this the best name or should we call it LargeObjectSpaceDriver?
protected  void registerSpecializedMethods()
          Register specialized methods.
(package private) static void reportSpaces()
          Report information on the semispaces
 void startGCspyServer(int port, boolean wait)
          Start the server and wait if necessary.
 
Methods inherited from class org.mmtk.plan.semispace.SS
fromSpace, getCollectionReserve, getPagesAvail, toSpace, willNeverMove
 
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, collectionRequired, concurrentCollectionRequired, enableAllocation, enableCollection, forceFullHeapCollection, freeMemory, fullyBooted, gcInProgress, gcInProgressProper, getAllocationSite, getPagesReserved, getSpecializedScanClass, getTotalPages, handleUserCollectionRequest, harnessBegin, harnessEnd, insertPhaseAfter, isCurrentGCNursery, isEmergencyCollection, isInitialized, isInternalTriggeredCollection, isUserTriggeredCollection, lastCollectionFullHeap, lastCollectionWasExhaustive, loadObjectReference, logPoll, notifyExit, poll, printDetailedTiming, printPostStats, printPreStats, printUsedPages, reservedMemory, resetCollectionTrigger, sanityExpectedRC, sanityLinearScan, setGCStatus, stacksPrepared, 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

BEFORE_COLLECTION

static final int BEFORE_COLLECTION
Before a collection has started, i.e. before SS.collectionPhase(SS.PREPARE,..).

See Also:
Constant Field Values

SEMISPACE_COPIED

static final int SEMISPACE_COPIED
After the semispace has been copied and the large object space has been traced At this time the Large Object Space has not been swept.

See Also:
Constant Field Values

AFTER_COLLECTION

static final int AFTER_COLLECTION
The collection is complete, i.e. immediately after SS.collectionPhase(SS.RELEASE,..). The Large Object Space has been swept.

See Also:
Constant Field Values

gcspyEvent_

static int gcspyEvent_

ss0Driver

static LinearSpaceDriver ss0Driver

ss1Driver

static LinearSpaceDriver ss1Driver

immortalDriver

static ImmortalSpaceDriver immortalDriver

losNurseryDriver

static TreadmillDriver losNurseryDriver

losDriver

static TreadmillDriver losDriver

plosNurseryDriver

static TreadmillDriver plosNurseryDriver

plosDriver

static TreadmillDriver plosDriver

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values
Constructor Detail

SSGCspy

public SSGCspy()
Method Detail

startGCspyServer

public final void startGCspyServer(int port,
                                   boolean wait)
Start the server and wait if necessary. This method has the following responsibilities.
  1. Create and initialise the GCspy server by calling.
    server = ServerInterpreter.init(name, portNumber, verbose);
  2. Add each event to the ServerInterpreter
    server.addEvent(eventID, eventName);
  3. Set some general information about the server (e.g. name of the collector, build, etc).
    server.setGeneralInfo(info); 
  4. Create new drivers for each component to be visualised.
    myDriver = new MyDriver(server, args...);
    Drivers extend AbstractDriver and register their spce with the ServerInterpreter. In addition to the server, drivers will take as arguments the name of the space, the MMTk space, the tilesize, and whether this space is to be the main space in the visualiser.
WARNING: allocates memory.

Overrides:
startGCspyServer in class Plan
Parameters:
wait - Whether to wait
port - The port to talk to the GCspy client (e.g. visualiser)

newLinearSpaceDriver

private LinearSpaceDriver newLinearSpaceDriver(String name,
                                               CopySpace space,
                                               boolean mainSpace)
Create a new LinearSpaceDriver TODO is this the best name or should we call it LargeObjectSpaceDriver?

Parameters:
name - Name of the space
space - The space
Returns:
A new GCspy driver for this space

newTreadmillDriver

private TreadmillDriver newTreadmillDriver(String name,
                                           LargeObjectSpace space)
Create a new TreadmillDriver TODO is this the best name or should we call it LargeObjectSpaceDriver?

Parameters:
name - Name of the space
space - The space
Returns:
A new GCspy driver for this space

collectionPhase

public void collectionPhase(short phaseId)
Perform a (global) collection phase.

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

gcspyGatherData

private void gcspyGatherData(int event)
Gather data for GCspy for the semispaces, the immortal space and the large object space.

This method sweeps the semispace under consideration to gather data. Alternatively and more efficiently, 'used space' can obviously be discovered in constant time simply by comparing the start and the end addresses of the semispace. However, per-object information can only be gathered by sweeping through the space and we do this here for tutorial purposes.

Parameters:
event - The event, either BEFORE_COLLECTION, SEMISPACE_COPIED or AFTER_COLLECTION

getPagesUsed

public final int getPagesUsed()
Return the number of pages reserved for use given the pending allocation. This is exclusive of space reserved for copying.

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

reportSpaces

static void reportSpaces()
Report information on the semispaces


registerSpecializedMethods

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

Overrides:
registerSpecializedMethods in class SS