Search in sources :

Example 1 with GCObjectHeapIterator

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());
                }
            }
        }
    }
}
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) GCObjectIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 2 with GCObjectHeapIterator

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);
            }
        }
    }
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) GCObjectHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 3 with GCObjectHeapIterator

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);
    }
}
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 4 with GCObjectHeapIterator

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
    }
}
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

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