org.mmtk.policy.immix
Class ImmixSpace

java.lang.Object
  extended by org.mmtk.policy.Space
      extended by org.mmtk.policy.immix.ImmixSpace
All Implemented Interfaces:
Constants

public final class ImmixSpace
extends Space
implements Constants

Each instance of this class corresponds to one immix space. Each of the instance methods of this class may be called by any thread (i.e. synchronization must be explicit in any instance or class method). This contrasts with the SquishLocal, where instances correspond to *plan* instances and therefore to kernel threads. Thus unlike this class, synchronization is not necessary in the instance methods of SquishLocal.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmtk.policy.Space
Space.SpaceVisitor
 
Field Summary
private  Address allocBlockCursor
           
private  Address allocBlockSentinel
           
private  ChunkList chunkMap
           
private  Defrag defrag
           
private  boolean exhaustedReusableSpace
           
private  Lock gcLock
           
private  boolean inCollection
           
(package private)  byte lineMarkState
           
private  int linesConsumed
           
private  byte lineUnavailState
           
private  byte markState
           
private  Lock mutatorLock
           
private static short reusableMarkStateThreshold
           
 
Fields inherited from class org.mmtk.policy.Space
AVAILABLE_BYTES, AVAILABLE_END, AVAILABLE_PAGES, AVAILABLE_START, BYTES_IN_CHUNK, contiguous, descriptor, extent, headDiscontiguousRegion, HEAP_END, HEAP_START, immortal, LOG_ADDRESS_SPACE, LOG_BYTES_IN_CHUNK, MAX_CHUNKS, MAX_SPACES, movable, PAGES_IN_CHUNK, pr, start, zeroed
 
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
ImmixSpace(String name, boolean zeroed, VMRequest vmRequest)
          The caller specifies the region of virtual memory to be used for this space.
ImmixSpace(String name, VMRequest vmRequest)
          The caller specifies the region of virtual memory to be used for this space.
 
Method Summary
 Address acquireReusableBlocks()
           
 boolean copyNurseryIsLive(ObjectReference object)
          Test the liveness of an object during copying sticky mark bits collection
 void decideWhetherToDefrag(boolean emergencyCollection, boolean collectWholeHeap, int collectionAttempt, boolean userTriggeredCollection)
          Determine the collection kind.
 int defragHeadroomPages()
          Return the amount of headroom required to allow defrag, so this can be included in a collection reserve.
 boolean fastIsLive(ObjectReference object)
          Test the liveness of an object during defragmentation
 ObjectReference fastTraceObject(TransitiveClosure trace, ObjectReference object)
          Trace a reference to an object in the context of a non-moving collection.
(package private)  int getAvailableLines(int[] spillAvailHistogram)
          Establish the number of recyclable lines lines available for allocation during defragmentation, populating the spillAvailHistogram, which buckets available lines according to the number of holes on the block on which the available lines reside.
(package private)  ChunkList getChunkMap()
           
(package private)  Defrag getDefrag()
           
 int getNextAvailableLine(Address baseLineAvailAddress, int line)
           
 int getNextUnavailableLine(Address baseLineAvailAddress, int line)
           
 int getPagesAllocated()
          Return the number of pages allocated since the last collection
static short getReusuableMarkStateThreshold(boolean forDefrag)
          Return the reusable mark state threshold, which determines how eagerly lines should be recycled (by default these values are set so that all lines are recycled).
 Address getSpace(boolean hot, boolean copy, int lineUseCount)
          Return a pointer to a set of new usable blocks, or null if none are available.
private  int getUsableLinesInRegion(Address start, Address end, int[] spillAvailHistogram)
          Return the number of lines usable for allocation during defragmentation in the address range specified by start and end.
 void growSpace(Address start, Extent bytes, boolean newChunk)
          This hook is called by page resources each time a space grows.
 boolean inImmixCollection()
          Return true if this space is currently being collected.
 boolean inImmixDefragCollection()
          Return true if this space is currently being defraged.
 boolean isDefragSource(Address address)
           
private  boolean isDefragSource(ObjectReference object)
           
 boolean isLive(ObjectReference object)
          Generic test of the liveness of an object
static boolean isRecycleAllocChunkAligned(Address ptr)
           
