|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object joeq.Allocator.HeapAllocator joeq.Allocator.SimpleAllocator
public class SimpleAllocator
SimpleAllocator is a simple version of a heap allocator. It is basically a bump-pointer allocator with a free list.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class joeq.Allocator.HeapAllocator |
---|
HeapAllocator.HeapPointer |
Field Summary | |
---|---|
static jq_InstanceMethod |
_allocateArray
|
static jq_InstanceMethod |
_allocateArrayAlign8
|
static jq_InstanceMethod |
_allocateObject
|
static jq_InstanceMethod |
_allocateObjectAlign8
|
static jq_Class |
_class
|
static int |
BLOCK_SIZE
Size of blocks allocated from the OS. |
static int |
LARGE_THRESHOLD
Threshold for direct OS allocation. |
static int |
MAX_MEMORY
Maximum memory, in bytes, to be allocated from the OS. |
static int |
MIN_SIZE
Smallest object size allowed in free list. |
static boolean |
NO_GC
|
static boolean |
TRACE_ALLOC
|
static boolean |
TRACE_FREELIST
|
static boolean |
TRACE_GC
|
Fields inherited from class joeq.Allocator.HeapAllocator |
---|
_clsinitAndAllocateObject, _data_segment_end, _data_segment_start, data_segment_end, data_segment_start, TRACE |
Constructor Summary | |
---|---|
SimpleAllocator()
|
Method Summary | |
---|---|
Object |
allocateArray(int length,
int size,
Object vtable)
Allocate an array with the default alignment. |
Object |
allocateArrayAlign8(int length,
int size,
Object vtable)
Allocate an array such that the elements are 8-byte aligned. |
Object |
allocateObject(int size,
Object vtable)
Allocate an object with the default alignment. |
Object |
allocateObjectAlign8(int size,
Object vtable)
Allocate an object such that the first field is 8-byte aligned. |
void |
collect()
Initiate a garbage collection. |
int |
freeMemory()
Returns an estimate of the amount of free memory available. |
static int |
getObjectSize(Object o)
|
void |
init()
Perform initialization for this allocator. |
boolean |
isInHeap(Address a)
Returns whether the given address falls within the boundaries of this heap. |
void |
processObjectReference(Address a)
Process a reference to a heap object during garbage collection. |
void |
processPossibleObjectReference(Address a)
Process a possible reference to a heap object during garbage collection. |
void |
sweep()
|
int |
totalMemory()
Returns an estimate of the total memory allocated (both used and unused). |
Methods inherited from class joeq.Allocator.HeapAllocator |
---|
checkObjectReferences, clone, clsinitAndAllocateObject, getGCBit, getScalarObjectReferenceOffsets, initializeDataSegment, isInDataSegment, isObjectAssignableType, isObjectExactType, isValidArray, isValidArray, isValidArrayType, isValidArrayVTable, isValidHeapAddress, isValidObject, isValidObject, isValidReferenceType, isValidVTable, outOfMemory, setGCBit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean NO_GC
public static boolean TRACE_ALLOC
public static boolean TRACE_FREELIST
public static boolean TRACE_GC
public static final int BLOCK_SIZE
public static int MAX_MEMORY
public static final int LARGE_THRESHOLD
public static final int MIN_SIZE
public static final jq_Class _class
public static final jq_InstanceMethod _allocateObject
public static final jq_InstanceMethod _allocateObjectAlign8
public static final jq_InstanceMethod _allocateArray
public static final jq_InstanceMethod _allocateArrayAlign8
Constructor Detail |
---|
public SimpleAllocator()
Method Detail |
---|
public void init() throws OutOfMemoryError
init
in class HeapAllocator
OutOfMemoryError
- if there is not enough memory for initializationpublic int freeMemory()
freeMemory
in class HeapAllocator
public int totalMemory()
totalMemory
in class HeapAllocator
public Object allocateObject(int size, Object vtable) throws OutOfMemoryError
allocateObject
in class HeapAllocator
size
- size of object to allocate (including object header), in bytesvtable
- vtable pointer for new object
OutOfMemoryError
- if there is insufficient memory to perform the operationpublic static final int getObjectSize(Object o)
public Object allocateObjectAlign8(int size, Object vtable) throws OutOfMemoryError
allocateObjectAlign8
in class HeapAllocator
size
- size of object to allocate (including object header), in bytesvtable
- vtable pointer for new object
OutOfMemoryError
- if there is insufficient memory to perform the operationpublic Object allocateArray(int length, int size, Object vtable) throws OutOfMemoryError, NegativeArraySizeException
allocateArray
in class HeapAllocator
length
- length of new arraysize
- size of array to allocate (including array header), in bytesvtable
- vtable pointer for new array
NegativeArraySizeException
- if length is negative
OutOfMemoryError
- if there is insufficient memory to perform the operationpublic Object allocateArrayAlign8(int length, int size, Object vtable) throws OutOfMemoryError, NegativeArraySizeException
allocateArrayAlign8
in class HeapAllocator
length
- length of new arraysize
- size of array to allocate (including array header), in bytesvtable
- vtable pointer for new array
NegativeArraySizeException
- if length is negative
OutOfMemoryError
- if there is insufficient memory to perform the operationpublic void collect()
HeapAllocator
collect
in class HeapAllocator
public void sweep()
public void processObjectReference(Address a)
HeapAllocator
processObjectReference
in class HeapAllocator
public void processPossibleObjectReference(Address a)
HeapAllocator
processPossibleObjectReference
in class HeapAllocator
public boolean isInHeap(Address a)
HeapAllocator
isInHeap
in class HeapAllocator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |