public abstract class SegregatedFreeListSpace extends Space
Modifier and Type | Class and Description |
---|---|
static class |
SegregatedFreeListSpace.Sweeper
A callback used to perform sweeping of a free list space.
|
Space.SpaceVisitor
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
Constructor and Description |
---|
SegregatedFreeListSpace(String name,
int additionalMetadata,
VMRequest vmRequest)
The caller specifies the region of virtual memory to be used for
this space.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Address |
advanceToBlock(Address block,
int sizeClass)
Prepare a block for allocation, returning a free list into the block.
|
private static Address |
alignToLiveStride(Address address)
Align an address so that it corresponds to a live word boundary.
|
protected void |
clearAllBlockMarks()
Clear all block marks for this space.
|
protected void |
clearBlockMark(Address block,
Extent blockSize)
Clear block marks for a block
|
protected static void |
clearLiveBit(Address address)
Clear the live bit for a given address
|
protected static void |
clearLiveBit(ObjectReference object)
Clear the live bit for a given object
|
protected void |
clearLiveBits(Address block,
int sizeClass)
Clear all live bits for a block.
|
protected void |
consumeBlocks()
Eagerly consume all remaining blocks.
|
protected boolean |
containsLiveCell(Address block,
Extent blockSize,
boolean clearMarks)
Does this block contain any live cells.
|
private Address |
expandSizeClass(int sizeClass,
AddressArray freeList)
Expand a particular size class, allocating a new block, breaking
the block into cells and placing those cells on a free list for
that block.
|
protected void |
flushAvailableBlocks()
Flush all the allocation blocks to the consumed list.
|
Address |
getAllocationBlock(int sizeClass,
AddressArray freeList)
Acquire a new block from the global pool to allocate into.
|
int |
getBaseCellSize(int sc)
Return the size of a basic cell (i.e. not including any cell
header) for a given size class.
|
protected Address |
getFreeList(Address block)
In the case where free lists associated with each block are
preserved, get the free list for a given block.
|
private static Address |
getLiveWordAddress(Address address)
Given an address, return the address of the live word for
that address.
|
private static Word |
getMask(Address address,
boolean set)
Given an address, produce a bit mask for the live table
|
int |
getSizeClass(int bytes)
Get the size class for a given number of bytes.
|
private Address |
getSweepBlock(int sizeClass)
Get a block for a parallel sweep.
|
private void |
initSizeClasses()
Initialize the size class data structures.
|
protected boolean |
isCellLive(ObjectReference object)
In the cell containing this object live?
|
protected static boolean |
liveBitSet(Address address) |
protected static boolean |
liveBitSet(ObjectReference object) |
protected abstract boolean |
maintainSideBitmap() |
protected Address |
makeFreeList(Address block,
int sizeClass)
Use the live bits for a block to infer free cells and thus
construct a free list for the block.
|
protected static void |
markBlock(Address block)
Set the live bit for the given block.
|
protected static void |
markBlock(ObjectReference object)
Set the live bit for the block containing the given object
|
protected void |
notifyNewBlock(Address block,
int sizeClass)
Notify that a new block has been installed.
|
void |
parallelSweepCells(SegregatedFreeListSpace.Sweeper sweeper)
Sweeps a block, freeing it and making it available if any live cells were found.
|
protected abstract boolean |
preserveFreeList() |
protected boolean |
reclaimCellForObject(ObjectReference object)
Should the sweep reclaim the cell containing this object.
|
void |
returnBlock(Address block,
int sizeClass,
Address freeCell)
Return a block to the global pool.
|
void |
returnConsumedBlock(Address block,
int sizeClass)
Returns a block to the global pool.
|
protected void |
setFreeList(Address block,
Address cell)
In the case where free lists associated with each block are
preserved, set the free list for a given block.
|
static int |
sizeClassCount() |
protected Address |
sweepBlock(Address block,
int sizeClass,
Extent blockSize,
Address availableHead,
boolean clearMarks)
Sweeps a block, freeing it and adding to the list given by availableHead
if it contains no free objects.
|
void |
sweepCells(SegregatedFreeListSpace.Sweeper sweeper)
Sweeps all blocks for free objects.
|
boolean |
sweepCells(SegregatedFreeListSpace.Sweeper sweeper,
Address block,
int sizeClass) |
private Address |
sweepCells(SegregatedFreeListSpace.Sweeper sweeper,
Address block,
int sizeClass,
Address availableHead)
Sweeps a block, freeing it and adding to the list given by availableHead
if it contains no free objects.
|
protected void |
sweepConsumedBlocks(boolean clearMarks)
Sweep all blocks for free objects.
|
static boolean |
testAndSetLiveBit(ObjectReference object)
Atomically set the live bit for a given object
|
protected static void |
unsyncClearLiveBit(Address address)
Clear the live bit for a given address
|
protected static void |
unsyncClearLiveBit(ObjectReference object)
Clear the live bit for a given object
|
static boolean |
unsyncSetLiveBit(ObjectReference object)
Set the live bit for a given object, without using
synchronization primitives---must only be used when contention
for live bit is strictly not possible
|
private static boolean |
updateLiveBit(Address address,
boolean set,
boolean atomic)
Set the live bit for a given address
|
protected void |
zeroLiveBits() |
acquire, availablePhysicalPages, chunkAlign, chunkAlign, committedPages, cumulativeCommittedPages, eagerlyMmapMMTkContiguousSpaces, eagerlyMmapMMTkDiscontiguousSpaces, eagerlyMmapMMTkSpaces, getDescriptor, getDiscontigEnd, getDiscontigStart, getExtent, getFracAvailable, getHeadDiscontiguousRegion, getIndex, getName, getSpaceCount, getSpaceForAddress, getSpaceForObject, getSpaces, getStart, growDiscontiguousSpace, growSpace, isImmortal, isImmortal, isInSpace, isInSpace, isLive, isMappedAddress, isMappedObject, isMovable, isMovable, isReachable, printUsageMB, printUsagePages, printVMMap, release, releaseAllChunks, releaseDiscontiguousChunks, requiredChunks, reservedPages, setZeroingApproach, skipConcurrentZeroing, traceObject, triggerConcurrentZeroing, visitSpaces
protected static final boolean LAZY_SWEEP
private static final boolean COMPACT_SIZE_CLASSES
protected static final int MIN_CELLS
protected static final int MAX_CELLS
protected static final int MAX_CELL_SIZE
public static final int MAX_FREELIST_OBJECT_BYTES
private static final int OBJECT_LIVE_SHIFT
private static final int LOG_BIT_COVERAGE
private static final int LOG_LIVE_COVERAGE
private static final int LIVE_BYTES_PER_REGION
private static final Word WORD_SHIFT_MASK
private static final int LOG_LIVE_WORD_STRIDE
private static final Extent LIVE_WORD_STRIDE
private static final Word LIVE_WORD_STRIDE_MASK
private static final int NET_META_DATA_BYTES_PER_REGION
protected static final int META_DATA_PAGES_PER_REGION_WITH_BITMAP
protected static final int META_DATA_PAGES_PER_REGION_NO_BITMAP
private static final Extent META_DATA_OFFSET
private static final int NEW_SIZECLASS_OVERHEAD
private static final int METADATA_OVERHEAD
public static final float WORST_CASE_FRAGMENTATION
protected final AddressArray consumedBlockHead
protected final AddressArray flushedBlockHead
protected final AddressArray availableBlockHead
private final int[] cellSize
private final byte[] blockSizeClass
private final int[] blockHeaderSize
public SegregatedFreeListSpace(String name, int additionalMetadata, VMRequest vmRequest)
name
- The name of this space (used when printing error messages etc)additionalMetadata
- The number of meta data bytes per region for the subclass.vmRequest
- An object describing the virtual memory requested.protected abstract boolean maintainSideBitmap()
protected abstract boolean preserveFreeList()
public void returnConsumedBlock(Address block, int sizeClass)
block
- The block to returnsizeClass
- The size classpublic void returnBlock(Address block, int sizeClass, Address freeCell)
block
- The block to returnsizeClass
- The size classfreeCell
- The first free cell in the block.public Address getAllocationBlock(int sizeClass, AddressArray freeList)
sizeClass
- The size class to allocate intofreeList
- The free list to populateprivate Address expandSizeClass(int sizeClass, AddressArray freeList)
This is guaranteed to return pre-zeroed cells
sizeClass
- The size class to be expandedfreeList
- The free list to populate.private void initSizeClasses()
public final int getSizeClass(int bytes)
We use size classes based on a worst case internal fragmentation loss target of 1/8. In fact, across sizes from 8 bytes to 512 the average worst case loss is 13.3%, giving an expected loss (assuming uniform distribution) of about 7%. We avoid using the Lea class sizes because they were so numerous and therefore liable to lead to excessive inter-class-size fragmentation.
This method may segregate arrays and scalars (currently it does not).
This method should be more intelligent and take alignment requests into consideration. The issue with this is that the block header which can be varied by subclasses can change the alignment of the cells.
bytes
- The number of bytes required to accommodate the object
to be allocated.public final int getBaseCellSize(int sc)
sc
- The size class in questionpublic static int sizeClassCount()
protected abstract Address advanceToBlock(Address block, int sizeClass)
block
- The new blocksizeClass
- The block's sizeclass.protected void notifyNewBlock(Address block, int sizeClass)
block
- The new blocksizeClass
- The block's sizeclass.protected boolean reclaimCellForObject(ObjectReference object)
object
- The object to querytrue
if the cell should be reclaimedprotected final Address getFreeList(Address block)
block
- The block whose free list is to be foundprotected final void setFreeList(Address block, Address cell)
block
- The block whose free list is to be foundcell
- The head of the free list (i.e. the first cell in the
free list).protected final void clearAllBlockMarks()
protected final void sweepConsumedBlocks(boolean clearMarks)
clearMarks
- should we clear block mark bits as we process.protected final Address sweepBlock(Address block, int sizeClass, Extent blockSize, Address availableHead, boolean clearMarks)
block
- the block's addresssizeClass
- the block's size classblockSize
- the block's size, in bytesavailableHead
- the head of the blocks that still need to be sweptclearMarks
- should we clear block mark bits as we process.protected final void consumeBlocks()
protected final void flushAvailableBlocks()
protected boolean containsLiveCell(Address block, Extent blockSize, boolean clearMarks)
block
- The blockblockSize
- The size of the blockclearMarks
- should we clear block mark bits as we process.true
if any cells in the block are liveprotected void clearBlockMark(Address block, Extent blockSize)
block
- The blockblockSize
- The size of the blockprotected boolean isCellLive(ObjectReference object)
object
- The objecttrue
if the cell is liveprotected final Address makeFreeList(Address block, int sizeClass)
block
- The block to be processedsizeClass
- The size class for the blockpublic void sweepCells(SegregatedFreeListSpace.Sweeper sweeper)
sweeper
- the sweeper to useprivate Address sweepCells(SegregatedFreeListSpace.Sweeper sweeper, Address block, int sizeClass, Address availableHead)
sweeper
- the sweeper to useblock
- the block's addresssizeClass
- the block's size classavailableHead
- the head of the blocks that still need to be sweptpublic void parallelSweepCells(SegregatedFreeListSpace.Sweeper sweeper)
This is designed to be called in parallel by multiple collector threads.
sweeper
- the sweeper to useprivate Address getSweepBlock(int sizeClass)
sizeClass
- The size class of the block to sweep.public boolean sweepCells(SegregatedFreeListSpace.Sweeper sweeper, Address block, int sizeClass)
public static boolean testAndSetLiveBit(ObjectReference object)
object
- The object whose live bit is to be set.true
if the bit was changed to true.protected static void markBlock(ObjectReference object)
object
- The object whose blocks liveness is to be set.protected static void markBlock(Address block)
block
- The block whose liveness is to be set.public static boolean unsyncSetLiveBit(ObjectReference object)
object
- The object whose live bit is to be set.private static boolean updateLiveBit(Address address, boolean set, boolean atomic)
address
- The address whose live bit is to be set.set
- true
if the bit is to be set, as opposed to clearedatomic
- true
if we want to perform this operation atomicallyprotected static boolean liveBitSet(ObjectReference object)
protected static boolean liveBitSet(Address address)
protected static void clearLiveBit(ObjectReference object)
object
- The object whose live bit is to be cleared.protected static void clearLiveBit(Address address)
address
- The address whose live bit is to be cleared.protected static void unsyncClearLiveBit(ObjectReference object)
object
- The object whose live bit is to be cleared.protected static void unsyncClearLiveBit(Address address)
address
- The address whose live bit is to be cleared.protected void clearLiveBits(Address block, int sizeClass)
block
- the block's addresssizeClass
- the block's size classprotected void zeroLiveBits()
private static Address alignToLiveStride(Address address)
address
- The address to be aligned to a live wordprivate static Word getMask(Address address, boolean set)
address
- The address whose live bit mask is to be establishedset
- True if we want the mask for setting the bit,
false if we want the mask for clearing the bit.private static Address getLiveWordAddress(Address address)
address
- The address whose live word address is to be returned