Search in sources :

Example 1 with J9ITablePointer

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

the class RamClassWalker method allSlotsIniTableDo.

private void allSlotsIniTableDo() throws CorruptDataException {
    J9ITablePointer iTable = J9ITablePointer.cast(ramClass.iTable());
    int interfaceSize = 0;
    final J9ITablePointer superclassITable;
    final J9ClassPointer superclass = J9ClassHelper.superclass(ramClass);
    if (superclass.isNull()) {
        superclassITable = J9ITablePointer.NULL;
    } else {
        superclassITable = J9ITablePointer.cast(superclass.iTable());
    }
    /*
		 * Loops through the linked list of interfaces until it hit it's
		 * superclass'itable
		 */
    while (!iTable.eq(superclassITable)) {
        classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, iTable.interfaceClassEA(), "iTable->interfaceClass", "!j9class");
        classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, iTable.nextEA(), "iTable->next", "!j9itable");
        /*
			 * The iTables for the interface classes do not contain entries for
			 * methods.
			 */
        if (!ramClass.romClass().modifiers().allBitsIn(J9Consts.J9_JAVA_INTERFACE)) {
            int methodCount = iTable.interfaceClass().romClass().romMethodCount().intValue();
            for (int i = 0; i < methodCount; i++) {
                /*
					 * Add the method after the iTable. We add i + 1 to the
					 * iTable.nextEA() because we do not want to print the
					 * iTable.nextEA() but actually the value after it which 
					 * will be a method
					 */
                classWalkerCallback.addSlot(clazz, SlotType.J9_iTableMethod, iTable.nextEA().add(i + 1), "method", "!j9method");
                interfaceSize += UDATA.SIZEOF;
            }
        }
        iTable = iTable.next();
        interfaceSize += J9ITable.SIZEOF;
    }
    classWalkerCallback.addSection(clazz, ramClass.iTable(), interfaceSize, "iTable", false);
}
Also used : J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)

Example 2 with J9ITablePointer

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

the class ITableSizeCommand method iTableExtendedSize.

public long iTableExtendedSize(J9ITablePointer startTable, J9ITablePointer superTable) throws CorruptDataException {
    long size = 0;
    J9ITablePointer iTable = startTable;
    while (!iTable.eq(superTable)) {
        size += J9ITable.SIZEOF;
        J9ClassPointer interfaceClass = iTable.interfaceClass();
        J9ROMClassPointer romClass = interfaceClass.romClass();
        J9ITablePointer allInterfaces = J9ITablePointer.cast(interfaceClass.iTable());
        do {
            size += (UDATA.SIZEOF * allInterfaces.interfaceClass().romClass().romMethodCount().intValue());
            allInterfaces = allInterfaces.next();
        } while (!allInterfaces.eq(J9ITablePointer.NULL));
        iTable = iTable.next();
    }
    return size;
}
Also used : J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)

Example 3 with J9ITablePointer

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

the class J9ClassHelper method size.

