Search in sources :

Example 6 with PointerPointer

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

the class RamClassWalker method allSlotsInSpecialSplitTableDo.

private void allSlotsInSpecialSplitTableDo() throws CorruptDataException {
    int count = ramClass.romClass().specialSplitMethodRefCount().intValue();
    PointerPointer splitTable = ramClass.specialSplitMethodTable();
    for (int i = 0; i < count; i++) {
        classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, splitTable.add(i), "J9Method address", "!j9method");
    }
    classWalkerCallback.addSection(clazz, splitTable, count * PointerPointer.SIZEOF, "SpecialSplitTable", false);
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer)

Example 7 with PointerPointer

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

the class RamClassWalker method allSlotsInStaticSplitTableDo.

private void allSlotsInStaticSplitTableDo() throws CorruptDataException {
    int count = ramClass.romClass().staticSplitMethodRefCount().intValue();
    PointerPointer splitTable = ramClass.staticSplitMethodTable();
    for (int i = 0; i < count; i++) {
        classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, splitTable.add(i), "J9Method address", "!j9method");
    }
    classWalkerCallback.addSection(clazz, splitTable, count * PointerPointer.SIZEOF, "StaticSplitTable", false);
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer)

Example 8 with PointerPointer

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

the class RamClassWalker method allSlotsInConstantPoolDo.

private void allSlotsInConstantPoolDo() throws CorruptDataException {
    final J9ROMClassPointer romClass = ramClass.romClass();
    final int constPoolCount = romClass.ramConstantPoolCount().intValue();
    final J9ConstantPoolPointer cpp = J9ConstantPoolPointer.cast(ramClass.ramConstantPool());
    U32Pointer cpDescriptionSlots = romClass.cpShapeDescription();
    PointerPointer cpEntry = PointerPointer.cast(ramClass.ramConstantPool());
    long cpDescription = 0;
    long cpEntryCount = ramClass.romClass().ramConstantPoolCount().longValue();
    long cpDescriptionIndex = 0;
    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;
        }
        /*
			 * A switch statement can't be used on long type, it might be
			 * erroneous to cast it to an int as it might change in the future.
			 */
        long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
        if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
            J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_RAM_UTF8, ref.stringObjectEA(), "stringObject");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
            if (slotType == J9CPTYPE_STRING) {
                classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_STRING", false);
            } else {
                classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_ANNOTATION_UTF8", false);
            }
        } else if (slotType == J9CPTYPE_METHOD_TYPE) {
            J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
            J9ObjectPointer slot = ref.type();
            if (slot.notNull()) {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type", "!j9object");
            } else {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type");
            }
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slotCountEA(), "slotCount");
            classWalkerCallback.addSection(clazz, ref, J9RAMMethodTypeRef.SIZEOF, "J9CPTYPE_METHOD_TYPE", false);
        } else if (slotType == J9CPTYPE_METHODHANDLE) {
            J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
            J9ObjectPointer slot = ref.methodHandle();
            if (slot.notNull()) {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle", "!j9object");
            } else {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle");
            }
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
            classWalkerCallback.addSection(clazz, ref, J9RAMMethodHandleRef.SIZEOF, "J9CPTYPE_METHODHANDLE", false);
        } else if (slotType == J9CPTYPE_CLASS) {
            J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
            if (ref.value().notNull()) {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value", "!j9class");
            } else {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value");
            }
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.modifiersEA(), "modifiers");
            classWalkerCallback.addSection(clazz, ref, J9RAMClassRef.SIZEOF, "J9CPTYPE_CLASS", false);
        } else if (slotType == J9CPTYPE_INT) {
            J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldInt");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
            classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_INT", false);
        } else if (slotType == J9CPTYPE_FLOAT) {
            J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldFloat");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
            classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_FLOAT", false);
        } else if (slotType == J9CPTYPE_LONG) {
            J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_LONG");
            classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_LONG", false);
        } else if (slotType == J9CPTYPE_DOUBLE) {
            J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_DOUBLE");
            classWalkerCallback.addSection(clazz, ref, I64.SIZEOF, "J9CPTYPE_DOUBLE", false);
        } else if (slotType == J9CPTYPE_FIELD) {
            J9RAMFieldRefPointer ref = J9RAMFieldRefPointer.cast(cpEntry);
            J9RAMStaticFieldRefPointer staticRef = J9RAMStaticFieldRefPointer.cast(cpEntry);
            /* if the field ref is resolved static, it has 'flagsAndClass', for other cases (unresolved and resolved instance) it has 'flags'. */
            if ((staticRef.flagsAndClass().longValue() > 0) && (staticRef.valueOffset().longValue() != -1)) {
                classWalkerCallback.addSlot(clazz, SlotType.J9_IDATA, staticRef.flagsAndClassEA(), "flagsAndClass");
            } else {
                classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.flagsEA(), "flags");
            }
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueOffsetEA(), "valueOffset");
            classWalkerCallback.addSection(clazz, ref, J9RAMFieldRef.SIZEOF, "J9CPTYPE_FIELD", false);
        } else if (slotType == J9CPTYPE_INTERFACE_METHOD) {
            J9RAMInterfaceMethodRefPointer ref = J9RAMInterfaceMethodRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.interfaceClassEA(), "interfaceClass", "!j9class");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
            classWalkerCallback.addSection(clazz, ref, J9RAMInterfaceMethodRef.SIZEOF, "J9CPTYPE_INTERFACE_METHOD", false);
        } else if (slotType == J9CPTYPE_STATIC_METHOD) {
            J9RAMStaticMethodRefPointer ref = J9RAMStaticMethodRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "unused");
            classWalkerCallback.addSection(clazz, ref, J9RAMStaticMethodRef.SIZEOF, "J9CPTYPE_STATIC_METHOD", false);
        } else if ((slotType == J9CPTYPE_UNUSED) || (slotType == J9CPTYPE_UNUSED8)) {
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry, "unused");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry.add(1), "unused");
            classWalkerCallback.addSection(clazz, cpEntry, 2 * UDATA.SIZEOF, "J9CPTYPE_UNUSED", false);
        } else if (slotType == J9CPTYPE_INSTANCE_METHOD) {
            J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
            classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_INSTANCE_METHOD", false);
        } else if (slotType == J9CPTYPE_HANDLE_METHOD) {
            J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodTypeIndexAndArgCount");
            classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "unused");
            classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_HANDLE_METHOD", false);
        }
        cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
        cpEntryCount -= 1;
        cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
        cpDescriptionIndex -= 1;
    }
    // The spaces at the end of "Constant Pool" are important since the
    // regions are sorted
    // by address and size, but when they are equal they are sorted by
    // longest name and "Constant Pool" has to come first
    classWalkerCallback.addSection(clazz, cpp, constPoolCount * 2 * UDATA.SIZEOF, "Constant Pool               ", false);
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9RAMClassRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMClassRefPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9RAMMethodTypeRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodTypeRefPointer) J9RAMMethodRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodRefPointer) J9RAMInterfaceMethodRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMInterfaceMethodRefPointer) J9RAMConstantRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMConstantRefPointer) J9RAMFieldRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMFieldRefPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) J9RAMStaticFieldRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMStaticFieldRefPointer) J9RAMStringRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMStringRefPointer) J9RAMStaticMethodRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMStaticMethodRefPointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer) J9RAMMethodHandleRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodHandleRefPointer)

Example 9 with PointerPointer

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

the class CheckEngine method checkClassHeap.