private  void lock()
          Acquire the appropriate lock depending on whether the context is GC or mutator.
 void markLines(ObjectReference object)
          Mark the line/s associated with a given object.
 ObjectReference nurseryTraceObject(TransitiveClosure trace, ObjectReference object, int allocator)
          Trace a reference to an object during a nursery collection for a sticky mark bits implementation of immix.
 void postAlloc(ObjectReference object, int bytes)
          Perform any required post allocation initialization
 void postCopy(ObjectReference object, int bytes, boolean majorGC)
          Perform any required post copy (i.e. in-GC allocation) initialization.
 void prepare(boolean majorGC)
          Prepare for a new collection increment.
 void release(Address block)
          Release a block.
 boolean release(boolean majorGC)
          A new collection increment has completed.
 int releaseDiscontiguousChunks(Address chunk)
          Release one or more contiguous chunks associated with a discontiguous space.
 ObjectReference traceObject(TransitiveClosure trace, ObjectReference object)
          Trace a reference to an object.
 ObjectReference traceObject(TransitiveClosure trace, ObjectReference object, int allocator)
          Trace a reference to an object.
private  ObjectReference traceObjectWithOpportunisticCopy(TransitiveClosure trace, ObjectReference object, int allocator, boolean nurseryCollection)
          Trace a reference to an object, forwarding the object if appropriate If the object is not already marked, mark the object and enqueue it for subsequent processing.
private  void traceObjectWithoutMoving(TransitiveClosure trace, ObjectReference object)
          Trace a reference to an object in the context of a non-moving collection.
private  void unlock()
          Release the appropriate lock depending on whether the context is GC or mutator.
 boolean willNotMoveThisGC(Address address)
           
 boolean willNotMoveThisGC(ObjectReference object)
           
 boolean willNotMoveThisNurseryGC(ObjectReference object)
           
 
Methods inherited from class org.mmtk.policy.Space
acquire, availablePhysicalPages, chunkAlign, chunkAlign, committedPages, cumulativeCommittedPages, eagerlyMmapMMTkContiguousSpaces, eagerlyMmapMMTkDiscontiguousSpaces, eagerlyMmapMMTkSpaces, getDescriptor, getDiscontigEnd, getDiscontigStart, getExtent, getFracAvailable, getHeadDiscontiguousRegion, getIndex, getName, getSpaceForAddress, getSpaceForObject, getStart, growDiscontiguousSpace, isImmortal, isImmortal, isInSpace, isInSpace, isMappedAddress, isMappedObject, isMovable, isMovable, isReachable, printUsageMB, printUsagePages, printVMMap, releaseAllChunks, requiredChunks, reservedPages, setZeroingApproach, skipConcurrentZeroing, triggerConcurrentZeroing, visitSpaces
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reusableMarkStateThreshold

private static short reusableMarkStateThreshold

markState

private byte markState

lineMarkState

byte lineMarkState

lineUnavailState

private byte lineUnavailState

inCollection

private boolean inCollection

linesConsumed

private int linesConsumed

mutatorLock

private Lock mutatorLock

gcLock

private Lock gcLock

allocBlockCursor

private Address allocBlockCursor

allocBlockSentinel

private Address allocBlockSentinel

exhaustedReusableSpace

private boolean exhaustedReusableSpace

chunkMap

private final ChunkList chunkMap

defrag

private final Defrag defrag
Constructor Detail

ImmixSpace

public ImmixSpace(String name,
                  VMRequest vmRequest)
The caller specifies the region of virtual memory to be used for this space. If this region conflicts with an existing space, then the constructor will fail.

Parameters:
name - The name of this space (used when printing error messages etc)
vmRequest - The virtual memory request

ImmixSpace

public ImmixSpace(String name,
                  boolean zeroed,
                  VMRequest vmRequest)
The caller specifies the region of virtual memory to be used for this space. If this region conflicts with an existing space, then the constructor will fail.

Parameters:
name - The name of this space (used when printing error messages etc)
zeroed - if true, allocations return zeroed memory
vmRequest - The virtual memory request
Method Detail

prepare

public void prepare(boolean majorGC)
Prepare for a new collection increment.


release

public boolean release(boolean majorGC)
A new collection increment has completed. Release global resources.

Parameters:
majorGC - TODO

decideWhetherToDefrag

public void decideWhetherToDefrag(boolean emergencyCollection,
                                  boolean collectWholeHeap,
                                  int collectionAttempt,
                                  boolean userTriggeredCollection)
