use of com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator in project openj9 by eclipse.
the class CheckEngine method findRegionForPointer.
private GCHeapRegionDescriptor findRegionForPointer(AbstractPointer pointer, GCHeapRegionDescriptor region) {
GCHeapRegionDescriptor regionDesc = null;
if (region != null && region.isAddressInRegion(pointer)) {
return region;
}
regionDesc = regionForAddress(pointer);
if (null != regionDesc) {
return regionDesc;
}
// TODO kmt : this is tragically slow
try {
GCHeapRegionIterator iterator = GCHeapRegionIterator.from();
while (iterator.hasNext()) {
regionDesc = GCHeapRegionDescriptor.fromHeapRegionDescriptor(iterator.next());
if (isPointerInRegion(pointer, regionDesc)) {
return regionDesc;
}
}
} catch (CorruptDataException e) {
}
return null;
}
use of com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator in project openj9 by eclipse.
the class HeapWalker method initializeFlatLockedMonitors.
private static void initializeFlatLockedMonitors() throws CorruptDataException {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
MM_GCExtensionsPointer gcext = GCExtensions.getGCExtensionsPointer();
MM_HeapRegionManagerPointer hrm = gcext.heapRegionManager();
flatLockedMonitors = new TreeSet<ObjectMonitor>();
GCHeapRegionIterator regions = GCHeapRegionIterator.fromMMHeapRegionManager(hrm, true, true);
while (regions.hasNext()) {
GCHeapRegionDescriptor region = regions.next();
if (!flatLockedMonitorsByRegion.containsKey(region)) {
runFlatLockMonitorRegionWalk(vm, region);
}
/* Running the walk should have populated the flatLockedMonitors map */
assert (flatLockedMonitorsByRegion.containsKey(region));
flatLockedMonitors.addAll(flatLockedMonitorsByRegion.get(region));
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator 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.GCHeapRegionIterator 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