Search in sources :

Example 6 with J9Object

use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.

the class CheckEngine method checkJ9ObjectPointer.

private int checkJ9ObjectPointer(J9ObjectPointer object, J9ObjectPointer[] newObject, GCHeapRegionDescriptor[] regionDesc) throws CorruptDataException {
    newObject[0] = object;
    if (object.isNull()) {
        return J9MODRON_GCCHK_RC_OK;
    }
    regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
    if (regionDesc[0] == null) {
        /* Is the object on the stack? */
        GCVMThreadListIterator threadListIterator = GCVMThreadListIterator.from();
        while (threadListIterator.hasNext()) {
            J9VMThreadPointer vmThread = threadListIterator.next();
            if (isObjectOnStack(object, vmThread.stackObject())) {
                return J9MODRON_GCCHK_RC_STACK_OBJECT;
            }
        }
        UDATA classSlot = UDATA.cast(object.clazz());
        if (classSlot.eq(J9MODRON_GCCHK_J9CLASS_EYECATCHER)) {
            return J9MODRON_GCCHK_RC_OBJECT_SLOT_POINTS_TO_J9CLASS;
        }
        return J9MODRON_GCCHK_RC_NOT_FOUND;
    }
    // if (0 == regionDesc->objectAlignment) {
    if (!regionDesc[0].containsObjects()) {
        /* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
        return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
    }
    /* Now we know object is not on stack we can check that it's correctly aligned
		 * for a J9Object.
		 */
    if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
        return J9MODRON_GCCHK_RC_UNALIGNED;
    }
    if (isMidscavengeFlagSet()) {
        if (GCExtensions.isVLHGC() || (regionDesc[0].getTypeFlags().allBitsIn(MEMORY_TYPE_NEW))) {
            // TODO: ideally, we should only check this in the evacuate segment
            // TODO: do some safety checks first -- is there enough room in the segment?
            GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
            if (scavengerForwardedHeader.isForwardedPointer()) {
                newObject[0] = scavengerForwardedHeader.getForwardedObject();
                reportForwardedObject(object, newObject[0]);
                // Replace the object and resume
                object = newObject[0];
                regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
                if (regionDesc[0] == null) {
                    /* Is the object on the stack? */
                    GCVMThreadListIterator threadListIterator = GCVMThreadListIterator.from();
                    while (threadListIterator.hasNext()) {
                        J9VMThreadPointer vmThread = threadListIterator.next();
                        if (isObjectOnStack(object, vmThread.stackObject())) {
                            return J9MODRON_GCCHK_RC_STACK_OBJECT;
                        }
                    }
                    return J9MODRON_GCCHK_RC_NOT_FOUND;
                }
                // if (0 == regionDesc->objectAlignment) {
                if (!regionDesc[0].containsObjects()) {
                    /* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
                    return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
                }
                /* make sure the forwarded pointer is also aligned */
                if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
                    return J9MODRON_GCCHK_RC_UNALIGNED;
                }
            }
        }
    }
    if (isScavengerBackoutFlagSet()) {
        GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
        if (scavengerForwardedHeader.isReverseForwardedPointer()) {
            newObject[0] = scavengerForwardedHeader.getReverseForwardedPointer();
            reportForwardedObject(object, newObject[0]);
            // Replace the object and resume
            object = newObject[0];
            regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
            if (regionDesc[0] == null) {
                return J9MODRON_GCCHK_RC_NOT_FOUND;
            }
            if (!regionDesc[0].containsObjects()) {
                /* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
                return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
            }
            if (!regionDesc[0].getTypeFlags().allBitsIn(MEMORY_TYPE_NEW)) {
                /* reversed forwarded should point to Evacuate */
                return J9MODRON_GCCHK_RC_REVERSED_FORWARDED_OUTSIDE_EVACUATE;
            }
            /* make sure the forwarded pointer is also aligned */
            if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
                return J9MODRON_GCCHK_RC_UNALIGNED;
            }
        }
    }
    /* Check that elements of a double array are aligned on an 8-byte boundary.  For continuous
		 * arrays, verifying that the J9Indexable object is aligned on an 8-byte boundary is sufficient.
		 * For arraylets, depending on the layout, elements of the array may be stored on arraylet leafs
		 * or on the spine.  Arraylet leafs should always be aligned on 8-byte boundaries.  Checking both 
		 * the first and last element will ensure that we are always checking that elements are aligned 
		 * on the spine.
		 *  */
    long classShape = -1;
    try {
        classShape = ObjectModel.getClassShape(J9ObjectHelper.clazz(object)).longValue();
    } catch (CorruptDataException cde) {
    /* don't bother to report an error yet -- a later step will catch this. */
    }
    if (classShape == OBJECT_HEADER_SHAPE_DOUBLES) {
        J9IndexableObjectPointer array = J9IndexableObjectPointer.cast(object);
        int size = 0;
        VoidPointer elementPtr = VoidPointer.NULL;
        try {
            size = ObjectModel.getSizeInElements(object).intValue();
        } catch (InvalidDataTypeException ex) {
        // size in elements can not be larger then 2G but it is...
        // We could report an error at this point, but the C version
        // doesn't -- we'll catch it later
        } catch (IllegalArgumentException ex) {
        // We could report an error at this point, but the C version
        // doesn't -- we'll catch it later
        }
        if (0 != size) {
            elementPtr = ObjectModel.getElementAddress(array, 0, U64.SIZEOF);
            if (elementPtr.anyBitsIn(U64.SIZEOF - 1)) {
                return J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED;
            }
            elementPtr = ObjectModel.getElementAddress(array, size - 1, U64.SIZEOF);
            if (elementPtr.anyBitsIn(U64.SIZEOF - 1)) {
                return J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED;
            }
        }
    }
    return J9MODRON_GCCHK_RC_OK;
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9IndexableObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9IndexableObjectPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) GCScavengerForwardedHeader(com.ibm.j9ddr.vm29.j9.gc.GCScavengerForwardedHeader) CorruptDataException(com.ibm.j9ddr.CorruptDataException) InvalidDataTypeException(com.ibm.j9ddr.InvalidDataTypeException)