Determine the collection kind.

Parameters:
emergencyCollection - Is this collection an emergency (last did not yield enough)?
collectWholeHeap - Is this a whole heap collection?
collectionAttempt - Which attempt is this to collect?
userTriggeredCollection - Was this collection requested by the user?

defragHeadroomPages

public int defragHeadroomPages()
Return the amount of headroom required to allow defrag, so this can be included in a collection reserve.

Returns:
The number of pages.

inImmixCollection

public boolean inImmixCollection()
Return true if this space is currently being collected.

Returns:
true if this space is currently being collected.

inImmixDefragCollection

public boolean inImmixDefragCollection()
Return true if this space is currently being defraged.

Returns:
true if this space is currently being defraged.

getPagesAllocated

public int getPagesAllocated()
Return the number of pages allocated since the last collection

Returns:
The number of pages allocated since the last collection

getReusuableMarkStateThreshold

public static short getReusuableMarkStateThreshold(boolean forDefrag)
Return the reusable mark state threshold, which determines how eagerly lines should be recycled (by default these values are set so that all lines are recycled).

Parameters:
forDefrag - The query is the context of a defragmenting collection
Returns:
The reusable mark state threshold

getSpace

public Address getSpace(boolean hot,
                        boolean copy,
                        int lineUseCount)
Return a pointer to a set of new usable blocks, or null if none are available. Use different block selection heuristics depending on whether the allocation request is "hot" or "cold".

Parameters:
hot - True if the requesting context is for hot allocations (used for allocations from high allocation volume sites).
Returns:
The pointer into the alloc table containing usable blocks.

growSpace

public void growSpace(Address start,
                      Extent bytes,
                      boolean newChunk)
Description copied from class: Space
This hook is called by page resources each time a space grows. The space may tap into the hook to monitor heap growth. The call is made from within the page resources' critical region, immediately before yielding the lock.

Overrides:
growSpace in class Space
Parameters:
start - The start of the newly allocated space
bytes - The size of the newly allocated space
newChunk - true if the new space encroached upon or started a new chunk or chunks.

acquireReusableBlocks

public Address acquireReusableBlocks()

release

public void release(Address block)
Release a block. A block is free, so call the underlying page allocator to release the associated storage.

Specified by:
release in class Space
Parameters:
block - The address of the block to be released

releaseDiscontiguousChunks

public int releaseDiscontiguousChunks(Address chunk)
Release one or more contiguous chunks associated with a discontiguous space.

This hook is called by the page level allocators whenever a complete discontiguous chunk is released.

Overrides:
releaseDiscontiguousChunks in class Space
Parameters:
chunk - The address of the start of the contiguous chunk or chunks
Returns:
The number of chunks freed

postAlloc

public void postAlloc(ObjectReference object,
                      int bytes)
Perform any required post allocation initialization

Parameters:
object - the object ref to the storage to be initialized

postCopy

public void postCopy(ObjectReference object,
                     int bytes,
                     boolean majorGC)
Perform any required post copy (i.e. in-GC allocation) initialization. This is relevant (for example) when Squish is used as the mature space in a copying GC.

Parameters:
object - the object ref to the storage to be initialized
majorGC - Is this copy happening during a major gc?

traceObject

public ObjectReference traceObject(TransitiveClosure trace,
                                   ObjectReference object,
                                   int allocator)
Trace a reference to an object. If the object header is not already marked, mark the object and enqueue it for subsequent processing.

Parameters:
trace - The trace performing the transitive closure
object - The object to be traced.
allocator - The allocator to which any copying should be directed
Returns:
The object, which may have been moved.

fastTraceObject

public ObjectReference fastTraceObject(TransitiveClosure trace,
                                       ObjectReference object)
Trace a reference to an object in the context of a non-moving collection. This call is optimized for the simpler non-moving case.

Parameters:
trace - The trace performing the transitive closure
object - The object to be traced.
Returns:
The object (there is no object forwarding in this trace method, so we always return the same object: this could be a void method but for compliance to a more general interface).

nurseryTraceObject

public ObjectReference nurseryTraceObject(TransitiveClosure trace,
                                          ObjectReference object,
                                          int allocator)
Trace a reference to an object during a nursery collection for a sticky mark bits implementation of immix. If the object header is not already marked, mark the object and enqueue it for subsequent processing.

