|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mmtk.policy.Space org.mmtk.policy.SegregatedFreeListSpace
public abstract class SegregatedFreeListSpace
Each instance of this class corresponds to one mark-sweep *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 MarkSweepLocal, where instances correspond to *plan* instances and therefore to kernel threads. Thus unlike this class, synchronization is not necessary in the instance methods of MarkSweepLocal.
Nested Class Summary | |
---|---|
static class |
SegregatedFreeListSpace.Sweeper
A callback used to perform sweeping of a free list space. |
Nested classes/interfaces inherited from class org.mmtk.policy.Space |
---|
Space.SpaceVisitor |
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 |
Constructor Summary | |
---|---|
SegregatedFreeListSpace(String name,
int additionalMetadata,
VMRequest vmRequest)
The caller specifies the region of virtual memory to be used for this space. |
Method Summary | |
---|---|
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)
Set the live bit for a given address |
protected static boolean |
liveBitSet(ObjectReference object)
Test the live bit for a given object |
protected abstract boolean |
maintainSideBitmap()
Should SegregatedFreeListSpace manage a side bitmap to keep track of live objects? |
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)
Sweep a block, freeing it and making it available if any live cells were found. |
protected abstract boolean |
preserveFreeList()
Do we need to preserve free lists as we move blocks around. |
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)
Return 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()
The number of distinct size classes. |
protected Address |
sweepBlock(Address block,
int sizeClass,
Extent blockSize,
Address availableHead,
boolean clearMarks)
Sweep a block, freeing it and adding to the list given by availableHead if it contains no free objects. |
void |
sweepCells(SegregatedFreeListSpace.Sweeper sweeper)
Sweep all blocks for free objects. |
boolean |
sweepCells(SegregatedFreeListSpace.Sweeper sweeper,
Address block,
int sizeClass)
Does this block contain any live cells? |
private Address |
sweepCells(SegregatedFreeListSpace.Sweeper sweeper,
Address block,
int sizeClass,
Address availableHead)
Sweep 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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 Lock lock
protected final AddressArray consumedBlockHead
protected final AddressArray flushedBlockHead
protected final AddressArray availableBlockHead
private final int[] cellSize
private final byte[] blockSizeClass
private final int[] blockHeaderSize
Constructor Detail |
---|
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.Method Detail |
---|
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 populate
private 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 question
public 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 query
true
if the cell should be reclaimedprotected final Address getFreeList(Address block)
block
- The block whose free list is to be found
protected 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)
clearMarks
- 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 object
true
if the cell is liveprotected final Address makeFreeList(Address block, int sizeClass)
block
- The block to be processedsizeClass
- The size class for the block
public void sweepCells(SegregatedFreeListSpace.Sweeper sweeper)
private Address sweepCells(SegregatedFreeListSpace.Sweeper sweeper, Address block, int sizeClass, Address availableHead)
public void parallelSweepCells(SegregatedFreeListSpace.Sweeper sweeper)
This is designed to be called in parallel by multiple collector threads.
private 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)
object
- The object whose live bit is to be set.protected static boolean liveBitSet(Address address)
address
- The address whose live bit is to be set.
true
if this operation changed the state of the live bit.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)
protected void zeroLiveBits()
private static Address alignToLiveStride(Address address)
address
- The address to be aligned to a live word
private 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
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |