Search in sources :

Example 46 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class RomClassWalker method allSlotsInAnnotationDo.

int allSlotsInAnnotationDo(U32Pointer annotation, String annotationSectionName) throws CorruptDataException {
    int increment = 0;
    int annotationLength = annotation.at(0).intValue();
    /* determine how many U_32 sized chunks to increment initialValue by
		 * NOTE: annotation length is U_32 and does not include the length field itself
		 * annotations are padded to U_32 which is also not included in the length field*/
    int padding = U32.SIZEOF - (annotationLength % U32.SIZEOF);
    increment = annotationLength / U32.SIZEOF;
    if (U32.SIZEOF == padding) {
        padding = 0;
    }
    if (padding > 0) {
        increment++;
    }
    classWalkerCallback.addSlot(clazz, SlotType.J9_U32, annotation, "annotation length");
    int count = annotationLength;
    U8Pointer cursor = U8Pointer.cast(annotation.add(1));
    for (; count > 0; count--) {
        classWalkerCallback.addSlot(clazz, SlotType.J9_U8, cursor, "annotation data");
        cursor = cursor.add(1);
    }
    count = padding;
    for (; count > 0; count--) {
        classWalkerCallback.addSlot(clazz, SlotType.J9_U8, cursor, "annotation padding");
        cursor = cursor.add(1);
    }
    /* move past the annotation length */
    increment += 1;
    classWalkerCallback.addSection(clazz, annotation, increment * U32.SIZEOF, annotationSectionName, true);
    return increment;
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 47 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class J9BCUtil method dumpMethodAnnotations.

private static void dumpMethodAnnotations(PrintStream out, J9ROMMethodPointer romMethod) throws CorruptDataException {
    U32Pointer methodAnnotationData = ROMHelp.getMethodAnnotationsDataFromROMMethod(romMethod);
    U32Pointer parametersAnnotationData = ROMHelp.getParameterAnnotationsDataFromROMMethod(romMethod);
    U32Pointer defaultAnnotationData = ROMHelp.getDefaultAnnotationDataFromROMMethod(romMethod);
    U32Pointer methodTypeAnnotations = ROMHelp.getMethodTypeAnnotationDataFromROMMethod(romMethod);
    U32Pointer codeTypeAnnotations = ROMHelp.getCodeTypeAnnotationDataFromROMMethod(romMethod);
    if ((!methodAnnotationData.isNull()) || (!parametersAnnotationData.isNull()) || (!defaultAnnotationData.isNull())) {
        J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
        J9UTF8Pointer name = nameAndSignature.name();
        J9UTF8Pointer signature = nameAndSignature.signature();
        out.append("      Name: " + J9UTF8Helper.stringValue(name) + nl);
        out.append("      Signature: " + J9UTF8Helper.stringValue(signature) + nl);
    }
    if (!methodAnnotationData.isNull()) {
        U32 length = methodAnnotationData.at(0);
        U32Pointer data = methodAnnotationData.add(1);
        out.append(String.format("      Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!parametersAnnotationData.isNull()) {
        U32 length = parametersAnnotationData.at(0);
        U32Pointer data = parametersAnnotationData.add(1);
        out.append(String.format("      Parameters Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!defaultAnnotationData.isNull()) {
        U32 length = defaultAnnotationData.at(0);
        U32Pointer data = defaultAnnotationData.add(1);
        out.append(String.format("      Default Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!methodTypeAnnotations.isNull()) {
        U32 length = methodTypeAnnotations.at(0);
        U32Pointer data = methodTypeAnnotations.add(1);
        out.append(String.format("      Method Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!codeTypeAnnotations.isNull()) {
        U32 length = codeTypeAnnotations.at(0);
        U32Pointer data = codeTypeAnnotations.add(1);
        out.append(String.format("      Code Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) U32(com.ibm.j9ddr.vm29.types.U32) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 48 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class J9ClassShapeCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        CommandUtils.dbgPrint(out, "Usage: !j9classshape <classAddress>\n");
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9ClassPointer instanceClass = J9ClassPointer.NULL;
        String classSelector = args[0];
        if (classSelector.matches("\\p{Digit}.*")) {
            /* addresses start with a decimal digit, possibly the '0' in "0x" */
            instanceClass = J9ClassPointer.cast(CommandUtils.parsePointer(classSelector, J9BuildFlags.env_data64));
        } else {
            J9ClassPointer[] candidates = findClassByName(vm, classSelector);
            if (candidates.length == 0) {
                CommandUtils.dbgPrint(out, "No classes matching \"" + classSelector + "\" found\n");
                return;
            } else if (candidates.length > 1) {
                CommandUtils.dbgPrint(out, "Multiple classes matching \"" + classSelector + "\" found\n");
                return;
            } else {
                instanceClass = candidates[0];
                String javaName = J9ClassHelper.getJavaName(instanceClass);
                String hexString = instanceClass.getHexAddress();
                CommandUtils.dbgPrint(out, String.format("!j9class %1$s\n", hexString));
            }
        }
        J9ClassPointer previousSuperclass = J9ClassPointer.NULL;
        String className = J9ClassHelper.getName(instanceClass);
        J9VMThreadPointer mainThread = vm.mainThread();
        boolean lockwordPrinted = true;
        if (J9BuildFlags.thr_lockNursery) {
            lockwordPrinted = false;
        }
        CommandUtils.dbgPrint(out, "Instance fields in %s:\n", className);
        CommandUtils.dbgPrint(out, "\noffset     name\tsignature\t(declaring class)\n");
        if (mainThread.isNull()) {
            /* we cannot print the instance fields without this */
            return;
        }
        long depth = J9ClassHelper.classDepth(instanceClass).longValue();
        for (long superclassIndex = 0; superclassIndex <= depth; superclassIndex++) {
            J9ClassPointer superclass;
            if (superclassIndex == depth) {
                superclass = instanceClass;
            } else {
                superclass = J9ClassPointer.cast(instanceClass.superclasses().at(superclassIndex));
            }
            U32 flags = new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_INCLUDE_HIDDEN);
            Iterator<J9ObjectFieldOffset> iterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(superclass.romClass(), instanceClass, previousSuperclass, flags);
            while (iterator.hasNext()) {
                J9ObjectFieldOffset result = (J9ObjectFieldOffset) iterator.next();
                boolean printField = true;
                boolean isHiddenField = result.isHidden();
                if (J9BuildFlags.thr_lockNursery) {
                    boolean isLockword = (isHiddenField && (result.getOffsetOrAddress().add(J9Object.SIZEOF).eq(superclass.lockOffset())));
                    if (isLockword) {
                        /*
							 * Print the lockword field if it is indeed the
							 * lockword for this instanceClass and we haven't
							 * printed it yet.
							 */
                        printField = !lockwordPrinted && instanceClass.lockOffset().eq(superclass.lockOffset());
                        if (printField) {
                            lockwordPrinted = true;
                        }
                    }
                }
                if (printField) {
                    printShapeField(out, superclass, result.getField(), result.getOffsetOrAddress(), isHiddenField);
                }
            }
            previousSuperclass = superclass;
        }
        CommandUtils.dbgPrint(out, "\nTotal instance size: %d\n", instanceClass.totalInstanceSize().longValue());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 49 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class CheckEngine method checkClassStatics.

private int checkClassStatics(J9ClassPointer clazz) {
    int result = J9MODRON_GCCHK_RC_OK;
    try {
        boolean validationRequired = true;
        if (J9ClassHelper.isSwappedOut(clazz)) {
            /* if class has been hot swapped (J9AccClassHotSwappedOut bit is set) in Fast HCR,
				 * the ramStatics of the existing class may be reused.  The J9ClassReusedStatics
				 * bit in J9Class->extendedClassFlags will be set if that's the case.
				 * In Extended HCR mode ramStatics might be not NULL and must be valid
				 * NOTE: If class is hot swapped and the value in ramStatics is NULL it is valid 
				 * to have the correspondent ROM Class value in objectStaticCount field greater then 0
				 */
            if (J9ClassHelper.isArrayClass(clazz)) {
                /* j9arrayclass should not be hot swapped */
                result = J9MODRON_GCCHK_RC_CLASS_HOT_SWAPPED_FOR_ARRAY;
                CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
                _reporter.report(error);
                return result;
            }
            if (J9ClassHelper.areExtensionsEnabled()) {
                /* This is Extended HSR mode so hot swapped class might have NULL in ramStatics field */
                if (clazz.ramStatics().isNull()) {
                    validationRequired = false;
                }
            }
            try {
                /* This case can also occur when running -Xint with extensions enabled */
                if (J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassReusedStatics)) {
                    validationRequired = false;
                }
            } catch (NoSuchFieldError e) {
            /* Flag must be missing from the core. */
            }
        }
        if (validationRequired) {
            // J9ClassLoaderPointer classLoader = clazz.classLoader();
            J9ROMClassPointer romClazz = clazz.romClass();
            UDATA numberOfReferences = new UDATA(0);
            PointerPointer sectionStart = PointerPointer.NULL;
            PointerPointer sectionEnd = PointerPointer.NULL;
            /*
				 * Note: we have no special recognition for J9ArrayClass here
				 * J9ArrayClass does not have a ramStatics field but something else at this place
				 * so direct check (NULL != clazz->ramStatics) would not be correct,
				 * however romClazz->objectStaticCount must be 0 for this case
				 */
            if (!romClazz.objectStaticCount().eq(0)) {
                sectionStart = PointerPointer.cast(clazz.ramStatics());
                sectionEnd = sectionStart.add(romClazz.objectStaticCount());
            }
            /* Iterate all fields of ROM Class looking to statics fields pointed to java objects */
            Iterator<J9ObjectFieldOffset> objectFieldOffsetIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(clazz, J9ClassHelper.superclass(clazz), new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC | J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS));
            while (objectFieldOffsetIterator.hasNext()) {
                J9ObjectFieldOffset fieldOffset = objectFieldOffsetIterator.next();
                // J9ROMFieldShapePointer field = fieldOffset.getField();
                numberOfReferences = numberOfReferences.add(1);
                /* get address of next field */
                PointerPointer address = sectionStart.addOffset(fieldOffset.getOffsetOrAddress());
                /* an address must be in gc scan range */
                if (!(address.gte(sectionStart) && address.lt(sectionEnd))) {
                    result = J9MODRON_GCCHK_RC_CLASS_STATICS_REFERENCE_IS_NOT_IN_SCANNING_RANGE;
                    CheckError error = new CheckError(clazz, address, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
                    _reporter.report(error);
                }
            /* check only if we have an object */
            // TODO kmt : can't easily implement this part of the check
            // J9Class* classToCast = vm->internalVMFunctions->internalFindClassUTF8(currentThread, toSearchString, toSearchLength, classLoader, J9_FINDCLASS_FLAG_EXISTING_ONLY);
            // if ((NULL == classToCast) || (0 == instanceOfOrCheckCast(J9GC_J9OBJECT_CLAZZ(*address), classToCast))) {
            // The issue is that we can't simply call "internalFindClassUTF8" in DDR.
            // We could guess at the behaviour of the ClassLoader, but that makes
            // distingushing a real problem from a weird ClassLoader delegation
            // model difficult.
            }
            if (!numberOfReferences.eq(romClazz.objectStaticCount())) {
                result = J9MODRON_GCCHK_RC_CLASS_STATICS_WRONG_NUMBER_OF_REFERENCES;
                CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
                _reporter.report(error);
            }
        }
    } 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 result;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) U32(com.ibm.j9ddr.vm29.types.U32) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 50 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class CheckReporterTTY method reportObjectHeader.

@Override
public void reportObjectHeader(CheckError error, J9ObjectPointer object, String prefix) {
    String prefixString = prefix == null ? "" : prefix;
    if (!shouldReport(error)) {
        return;
    }
    boolean isValid = false;
    boolean isHole = false;
    boolean isIndexable = false;
    try {
        isHole = ObjectModel.isDeadObject(object);
        if (!isHole) {
            isIndexable = ObjectModel.isIndexable(object);
        }
        isValid = true;
    } catch (CorruptDataException cde) {
    }
    if (isValid) {
        if (isIndexable) {
            out.print(String.format("  <gc check (%d): %sIObject %x header:", error._errorNumber, prefixString, object.getAddress()));
        } else {
            String elementName = isHole ? "Hole" : "Object";
            out.print(String.format("  <gc check (%d): %s%s %x header:", error._errorNumber, prefixString, elementName, object.getAddress()));
        }
    } else {
        out.print(String.format("  <gc check (%d): %s%s %x header:", error._errorNumber, prefixString, "Corrupt", object.getAddress()));
    }
    int headerSize = (int) J9Object.SIZEOF;
    if (isHole) {
        headerSize = (int) MM_HeapLinkedFreeHeader.SIZEOF;
    } else {
        try {
            headerSize = ObjectModel.getHeaderSize(object).intValue();
        } catch (CorruptDataException cde) {
        }
    }
    try {
        U32Pointer data = U32Pointer.cast(object);
        for (int i = 0; i < headerSize / U32.SIZEOF; i++) {
            out.print(String.format(" %08X", data.at(i).longValue()));
        }
    } catch (CorruptDataException cde) {
    }
    out.println(">");
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Aggregations

U32 (com.ibm.j9ddr.vm29.types.U32)44 UDATA (com.ibm.j9ddr.vm29.types.UDATA)16 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)9 CorruptDataException (com.ibm.j9ddr.CorruptDataException)6 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)6 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)6 J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)6 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)5 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)5 OMRMemCategoryPointer (com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer)4 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)3 J9ArrayClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)3 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)3 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)3 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)3 U16 (com.ibm.j9ddr.vm29.types.U16)3 U8 (com.ibm.j9ddr.vm29.types.U8)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 J9ROMFieldShapeIterator (com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator)2 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)2