Parameters:
trace - The trace performing the transitive closure
object - The object to be traced.
allocator - The allocator to which any copying should be directed
Returns:
Either the object or a forwarded object, depending on the policy in place.

traceObject

public ObjectReference traceObject(TransitiveClosure trace,
                                   ObjectReference object)
Trace a reference to an object. This interface is not supported by immix, since we require the allocator to be identified except for the special case of the fast trace.

Specified by:
traceObject in class Space
Parameters:
trace - The trace performing the transitive closure
object - The object to be traced.
Returns:
null and fail.

traceObjectWithoutMoving

private void traceObjectWithoutMoving(TransitiveClosure trace,
                                      ObjectReference object)
Trace a reference to an object in the context of a non-moving collection. This call is optimized for the simpler non-moving case.

Parameters:
trace - The trace performing the transitive closure
object - The object to be traced.

traceObjectWithOpportunisticCopy

private ObjectReference traceObjectWithOpportunisticCopy(TransitiveClosure trace,
                                                         ObjectReference object,
                                                         int allocator,
                                                         boolean nurseryCollection)
Trace a reference to an object, forwarding the object if appropriate If the object is not already marked, mark the object and enqueue it for subsequent processing.

Parameters:
trace - The trace performing the transitive closure
object - The object to be traced.
allocator - The allocator to which any copying should be directed
Returns:
Either the object or a forwarded object, if it was forwarded.

markLines

public void markLines(ObjectReference object)
Mark the line/s associated with a given object. This is distinct from the above tracing code because line marks are stored separately from the object headers (thus both must be set), and also because we found empirically that it was more efficient to perform the line mark of the object during the scan phase (which occurs after the trace phase), presumably because the latency of the associated memory operations was better hidden in the context of that code

Parameters:
object - The object which is live and for which the associated lines must be marked.

getNextUnavailableLine

public int getNextUnavailableLine(Address baseLineAvailAddress,
                                  int line)

getNextAvailableLine

public int getNextAvailableLine(Address baseLineAvailAddress,
                                int line)

getAvailableLines

int getAvailableLines(int[] spillAvailHistogram)
Establish the number of recyclable lines lines available for allocation during defragmentation, populating the spillAvailHistogram, which buckets available lines according to the number of holes on the block on which the available lines reside.

Parameters:
spillAvailHistogram - A histogram of availability to be populated
Returns:
The number of available recyclable lines

getUsableLinesInRegion

private int getUsableLinesInRegion(Address start,
                                   Address end,
                                   int[] spillAvailHistogram)
Return the number of lines usable for allocation during defragmentation in the address range specified by start and end. Populate a histogram to indicate where the usable lines reside as a function of block hole count.

Parameters:
start - The start of the region to be checked for availability
end - The end of the region to be checked for availability
spillAvailHistogram - The histogram which will be populated
Returns:
The number of usable lines

isLive

public boolean isLive(ObjectReference object)
Generic test of the liveness of an object

Specified by:
isLive in class Space
Parameters:
object - The object in question
Returns:
true if this object is known to be live (i.e. it is marked)

copyNurseryIsLive

public boolean copyNurseryIsLive(ObjectReference object)
Test the liveness of an object during copying sticky mark bits collection

Parameters:
object - The object in question
Returns:
True if this object is known to be live (i.e. it is marked)

fastIsLive

public boolean fastIsLive(ObjectReference object)
Test the liveness of an object during defragmentation

Parameters:
object - The object in question
Returns:
true if this object is known to be live (i.e. it is marked)

willNotMoveThisGC

public boolean willNotMoveThisGC(ObjectReference object)

willNotMoveThisNurseryGC

public boolean willNotMoveThisNurseryGC(ObjectReference object)

isDefragSource

private boolean isDefragSource(ObjectReference object)

willNotMoveThisGC

public boolean willNotMoveThisGC(Address address)

isDefragSource

public boolean isDefragSource(Address address)

lock

private void lock()
Acquire the appropriate lock depending on whether the context is GC or mutator.


unlock

private void unlock()
Release the appropriate lock depending on whether the context is GC or mutator.


isRecycleAllocChunkAligned

public static boolean isRecycleAllocChunkAligned(Address ptr)

getChunkMap

ChunkList getChunkMap()

getDefrag

Defrag getDefrag()