Search in sources :

Example 6 with J9ObjectPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.

the class ObjectMonitor_V1 method getBlockedThreads.

private static List<J9VMThreadPointer> getBlockedThreads(J9ObjectPointer blockingObject) throws CorruptDataException {
    // Do a single walk and cache all the results.
    if (blockedThreadsCache == null) {
        blockedThreadsCache = new HashMap<J9ObjectPointer, List<J9VMThreadPointer>>();
        GCVMThreadListIterator iterator = GCVMThreadListIterator.from();
        while (iterator.hasNext()) {
            J9VMThreadPointer vmThread = iterator.next();
            if (vmThread.publicFlags().allBitsIn(J9Consts.J9_PUBLIC_FLAGS_THREAD_BLOCKED)) {
                J9ObjectPointer object = vmThread.blockingEnterObject();
                if (object.notNull()) {
                    List<J9VMThreadPointer> list = blockedThreadsCache.get(object);
                    if (list == null) {
                        list = new ArrayList<J9VMThreadPointer>();
                        blockedThreadsCache.put(object, list);
                    }
                    list.add(vmThread);
                }
            }
        }
    }
    return blockedThreadsCache.get(blockingObject);
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) ArrayList(java.util.ArrayList) List(java.util.List) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 7 with J9ObjectPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.

the class GCConstantPoolSlotIterator method initializeSlots_V1.

protected void initializeSlots_V1(J9ClassPointer clazz, boolean returnClassSlots, boolean returnObjectSlots) throws CorruptDataException {
    U32Pointer cpDescriptionSlots = clazz.romClass().cpShapeDescription();
    PointerPointer cpEntry = PointerPointer.cast(clazz.ramConstantPool());
    long cpDescription = 0;
    long cpEntryCount = clazz.romClass().ramConstantPoolCount().longValue();
    long cpDescriptionIndex = 0;
    ArrayList<AbstractPointer> slots = new ArrayList<AbstractPointer>();
    ArrayList<VoidPointer> addresses = new ArrayList<VoidPointer>();
    while (cpEntryCount > 0) {
        if (0 == cpDescriptionIndex) {
            // Load a new description word
            cpDescription = cpDescriptionSlots.at(0).longValue();
            cpDescriptionSlots = cpDescriptionSlots.add(1);
            cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
        }
        long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
        if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
            if (returnObjectSlots) {
                J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
                J9ObjectPointer slot = ref.stringObject();
                if (slot.notNull()) {
                    slots.add(slot);
                    addresses.add(VoidPointer.cast(ref.stringObjectEA()));
                }
            }
        } else if (slotType == J9CPTYPE_METHOD_TYPE) {
            if (returnObjectSlots) {
                J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
                J9ObjectPointer slot = ref.type();
                if (slot.notNull()) {
                    slots.add(slot);
                    addresses.add(VoidPointer.cast(ref.typeEA()));
                }
            }
        } else if (slotType == J9CPTYPE_METHODHANDLE) {
            if (returnObjectSlots) {
                J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
                J9ObjectPointer slot = ref.methodHandle();
                if (slot.notNull()) {
                    slots.add(slot);
                    addresses.add(VoidPointer.cast(ref.methodHandleEA()));
                }
            }
        } else if (slotType == J9CPTYPE_CLASS) {
            if (returnClassSlots) {
                J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
                J9ClassPointer slot = ref.value();
                if (slot.notNull()) {
                    slots.add(slot);
                    addresses.add(VoidPointer.cast(ref.valueEA()));
                }
            }
        }
        cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
        cpEntryCount -= 1;
        cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
        cpDescriptionIndex -= 1;
    }
    slotIterator = slots.iterator();
    addressIterator = addresses.iterator();
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9RAMClassRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMClassRefPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) ArrayList(java.util.ArrayList) J9RAMMethodTypeRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodTypeRefPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) J9RAMStringRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMStringRefPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer) J9RAMMethodHandleRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodHandleRefPointer)

Example 8 with J9ObjectPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.

the class GCFinalizableObjectIterator method next.

public J9ObjectPointer next() {
    try {
        if (hasNext()) {
            J9ObjectPointer result = J9ObjectPointer.NULL;
            switch(_state) {
                case state_system:
                    result = _currentSystemObject;
                    advanceToNextSystemFinalizableObject();
                    break;
                case state_default:
                    result = _currentDefaultObject;
                    advanceToNextDefaultFinalizableObject();
                    break;
                case state_reference:
                    result = _currentReferenceObject;
                    _currentReferenceObject = ObjectAccessBarrier.getReferenceLink(_currentReferenceObject);
                    break;
            }
            return result;
        } else {
            throw new NoSuchElementException("There are no more items available through this iterator");
        }
    } catch (CorruptDataException cde) {
        // can try to recover from this
        raiseCorruptDataEvent("Error getting next item", cde, false);
        if (_state < state_end) {
            /* The current list appears damaged. Move to the next one. */
            _state++;
        }
        return null;
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) NoSuchElementException(java.util.NoSuchElementException)

Example 9 with J9ObjectPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.

the class GCMixedObjectIterator_V1 method next.

@Override
public J9ObjectPointer next() {
    try {
        if (hasNext()) {
            if (object != null && includeClassSlot) {
                includeClassSlot = false;
                return J9ObjectHelper.clazz(object).classObject();
            }
            J9ObjectPointer next = J9ObjectPointer.cast(data.at(scanIndex));
            scanIndex++;
            return next;
        } else {
            throw new NoSuchElementException("There are no more items available through this iterator");
        }
    } catch (CorruptDataException e) {
        // can try to recover from this
        raiseCorruptDataEvent("Error getting next item", e, false);
        return null;
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) NoSuchElementException(java.util.NoSuchElementException)

Example 10 with J9ObjectPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.

the class GCHeapMap method queryRange.

/**
 * Query the mark map to see what objects are marked within the specified range.
 * Return an array of MarkedObject records describing each entry found.
 * @param base Bottom of the range to query (inclusive)
 * @param top Top of the range to query (exclusive)
 * @return A MarkedObject[] containing the results
 * @throws CorruptDataException
 */
public MarkedObject[] queryRange(J9ObjectPointer base, J9ObjectPointer top) throws CorruptDataException {
    /* Naive implementation; should work but slow */
    ArrayList<MarkedObject> results = new ArrayList<MarkedObject>();
    if (base.lt(_heapBase)) {
        base = J9ObjectPointer.cast(_heapBase);
    }
    if (top.gt(_heapTop)) {
        top = J9ObjectPointer.cast(_heapTop);
    }
    if (base.gt(top)) {
        base = top;
    }
    J9ObjectPointer cursor = base;
    while (cursor.lt(top)) {
        UDATA[] indexAndMask = getSlotIndexAndMask(cursor);
        UDATAPointer slot = _heapMapBits.add(indexAndMask[0]);
        if (slot.at(0).bitAnd(indexAndMask[1]).gt(0)) {
            results.add(new MarkedObject(cursor, slot));
        }
        cursor = cursor.addOffset(getObjectGrain());
    }
    return results.toArray(new MarkedObject[results.size()]);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) ArrayList(java.util.ArrayList) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)76 CorruptDataException (com.ibm.j9ddr.CorruptDataException)48 UDATA (com.ibm.j9ddr.vm29.types.UDATA)22 NoSuchElementException (java.util.NoSuchElementException)18 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)17 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)16 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)12 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)7 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)6 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)5 MarkedObject (com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject)5 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)5 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)5 GCObjectHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator)4 GCObjectIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator)4 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)4 ArrayList (java.util.ArrayList)4 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)3 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)3 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)3