use of com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator in project openj9 by eclipse.
the class RootScanner method scanNonCollectableObjectsInternal.
private void scanNonCollectableObjectsInternal(long memoryType) throws CorruptDataException {
GCHeapRegionIterator regionIterator = GCHeapRegionIterator.from();
while (regionIterator.hasNext()) {
GCHeapRegionDescriptor region = regionIterator.next();
if (new UDATA(region.getTypeFlags()).allBitsIn(memoryType)) {
GCObjectHeapIterator objectIterator = GCObjectHeapIterator.fromHeapRegionDescriptor(region, true, false);
while (objectIterator.hasNext()) {
J9ObjectPointer object = objectIterator.next();
doClassSlot(J9ObjectHelper.clazz(object));
GCObjectIterator fieldIterator = GCObjectIterator.fromJ9Object(object, true);
GCObjectIterator fieldAddressIterator = GCObjectIterator.fromJ9Object(object, true);
while (fieldIterator.hasNext()) {
doNonCollectableObjectSlot(fieldIterator.next(), fieldAddressIterator.nextAddress());
}
}
}
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator in project openj9 by eclipse.
the class ObjectSizeInfo method scanObjects.
private void scanObjects(GCHeapRegionDescriptor region) throws CorruptDataException {
GCObjectHeapIterator heapIterator = GCObjectHeapIterator.fromHeapRegionDescriptor(region, true, true);
while (heapIterator.hasNext()) {
J9ObjectPointer object = heapIterator.next();
J9ClassPointer objClass = J9ObjectHelper.clazz(object);
if (!objClass.isNull() && (!J9ClassHelper.isArrayClass(objClass) || includeArrays)) {
String objClassString = J9ClassHelper.getJavaName(objClass);
if ((null == className) || className.equals(objClassString)) {
ClassFieldInfo cfInfo = fieldStats.get(objClassString);
if (null == cfInfo) {
cfInfo = new ClassFieldInfo(objClass);
fieldStats.put(objClassString, cfInfo);
}
cfInfo.addInstance(object);
}
}
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator in project openj9 by eclipse.
the class ObjectRefsCommand method dumpHeapReferences.
/**
* Write the on heap references stanza to the output stream.
* @param vm
* @param targetObject
* @param out
* @throws CorruptDataException
*/
private void dumpHeapReferences(J9JavaVMPointer vm, J9ObjectPointer targetObject, PrintStream out) throws CorruptDataException {
if (GCExtensions.isVLHGC()) {
Table table = new Table("On Heap References");
table.row("object (!j9object)", "field (!j9object)", "!mm_heapregiondescriptorvlhgc", "AC (type)");
/* iterate over all heap regions */
GCHeapRegionIterator regionIterator = GCHeapRegionIterator.from();
while (regionIterator.hasNext()) {
GCHeapRegionDescriptor region = regionIterator.next();
if (region.containsObjects()) {
MM_HeapRegionDescriptorVLHGCPointer vlhgcRegion = MM_HeapRegionDescriptorVLHGCPointer.cast(region.getHeapRegionDescriptorPointer());
MM_AllocationContextTarokPointer currentAllocationContextTarok = vlhgcRegion._allocateData()._owningContext();
/* iterate over all objects in region */
GCObjectHeapIterator heapObjectIterator = region.objectIterator(true, false);
while (heapObjectIterator.hasNext()) {
J9ObjectPointer currentObject = heapObjectIterator.next();
/* Iterate over the object's fields and list any that point at @ref targetObject */
GCObjectIterator fieldIterator = GCObjectIterator.fromJ9Object(currentObject, false);
while (fieldIterator.hasNext()) {
J9ObjectPointer currentTargetObject = fieldIterator.next();
if (currentTargetObject.eq(targetObject)) {
/* found a reference to our targetObject, add it to the table */
J9ClassPointer objectClass = J9ObjectHelper.clazz(currentObject);
String objectClassString = J9ClassHelper.getJavaName(objectClass);
table.row(currentObject.getHexAddress() + " //" + objectClassString, currentTargetObject.getHexAddress(), vlhgcRegion.getHexAddress(), currentAllocationContextTarok.getHexAddress() + " (" + currentAllocationContextTarok._allocationContextType() + ")");
}
}
}
}
}
table.render(out);
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator in project openj9 by eclipse.
the class CheckObjectHeap method check.
@Override
public void check() {
// Use iterators directly
try {
GCHeapRegionIterator regions = GCHeapRegionIterator.from();
boolean midScavenge = _engine.isMidscavengeFlagSet();
boolean isVLHGC = GCExtensions.isVLHGC();
while (regions.hasNext()) {
GCHeapRegionDescriptor region = GCHeapRegionDescriptor.fromHeapRegionDescriptor(regions.next());
boolean isRegionTypeNew = region.getTypeFlags().allBitsIn(MEMORY_TYPE_NEW);
GCObjectHeapIterator heapIterator = region.objectIterator(true, true);
while (heapIterator.hasNext()) {
J9ObjectPointer object = heapIterator.peek();
if (midScavenge && (isVLHGC || isRegionTypeNew)) {
GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
if (scavengerForwardedHeader.isForwardedPointer()) {
// forwarded pointer is discovered
// report it
_engine.reportForwardedObject(object, scavengerForwardedHeader.getForwardedObject());
// and skip it by advancing of iterator to the next object
UDATA objectSize = scavengerForwardedHeader.getObjectSize();
heapIterator.advance(objectSize);
_engine.pushPreviousObject(object);
continue;
}
}
int result = _engine.checkObjectHeap(object, region);
if (result != J9MODRON_SLOT_ITERATOR_OK) {
break;
}
heapIterator.next();
_engine.pushPreviousObject(object);
}
}
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
Aggregations