Example 7 with J9Object

use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.

the class J9ObjectFieldFormatter method postFormat.

@Override
public FormatWalkResult postFormat(String name, String type, String declaredType, int typeCode, long address, PrintStream out, Context context, IStructureFormatter structureFormatter) throws CorruptDataException {
    if (typeCode == TYPE_STRUCTURE_POINTER && StructureCommandUtil.typeToCommand(type).equals("!j9object")) {
        PointerPointer slotPtr = PointerPointer.cast(address);
        J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
        if (object.isNull()) {
            return FormatWalkResult.KEEP_WALKING;
        }
        J9ClassPointer clazz = J9ObjectHelper.clazz(object);
        out.print(" // ");
        if (J9ClassHelper.isArrayClass(clazz)) {
            out.print(J9ClassHelper.getArrayName(clazz));
        } else {
            out.print(J9ClassHelper.getName(clazz));
        }
    }
    return FormatWalkResult.KEEP_WALKING;
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 8 with J9Object

use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.

the class J9ObjectStructureFormatter method printSubArrayType.

void printSubArrayType(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, int begin, int end, J9IndexableObjectPointer array) throws CorruptDataException {
    U32 arraySize = J9IndexableObjectHelper.size(array);
    if (arraySize.anyBitsIn(0x80000000)) {
        arraySize = new U32(Integer.MAX_VALUE);
    }
    int finish = Math.min(arraySize.intValue(), end);
    if (begin < finish) {
        String className = J9IndexableObjectHelper.getClassName(array);
        char signature = className.charAt(1);
        switch(signature) {
            case 'B':
            case 'Z':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 1);
                    out.println(String.format("[%d] = %3d, 0x%02x", index, U8Pointer.cast(slot).at(0).longValue(), U8Pointer.cast(slot).at(0).longValue()));
                }
                break;
            case 'C':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
                    long value = U16Pointer.cast(slot).at(0).longValue();
                    out.println(String.format("[%d] = %5d, 0x%2$04x, '%c'", index, value, (char) value));
                }
                break;
            case 'S':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
                    out.println(String.format("[%d] = %6d, 0x%04x", index, I16Pointer.cast(slot).at(0).longValue(), U16Pointer.cast(slot).at(0).longValue()));
                }
                break;
            case 'I':
            case 'F':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 4);
                    out.println(String.format("[%d] = %10d, 0x%08x, %8.8fF", index, I32Pointer.cast(slot).at(0).longValue(), U32Pointer.cast(slot).at(0).longValue(), FloatPointer.cast(slot).floatAt(0)));
                }
                break;
            case 'J':
            case 'D':
                for (int index = begin; index < finish; index++) {
                    padding(out, tabLevel);
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 8);
                    out.println(String.format("[%d] = %2d, 0x%016x, %8.8fF", index, I64Pointer.cast(slot).at(0).longValue(), I64Pointer.cast(slot).at(0).longValue(), DoublePointer.cast(slot).doubleAt(0)));
                }
                break;
            case 'L':
            case '[':
                for (int index = begin; index < finish; index++) {
                    VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, (int) ObjectReferencePointer.SIZEOF);
                    if (slot.notNull()) {
                        long compressedPtrValue;
                        if (J9BuildFlags.gc_compressedPointers) {
                            compressedPtrValue = I32Pointer.cast(slot).at(0).longValue();
                        } else {
                            compressedPtrValue = DataType.getProcess().getPointerAt(slot.getAddress());
                        }
                        padding(out, tabLevel);
                        out.println(String.format("[%d] = !fj9object 0x%x = !j9object 0x%x", index, compressedPtrValue, ObjectReferencePointer.cast(slot).at(0).longValue()));
                    } else {
                        padding(out, tabLevel);
                        out.println(String.format("[%d] = null", slot));
                    }
                }
                break;
        }
    }
    /* check if it just printed a range; if so, give cmd to see all data */
    arraySize = J9IndexableObjectHelper.size(array);
    if (begin > 0 || arraySize.longValue() > finish) {
        out.println(String.format("To print entire range: !j9indexableobject %s %d %d\n", array.getHexAddress(), 0, arraySize.longValue()));
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) U32(com.ibm.j9ddr.vm29.types.U32)

