public abstract class SegregatedFreeListLocal<S extends SegregatedFreeListSpace> extends SegregatedFreeList<S>
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.
Modifier and Type | Field and Description |
---|---|
protected AddressArray |
currentBlock |
freeList, space
Constructor and Description |
---|
SegregatedFreeListLocal(S space)
Constructor
|
Modifier and Type | Method and Description |
---|---|
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. |
alloc, getSpace
alignAllocation, alignAllocation, alignAllocationNoFill, allocSlow, allocSlowInline, determineCollectionAttempts, fillAlignmentGap, getMaximumAlignedSize, getMaximumAlignedSize
protected final AddressArray currentBlock
public SegregatedFreeListLocal(S space)
space
- The space with which this allocator will be associatedpublic final Address allocSlowOnce(int bytes, int align, int offset)
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).
allocSlowOnce
in class Allocator
bytes
- The size of the object to occupy this space, in bytes.offset
- The alignment offset.align
- The requested alignment.public final void flush()
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.