|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mmtk.utility.alloc.Allocator
public abstract class Allocator
This abstract base class provides the basis for processor-local allocation. The key functionality provided is the retry mechanism that is necessary to correctly handle the fact that a "slow-path" allocation can cause a GC which violate the uninterruptability assumption. This results in the thread being moved to a different processor so that the allocator object it is using is not actually the one for the processor it is running on.
This class also includes functionality to assist allocators with ensuring that requests are aligned according to requests.
Failing to handle this properly will lead to very hard to trace bugs where the allocation that caused a GC or allocations immediately following GC are run incorrectly.
Field Summary | |
---|---|
private static boolean |
allocationSuccess
Has an allocation succeeded since the emergency collection? |
private static int |
collectionAttempts
Maximum number of failed attempts by a single thread |
private static Lock |
oomLock
Lock used for out of memory handling |
Constructor Summary | |
---|---|
Allocator()
|
Method Summary | |
---|---|
static Address |
alignAllocation(Address region,
int alignment,
int offset)
Aligns up an allocation request. |
static Address |
alignAllocation(Address region,
int alignment,
int offset,
int knownAlignment,
boolean fillAlignmentGap)
Aligns up an allocation request. |
static Address |
alignAllocationNoFill(Address region,
int alignment,
int offset)
Aligns up an allocation request. |
Address |
allocSlow(int bytes,
int alignment,
int offset)
Out-of-line slow path allocation. |
Address |
allocSlowInline(int bytes,
int alignment,
int offset)
Inline slow path allocation. |
protected abstract Address |
allocSlowOnce(int bytes,
int alignment,
int offset)
Single slow path allocation attempt. |
static int |
determineCollectionAttempts()
|
static void |
fillAlignmentGap(Address start,
Address end)
Fill the specified region with the alignment value. |
static int |
getMaximumAlignedSize(int size,
int alignment)
This method calculates the minimum size that will guarantee the allocation of a specified number of bytes at the specified alignment. |
static int |
getMaximumAlignedSize(int size,
int alignment,
int knownAlignment)
This method calculates the minimum size that will guarantee the allocation of a specified number of bytes at the specified alignment. |
protected abstract Space |
getSpace()
Return the space this allocator is currently bound to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static Lock oomLock
private static volatile boolean allocationSuccess
private static int collectionAttempts
Constructor Detail |
---|
public Allocator()
Method Detail |
---|
public static int determineCollectionAttempts()
protected abstract Space getSpace()
public static Address alignAllocation(Address region, int alignment, int offset, int knownAlignment, boolean fillAlignmentGap)
region
- The region to align up.alignment
- The requested alignmentoffset
- The offset from the alignmentknownAlignment
- The statically known minimum alignment.
public static void fillAlignmentGap(Address start, Address end)
start
- The start of the region.end
- A pointer past the end of the region.public static Address alignAllocation(Address region, int alignment, int offset)
region
- The region to align up.alignment
- The requested alignmentoffset
- The offset from the alignment
public static Address alignAllocationNoFill(Address region, int alignment, int offset)
region
- The region to align up.alignment
- The requested alignmentoffset
- The offset from the alignment
public static int getMaximumAlignedSize(int size, int alignment)
size
- The number of bytes (not aligned).alignment
- The requested alignment (some factor of 2).public static int getMaximumAlignedSize(int size, int alignment, int knownAlignment)
size
- The number of bytes (not aligned).alignment
- The requested alignment (some factor of 2).knownAlignment
- The known minimum alignment. Specifically for use in
allocators that enforce greater than particle alignment. It is a precondition
that size is aligned to knownAlignment, and that knownAlignment >= MIN_ALGINMENT.protected abstract Address allocSlowOnce(int bytes, int alignment, int offset)
bytes
- The size of the allocation requestalignment
- The required alignmentoffset
- The alignment offset
public final Address allocSlow(int bytes, int alignment, int offset)
bytes
- The size of the allocation requestalignment
- The required alignmentoffset
- The alignment offset
public final Address allocSlowInline(int bytes, int alignment, int offset)
bytes
- The size of the allocation requestalignment
- The required alignmentoffset
- The alignment offset
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |