Search in sources :

Example 6 with GCHeapRegionIterator

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;
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 7 with GCHeapRegionIterator

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));
    }
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) MM_HeapRegionManagerPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) MM_GCExtensionsPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_GCExtensionsPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Example 8 with GCHeapRegionIterator

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);
    }
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) Table(com.ibm.j9ddr.tools.ddrinteractive.Table) MM_HeapRegionDescriptorVLHGCPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionDescriptorVLHGCPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) GCObjectHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator) GCObjectIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator) MM_AllocationContextTarokPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_AllocationContextTarokPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 9 with GCHeapRegionIterator

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
    }
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) UDATA(com.ibm.j9ddr.vm29.types.UDATA) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) GCObjectHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator) GCScavengerForwardedHeader(com.ibm.j9ddr.vm29.j9.gc.GCScavengerForwardedHeader) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)8 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 GCObjectHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator)3 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)3 Table (com.ibm.j9ddr.tools.ddrinteractive.Table)2 GCObjectIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator)2 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 MM_AllocationContextTarokPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_AllocationContextTarokPointer)2 MM_GCExtensionsPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_GCExtensionsPointer)2 MM_HeapRegionDescriptorVLHGCPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionDescriptorVLHGCPointer)2 MM_HeapRegionManagerPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)1 GCScavengerForwardedHeader (com.ibm.j9ddr.vm29.j9.gc.GCScavengerForwardedHeader)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1