public static UDATA size(J9ClassPointer clazz, J9JavaVMPointer vm) throws CorruptDataException {
    /*
		 * Size includes up to 7 fragments:
		 * 		0. RAM class header = J9Class struct + vTable + JIT vTable
		 * 		1. RAM methods + extended method block
		 * 		2. Superclasses
		 * 		3. Instance description
		 * 		4. iTable
		 * 		5. Static slots
		 * 		6. Constant pool
		 * 
		 * Array classes omit 1, 3, 5 and 6.
		 */
    // Fragment 0. RAM class header = J9Class struct + vTable + JIT vTable
    UDATA size = new UDATA(J9Class.SIZEOF);
    UDATA vTableSlotCount = vTable(clazz).at(0);
    size = size.add(Scalar.convertSlotsToBytes(vTableSlotCount));
    if (vm.jitConfig().notNull()) {
        UDATA jitVTableSlotCount = vTableSlotCount.sub(1);
        size = size.add(Scalar.convertSlotsToBytes(jitVTableSlotCount));
    }
    if (!J9ROMClassHelper.isArray(clazz.romClass())) {
        // Fragment 1. RAM methods + extended method block
        U32 ramMethodsSize = clazz.romClass().romMethodCount().mult((int) J9Method.SIZEOF);
        size = size.add(ramMethodsSize);
        if (vm.runtimeFlags().allBitsIn(J9Consts.J9_RUNTIME_EXTENDED_METHOD_BLOCK)) {
            UDATA extendedMethodBlockSize = Scalar.roundToSizeofUDATA(new UDATA(clazz.romClass().romMethodCount()));
            size = size.add(extendedMethodBlockSize);
        }
        // Fragment 3. Instance description
        if (!clazz.instanceDescription().anyBitsIn(1)) {
            UDATA highestBitInSlot = new UDATA(UDATA.SIZEOF * 8 - 1);
            UDATA instanceDescriptionSize = clazz.totalInstanceSize().rightShift((int) (ObjectReferencePointer.SIZEOF >> 2) + 1);
            instanceDescriptionSize = instanceDescriptionSize.add(highestBitInSlot).bitAnd(highestBitInSlot.bitNot());
            if (J9BuildFlags.gc_leafBits) {
                instanceDescriptionSize = instanceDescriptionSize.mult(2);
            }
            size = size.add(instanceDescriptionSize);
        }
        // Fragment 5. Static slots
        U32 staticSlotCount = clazz.romClass().objectStaticCount().add(clazz.romClass().singleScalarStaticCount());
        if (J9BuildFlags.env_data64) {
            staticSlotCount = staticSlotCount.add(clazz.romClass().doubleScalarStaticCount());
        } else {
            staticSlotCount = staticSlotCount.add(1).bitAnd(~1L).add(clazz.romClass().doubleScalarStaticCount().mult(2));
        }
        size = size.add(Scalar.convertSlotsToBytes(new UDATA(staticSlotCount)));
        // Fragment 6. Constant pool
        U32 constantPoolSlotCount = clazz.romClass().ramConstantPoolCount().mult(2);
        size = size.add(Scalar.convertSlotsToBytes(new UDATA(constantPoolSlotCount)));
    }
    // Fragment 2. Superclasses
    UDATA classDepth = classDepthAndFlags(clazz).bitAnd(J9JavaAccessFlags.J9AccClassDepthMask);
    if (classDepth.eq(0)) {
        // java/lang/Object has a single slot superclasses array
        size = size.add(UDATA.SIZEOF);
    } else {
        size = size.add(Scalar.convertSlotsToBytes(classDepth));
    }
    // Fragment 4. iTable
    if (clazz.iTable().notNull()) {
        J9ClassPointer superclass = J9ClassPointer.cast(clazz.superclasses().at(classDepth.sub(1)));
        if (superclass.isNull() || !superclass.iTable().eq(clazz.iTable())) {
            J9ITablePointer iTable = J9ITablePointer.cast(clazz.iTable());
            // Scan to the last iTable belonging to classPointer
            if (superclass.isNull()) {
                while (iTable.next().notNull()) {
                    iTable = iTable.next();
                }
            } else {
                while (iTable.next().notNull() && !iTable.next().eq(superclass.iTable())) {
                    iTable = iTable.next();
                }
            }
            // Find the end of the last iTable
            if (clazz.romClass().modifiers().allBitsIn(J9Consts.J9_JAVA_INTERFACE)) {
                iTable = iTable.add(1);
            } else {
                iTable = iTable.add(1).addOffset(iTable.interfaceClass().romClass().romMethodCount().mult(UDATA.SIZEOF));
            }
            size = size.add(iTable.getAddress() - clazz.iTable().getAddress());
        }
    }
    return size;
}
Also used : J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)

Example 4 with J9ITablePointer

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

the class ITableSizeCommand method iTableChainSize.

public long iTableChainSize(J9ITablePointer startTable, J9ITablePointer superTable) throws CorruptDataException {
    long size = 0;
    J9ITablePointer iTable = startTable;
    while (!iTable.eq(superTable)) {
        size += J9ITable.SIZEOF;
        J9ClassPointer interfaceClass = iTable.interfaceClass();
        J9ROMClassPointer romClass = interfaceClass.romClass();
        size += (UDATA.SIZEOF * romClass.romMethodCount().intValue());
        iTable = iTable.next();
    }
    return size;
}
Also used : J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)

Example 5 with J9ITablePointer

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

the class ITableSizeCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long currentSize = 0;
    long duplicatedSize = 0;
    long extendedSize = 0;
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer clazz = (J9ClassPointer) classSegmentIterator.next();
            int classDepth = clazz.classDepthAndFlags().bitAnd(J9_JAVA_CLASS_DEPTH_MASK).intValue();
            J9ITablePointer superITable = J9ITablePointer.NULL;
            J9ITablePointer startITable = J9ITablePointer.cast(clazz.iTable());
            if (0 != classDepth) {
                PointerPointer superclasses = clazz.superclasses();
                J9ClassPointer superclazz = J9ClassPointer.cast(superclasses.at(classDepth - 1));
                superITable = J9ITablePointer.cast(superclazz.iTable());
            }
            currentSize += iTableChainSize(startITable, superITable);
            duplicatedSize += iTableChainSize(superITable, J9ITablePointer.NULL);
            extendedSize += iTableExtendedSize(startITable, superITable);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    long totalSize = duplicatedSize + currentSize;
    double percent = (double) totalSize / (double) currentSize;
    out.append("iTable duplication" + nl);
    out.append("------------------" + nl);
    out.append("current    iTable size : " + currentSize + nl);
    out.append("additional iTable size : " + duplicatedSize + nl);
    out.append("total      iTable size : " + totalSize + nl);
    out.append("growth factor          : " + percent + nl);
    out.append(nl);
    percent = (double) extendedSize / (double) currentSize;
    out.append("iTable contains extends" + nl);
    out.append("-----------------------" + nl);
    out.append("current    iTable size : " + currentSize + nl);
    out.append("new        iTable size : " + extendedSize + nl);
    out.append("growth factor          : " + percent + nl);
    out.append(nl);
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)5 J9ITablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer)5 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)1 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 U32 (com.ibm.j9ddr.vm29.types.U32)1 UDATA (com.ibm.j9ddr.vm29.types.UDATA)1