Example 9 with J9Object

use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.

the class CompressedRefMappingCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printHelp(out);
        return;
    }
    long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
    VoidPointer ptr = VoidPointer.cast(address);
    if (command.startsWith("!fj9object")) {
        J9ObjectPointer mappedValue;
        if (J9BuildFlags.gc_compressedPointers) {
            mappedValue = ObjectAccessBarrier.convertPointerFromToken(ptr.getAddress());
        } else {
            mappedValue = J9ObjectPointer.cast(ptr);
        }
        if (command.startsWith("!fj9objecttoj9object")) {
            out.println(String.format("!fj9object %s -> !j9object %s", ptr.getHexAddress(), mappedValue.getHexAddress()));
        } else {
            context.execute("!j9object", new String[] { mappedValue.getHexAddress() }, out);
        }
    } else {
        long tokenValue;
        if (J9BuildFlags.gc_compressedPointers) {
            tokenValue = ObjectAccessBarrier.convertTokenFromPointer(J9ObjectPointer.cast(ptr));
        } else {
            tokenValue = ptr.getAddress();
        }
        out.println(String.format("!j9object %s -> !fj9object 0x%s\n", ptr.getHexAddress(), Long.toHexString(tokenValue)));
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 10 with J9Object

use of com.ibm.j9ddr.vm29.structure.J9Object 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)

Aggregations

J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)6 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)4 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)3 U32 (com.ibm.j9ddr.vm29.types.U32)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 Table (com.ibm.j9ddr.tools.ddrinteractive.Table)2 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)2 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 InvalidDataTypeException (com.ibm.j9ddr.InvalidDataTypeException)1 MemoryFault (com.ibm.j9ddr.corereaders.memory.MemoryFault)1 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)1 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)1 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)1 GCHeapRegionManager (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionManager)1 GCObjectHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator)1