public abstract class GenericHeap extends Object implements Heap, Iterable<ElementInfo>
Modifier and Type | Class and Description |
---|---|
protected class |
GenericHeap.ElementInfoMarker |
Modifier and Type | Field and Description |
---|---|
protected GenericHeap.ElementInfoMarker |
elementInfoMarker |
protected IntTable<String> |
internStrings |
protected boolean |
liveBitValue |
protected ObjectQueue<ElementInfo> |
markQueue |
protected IntVector |
pinDownList |
protected VM |
vm |
protected ArrayList<ElementInfo> |
weakRefs |
Constructor and Description |
---|
GenericHeap(Config config,
KernelState ks) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToInternStrings(String str,
int objref) |
protected void |
addToPinDownList(int objref) |
void |
checkConsistency(boolean isStateStore) |
void |
cleanUpDanglingReferences()
clean up reference values that are stored outside of reference fields
called from KernelState to process live ElementInfos after GC has finished
and only live objects remain in the heap.
|
protected void |
cleanupWeakRefs()
reset all weak references that now point to collected objects to 'null'
NOTE: this implementation requires our own Reference/WeakReference implementation, to
make sure the 'ref' field is the first one
|
protected ElementInfo |
createArray(String elementType,
int nElements,
ClassInfo ci,
ThreadInfo ti,
int objref) |
protected DynamicElementInfo |
createElementInfo(int objref,
ClassInfo ci,
Fields f,
Monitor m,
ThreadInfo ti) |
protected ElementInfo |
createObject(ClassInfo ci,
ThreadInfo ti,
int objref) |
void |
gc() |
abstract ElementInfo |
get(int ref)
public getter to access but not change ElementInfos
|
protected ClassInfo |
getArrayClassInfo(ThreadInfo ti,
String elementType) |
abstract Memento<Heap> |
getMemento() |
abstract Memento<Heap> |
getMemento(MementoFactory factory) |
abstract ElementInfo |
getModifiable(int ref)
public getter to access modifiable ElementInfos;
|
protected abstract int |
getNewElementInfoIndex(AllocationContext ctx)
this is called for newXX(..) allocations that are SUT thread specific, i.e.
|
protected abstract AllocationContext |
getSUTAllocationContext(ClassInfo ci,
ThreadInfo ti) |
protected abstract AllocationContext |
getSystemAllocationContext(ClassInfo ci,
ThreadInfo ti,
int anchor) |
boolean |
hasChanged() |
protected ElementInfo |
initializeStringObject(String str,
int index,
int vref) |
boolean |
isAlive(ElementInfo ei)
check if object is alive.
|
boolean |
isGcEnabled() |
boolean |
isOutOfMemory() |
abstract Iterator<ElementInfo> |
iterator()
return Iterator for all non-null ElementInfo entries
|
abstract Iterable<ElementInfo> |
liveObjects() |
protected void |
mark() |
void |
markChanged(int objref) |
void |
markStaticRoot(int objref)
called during non-recursive phase1 marking of all objects reachable
from static fields
|
void |
markThreadRoot(int objref,
int tid)
called during non-recursive phase1 marking of all objects reachable
from Thread roots
|
ElementInfo |
newArray(String elementType,
int nElements,
ThreadInfo ti) |
ElementInfo |
newInternString(String str,
ThreadInfo ti) |
ElementInfo |
newObject(ClassInfo ci,
ThreadInfo ti) |
protected ElementInfo |
newString(ClassInfo ciString,
ClassInfo ciChars,
String str,
ThreadInfo ti,
AllocationContext ctx) |
ElementInfo |
newString(String str,
ThreadInfo ti) |
ElementInfo |
newSystemArray(String elementType,
int nElements,
ThreadInfo ti,
int anchor) |
ElementInfo |
newSystemObject(ClassInfo ci,
ThreadInfo ti,
int anchor) |
ElementInfo |
newSystemString(String str,
ThreadInfo ti,
int anchor) |
ElementInfo |
newSystemThrowable(ClassInfo ciThrowable,
String details,
int[] stackSnapshot,
int causeRef,
ThreadInfo ti,
int anchor) |
void |
queueMark(int objref)
add a non-null, not yet marked reference to the markQueue
called from ElementInfo.markRecursive().
|
void |
registerPinDown(int objref) |
void |
registerWeakReference(ElementInfo ei) |
void |
releasePinDown(int objref) |
protected abstract void |
remove(int ref)
internal remover used by generic sweep
|
protected void |
removeFromPinDownList(int objref) |
abstract void |
resetVolatiles() |
abstract void |
restoreVolatiles() |
protected abstract void |
set(int index,
ElementInfo ei)
internal setter used during allocation
|
void |
setGcEnabled(boolean doGC) |
void |
setOutOfMemory(boolean isOutOfMemory) |
void |
setStored() |
protected void |
sweep()
this implementation uses a generic ElementInfo iterator, it can be replaced
with a more efficient container specific version
|
void |
unmarkAll() |
protected VM vm
protected IntVector pinDownList
protected ArrayList<ElementInfo> weakRefs
protected ObjectQueue<ElementInfo> markQueue
protected boolean liveBitValue
protected GenericHeap.ElementInfoMarker elementInfoMarker
public GenericHeap(Config config, KernelState ks)
protected DynamicElementInfo createElementInfo(int objref, ClassInfo ci, Fields f, Monitor m, ThreadInfo ti)
protected void addToPinDownList(int objref)
protected void removeFromPinDownList(int objref)
public void registerPinDown(int objref)
registerPinDown
in interface Heap
public void releasePinDown(int objref)
releasePinDown
in interface Heap
public void registerWeakReference(ElementInfo ei)
registerWeakReference
in interface Heap
protected void cleanupWeakRefs()
protected abstract AllocationContext getSUTAllocationContext(ClassInfo ci, ThreadInfo ti)
protected abstract AllocationContext getSystemAllocationContext(ClassInfo ci, ThreadInfo ti, int anchor)
protected abstract int getNewElementInfoIndex(AllocationContext ctx)
protected ElementInfo createObject(ClassInfo ci, ThreadInfo ti, int objref)
public ElementInfo newObject(ClassInfo ci, ThreadInfo ti)
public ElementInfo newSystemObject(ClassInfo ci, ThreadInfo ti, int anchor)
newSystemObject
in interface Heap
protected ElementInfo createArray(String elementType, int nElements, ClassInfo ci, ThreadInfo ti, int objref)
protected ClassInfo getArrayClassInfo(ThreadInfo ti, String elementType)
public ElementInfo newArray(String elementType, int nElements, ThreadInfo ti)
public ElementInfo newSystemArray(String elementType, int nElements, ThreadInfo ti, int anchor)
newSystemArray
in interface Heap
protected ElementInfo initializeStringObject(String str, int index, int vref)
protected ElementInfo newString(ClassInfo ciString, ClassInfo ciChars, String str, ThreadInfo ti, AllocationContext ctx)
public ElementInfo newString(String str, ThreadInfo ti)
public ElementInfo newSystemString(String str, ThreadInfo ti, int anchor)
newSystemString
in interface Heap
public ElementInfo newInternString(String str, ThreadInfo ti)
newInternString
in interface Heap
protected void addToInternStrings(String str, int objref)
public ElementInfo newSystemThrowable(ClassInfo ciThrowable, String details, int[] stackSnapshot, int causeRef, ThreadInfo ti, int anchor)
newSystemThrowable
in interface Heap
protected abstract void set(int index, ElementInfo ei)
index
- ei
- public abstract ElementInfo get(int ref)
public abstract ElementInfo getModifiable(int ref)
getModifiable
in interface Heap
protected abstract void remove(int ref)
public abstract Iterator<ElementInfo> iterator()
iterator
in interface Iterable<ElementInfo>
public abstract Iterable<ElementInfo> liveObjects()
liveObjects
in interface Heap
public boolean isGcEnabled()
public void setGcEnabled(boolean doGC)
public void queueMark(int objref)
public void markStaticRoot(int objref)
markStaticRoot
in interface Heap
public void markThreadRoot(int objref, int tid)
markThreadRoot
in interface Heap
protected void sweep()
protected void mark()
public void cleanUpDanglingReferences()
cleanUpDanglingReferences
in interface Heap
public boolean isAlive(ElementInfo ei)
public abstract void resetVolatiles()
resetVolatiles
in interface Heap
public abstract void restoreVolatiles()
restoreVolatiles
in interface Heap
public boolean hasChanged()
hasChanged
in interface Heap
public void markChanged(int objref)
markChanged
in interface Heap
public void setStored()
public abstract Memento<Heap> getMemento(MementoFactory factory)
getMemento
in interface Heap
public abstract Memento<Heap> getMemento()
getMemento
in interface Heap
public boolean isOutOfMemory()
isOutOfMemory
in interface Heap
public void setOutOfMemory(boolean isOutOfMemory)
setOutOfMemory
in interface Heap
public void checkConsistency(boolean isStateStore)
checkConsistency
in interface Heap