org.mmtk.utility.alloc
Class SegregatedFreeListLocal<S extends SegregatedFreeListSpace>

java.lang.Object
  extended by org.mmtk.utility.alloc.Allocator
      extended by org.mmtk.utility.alloc.SegregatedFreeList<S>
          extended by org.mmtk.utility.alloc.SegregatedFreeListLocal<S>
All Implemented Interfaces:
Constants
Direct Known Subclasses:
ExplicitFreeListLocal, MarkSweepLocal

public abstract class SegregatedFreeListLocal<S extends SegregatedFreeListSpace>
extends SegregatedFreeList<S>
implements Constants

This abstract class implements a simple segregated free list.

See: Wilson, Johnstone, Neely and Boles "Dynamic Storage Allocation: A Survey and Critical Review", IWMM 1995, for an overview of free list allocation and the various implementation strategies, including segregated free lists.

We maintain a number of size classes, each size class having a free list of available objects of that size (the list may be empty). We call the storage elements "cells". Cells reside within chunks of memory called "blocks". All cells in a given block are of the same size (i.e. blocks are homogeneous with respect to size class). Each block maintains its own free list (free cells within that block). For each size class a list of blocks is maintained, one of which will serve the role of the current free list. When the free list on the current block is exhausted, the next block for that size class becomes the current block and its free list is used. If there are no more blocks the a new block is allocated.


Field Summary
protected  AddressArray currentBlock
           
 
Fields inherited from class org.mmtk.utility.alloc.SegregatedFreeList
freeList, space
 
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
SegregatedFreeListLocal(S space)
          Constructor
 
Method Summary
 Address allocSlowOnce(int bytes, int align, int offset)
          Allocate bytes contiguous bytes of non-zeroed memory.
 void flush()
          Zero all of the current free list pointers, and refresh the currentBlock values, so instead of the free list pointing to free cells, it points to the block containing the free cells.
 
Methods inherited from class org.mmtk.utility.alloc.SegregatedFreeList
alloc, getSpace
 
Methods inherited from class org.mmtk.utility.alloc.Allocator
alignAllocation, alignAllocation, alignAllocationNoFill, allocSlow, allocSlowInline, determineCollectionAttempts, fillAlignmentGap, getMaximumAlignedSize, getMaximumAlignedSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentBlock

protected final AddressArray currentBlock
Constructor Detail

SegregatedFreeListLocal

public SegregatedFreeListLocal(S space)
Constructor

Parameters:
space - The space with which this allocator will be associated
Method Detail

allocSlowOnce

public final Address allocSlowOnce(int bytes,
                                   int align,
                                   int offset)
Allocate bytes contiguous bytes of non-zeroed memory. First check if the fast path works. This is needed since this method may be called in the context when the fast version was NOT just called. If this fails, it will try finding another block with a non-empty free list, or allocating a new block.

This code should be relatively infrequently executed, so it is forced out of line to reduce pressure on the compilation of the core alloc routine.

Precondition: None

Postconditions: A new cell has been allocated (not zeroed), and the block containing the cell has been placed on the appropriate free list data structures. The free list itself is not updated (the caller must do so).

Specified by:
allocSlowOnce in class Allocator
Parameters:
bytes - The size of the object to occupy this space, in bytes.
offset - The alignment offset.
align - The requested alignment.
Returns:
The address of the first word or zero on failure.

flush

public final void flush()
Zero all of the current free list pointers, and refresh the currentBlock values, so instead of the free list pointing to free cells, it points to the block containing the free cells. Then the free lists for each cell can be reestablished during GC. If the free lists are being preserved on a per-block basis (eager mark-sweep and reference counting), then free lists are remembered for each block.