public int checkClassHeap(J9ClassPointer clazz, J9MemorySegmentPointer segment) {
    int result;
    /*
		 * Verify that this is, in fact, a class
		 */
    try {
        result = checkJ9Class(clazz, segment, _cycle.getCheckFlags());
        if (J9MODRON_GCCHK_RC_OK != result) {
            CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
            _reporter.report(error);
        }
        /*
			 * Process object slots in the class
			 */
        GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
        while (classIterator.hasNext()) {
            PointerPointer slotPtr = PointerPointer.cast(classIterator.nextAddress());
            J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
            result = checkObjectIndirect(object);
            if (J9MODRON_GCCHK_RC_OK != result) {
                String elementName = "";
                switch(classIterator.getState()) {
                    case GCClassIterator.state_statics:
                        elementName = "static ";
                        break;
                    case GCClassIterator.state_constant_pool:
                        elementName = "constant ";
                        break;
                    case GCClassIterator.state_slots:
                        elementName = "slots ";
                        break;
                }
                CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
            if (GCExtensions.isStandardGC()) {
                /* If the slot has its old bit OFF, the class's remembered bit should be ON */
                if (object.notNull() && !ObjectModel.isOld(object)) {
                    if (!ObjectModel.isRemembered(clazz.classObject())) {
                        CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REMEMBERED_SET_OLD_OBJECT, _cycle.nextErrorCount());
                        _reporter.report(error);
                        return J9MODRON_SLOT_ITERATOR_OK;
                    }
                }
            }
        }
        if (J9MODRON_GCCHK_RC_OK != checkClassStatics(clazz)) {
            return J9MODRON_SLOT_ITERATOR_OK;
        }
        J9ClassPointer replaced = clazz.replacedClass();
        if (replaced.notNull()) {
            if (!J9ClassHelper.isSwappedOut(replaced)) {
                CheckError error = new CheckError(clazz, clazz.replacedClassEA(), _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REPLACED_CLASS_HAS_NO_HOTSWAP_FLAG, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
        }
        /*
			 * Process class slots in the class
			 */
        GCClassIteratorClassSlots classIteratorClassSlots = GCClassIteratorClassSlots.fromJ9Class(clazz);
        while (classIteratorClassSlots.hasNext()) {
            PointerPointer classSlotPtr = PointerPointer.cast(classIteratorClassSlots.nextAddress());
            J9ClassPointer classSlot = J9ClassPointer.cast(classSlotPtr.at(0));
            String elementName = "";
            result = J9MODRON_GCCHK_RC_OK;
            switch(classIteratorClassSlots.getState()) {
                case GCClassIteratorClassSlots.state_constant_pool:
                    /* may be NULL */
                    if (classSlot.notNull()) {
                        result = checkJ9ClassPointer(classSlot);
                    }
                    elementName = "constant ";
                    break;
                case GCClassIteratorClassSlots.state_superclasses:
                    /* must not be NULL */
                    result = checkJ9ClassPointer(classSlot);
                    elementName = "superclass ";
                    break;
                case GCClassIteratorClassSlots.state_interfaces:
                    /* must not be NULL */
                    result = checkJ9ClassPointer(classSlot);
                    elementName = "interface ";
                    break;
                case GCClassIteratorClassSlots.state_array_class_slots:
                    /* may be NULL */
                    if (classSlot.notNull()) {
                        result = checkJ9ClassPointer(classSlot);
                    }
                    elementName = "array class ";
            }
            if (J9MODRON_GCCHK_RC_OK != result) {
                CheckError error = new CheckError(clazz, classSlotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
        }
    } catch (CorruptDataException e) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
        _reporter.report(error);
    }
    return J9MODRON_SLOT_ITERATOR_OK;
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) GCClassIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) GCClassIteratorClassSlots(com.ibm.j9ddr.vm29.j9.gc.GCClassIteratorClassSlots)

Example 10 with PointerPointer

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

the class CheckVMThreadStacks method check.

@Override
public void check() {
    try {
        GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
        while (vmThreadListIterator.hasNext()) {
            J9VMThreadPointer walkThread = vmThreadListIterator.next();
            // GC_VMThreadStackSlotIterator::scanSlots(toScanWalkThread, toScanWalkThread, (void *)&localData, checkStackSlotIterator, false, false);
            WalkState walkState = new WalkState();
            walkState.walkThread = walkThread;
            walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK | J9_STACKWALK_SKIP_INLINES;
            walkState.callBacks = new BaseStackWalkerCallbacks() {

                public void objectSlotWalkFunction(J9VMThreadPointer walkThread, WalkState walkState, PointerPointer objectSlot, VoidPointer stackAddress) {
                    _engine.checkSlotStack(objectSlot, walkThread, stackAddress);
                }
            };
            StackWalker.walkStackFrames(walkState);
        }
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)31 CorruptDataException (com.ibm.j9ddr.CorruptDataException)22 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)10 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)9 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)5 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)4 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)3 J9HashTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer)3 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)3 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)3 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)2 WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)2 AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)2 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)2 J9RAMClassRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMClassRefPointer)2 J9RAMMethodHandleRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodHandleRefPointer)2 J9RAMMethodTypeRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMMethodTypeRefPointer)2