Search in sources :

Example 1 with J9ArrayClassPointer

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

the class GCArrayletObjectModelBase_V1 method getDataSizeInBytes.

/**
 * Returns the size of data in an indexable object, in bytes, including leaves, excluding the header.
 * @param arrayPtr Pointer to the indexable object whose size is required
 * @return Size of object in bytes excluding the header
 */
public UDATA getDataSizeInBytes(J9IndexableObjectPointer array) throws CorruptDataException {
    J9ArrayClassPointer clazz = J9IndexableObjectHelper.clazz(array);
    U32 arrayShape = J9ROMArrayClassPointer.cast(clazz.romClass()).arrayShape();
    UDATA numberOfElements = getSizeInElements(array);
    UDATA size = numberOfElements.leftShift(arrayShape.bitAnd(0x0000FFFF).intValue());
    return UDATA.roundToSizeofUDATA(size);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) J9ArrayClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)

Example 2 with J9ArrayClassPointer

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

the class J9ClassHelper method getJavaName.

public static String getJavaName(J9ClassPointer clazz) throws CorruptDataException {
    String baseName = getName(clazz);
    char ch = baseName.charAt(0);
    if (ch != '[') {
        return baseName;
    }
    J9ArrayClassPointer arrayClass = J9ArrayClassPointer.cast(clazz);
    int arity = arrayClass.arity().intValue();
    StringBuilder buf = new StringBuilder();
    for (int i = 0; i < arity; i++) {
        buf.append("[]");
    }
    String aritySuffix = buf.toString();
    ch = baseName.charAt(1);
    switch(ch) {
        case 'B':
            return "byte" + aritySuffix;
        case 'C':
            return "char" + aritySuffix;
        case 'D':
            return "double" + aritySuffix;
        case 'F':
            return "float" + aritySuffix;
        case 'I':
            return "int" + aritySuffix;
        case 'J':
            return "long" + aritySuffix;
        case 'S':
            return "void" + aritySuffix;
        case 'V':
            return "void" + aritySuffix;
        case 'Z':
            return "boolean" + aritySuffix;
        case 'L':
            return getName(arrayClass.leafComponentType()) + aritySuffix;
    }
    // Should never happen
    return baseName;
}
Also used : J9ArrayClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)

Example 3 with J9ArrayClassPointer

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

the class GCArrayletObjectModelBase_V1 method getHashcodeOffset.

@Override
public UDATA getHashcodeOffset(J9IndexableObjectPointer array) throws CorruptDataException {
    // Don't call getDataSizeInBytes() since that rounds up to UDATA.
    long layout = getArrayLayout(array);
    J9ArrayClassPointer clazz = J9IndexableObjectHelper.clazz(array);
    U32 arrayShape = J9ROMArrayClassPointer.cast(clazz.romClass()).arrayShape();
    UDATA numberOfElements = getSizeInElements(array);
    UDATA dataSize = numberOfElements.leftShift(arrayShape.bitAnd(0x0000FFFF).intValue());
    UDATA numberArraylets = numArraylets(dataSize);
    boolean alignData = shouldAlignSpineDataSection(clazz);
    UDATA spineSize = getSpineSize(layout, numberArraylets, dataSize, alignData);
    return U32.roundToSizeofU32(spineSize);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) J9ArrayClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)

Example 4 with J9ArrayClassPointer

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

the class GCArrayletObjectModelBase_V1 method getArrayLayout.

/**
 * Get the layout of an indexable object given it's class, data size in bytes and the subspace's largestDesirableSpine.
 * @param clazz The class of the object stored in the array.
 * @param dataSizeInBytes the size in bytes of the data of the array.
 * @param largestDesirableSpine The largest desirable spine of the arraylet.
 */
protected long getArrayLayout(J9ArrayClassPointer clazz, UDATA dataSizeInBytes) throws CorruptDataException {
    long layout = GC_ArrayletObjectModelBase$ArrayLayout.Illegal;
    UDATA minimumSpineSize;
    if (J9BuildFlags.gc_hybridArraylets) {
        minimumSpineSize = new UDATA(0);
    } else {
        minimumSpineSize = new UDATA(ObjectReferencePointer.SIZEOF);
    }
    UDATA minimumSpineSizeAfterGrowing = minimumSpineSize;
    if (GCExtensions.isVLHGC()) {
        /* CMVC 170688:  Ensure that we don't try to allocate an inline contiguous array of a size which will overflow the region if it ever grows
			 * (easier to handle this case in the allocator than to special-case the collectors to know how to avoid this case)
			 * (currently, we only grow by a hashcode slot which is 4-bytes but will increase our size by the granule of alignment)
			 */
        minimumSpineSize = minimumSpineSize.add(ObjectModel.getObjectAlignmentInBytes());
    }
    /* CMVC 135307 : when checking for InlineContiguous layout, perform subtraction as adding to dataSizeInBytes could trigger overflow. */
    if (largestDesirableArraySpineSize.eq(UDATA.MAX) || dataSizeInBytes.lte(largestDesirableArraySpineSize.sub(minimumSpineSizeAfterGrowing).sub(J9IndexableObjectContiguous.SIZEOF))) {
        layout = GC_ArrayletObjectModelBase$ArrayLayout.InlineContiguous;
        if (J9BuildFlags.gc_hybridArraylets) {
            if (dataSizeInBytes.eq(0)) {
                /* Zero sized NUA uses the discontiguous shape */
                layout = GC_ArrayletObjectModelBase$ArrayLayout.Discontiguous;
            }
        }
    } else {
        UDATA lastArrayletBytes = dataSizeInBytes.bitAnd(arrayletLeafSizeMask);
        /* determine how large the spine would be if this were a hybrid array */
        UDATA numberArraylets = numArraylets(dataSizeInBytes);
        boolean align = shouldAlignSpineDataSection(clazz);
        UDATA hybridSpineBytes = getSpineSize(GC_ArrayletObjectModelBase$ArrayLayout.Hybrid, numberArraylets, dataSizeInBytes, align);
        UDATA adjustedHybridSpineBytes = ObjectModel.adjustSizeInBytes(hybridSpineBytes);
        UDATA adjustedHybridSpineBytesAfterMove = adjustedHybridSpineBytes;
        if (GCExtensions.isVLHGC()) {
            adjustedHybridSpineBytesAfterMove.add(ObjectModel.getObjectAlignmentInBytes());
        }
        if (lastArrayletBytes.gt(0) && adjustedHybridSpineBytesAfterMove.lte(largestDesirableArraySpineSize)) {
            layout = GC_ArrayletObjectModelBase$ArrayLayout.Hybrid;
        } else {
            layout = GC_ArrayletObjectModelBase$ArrayLayout.Discontiguous;
        }
    }
    return layout;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA)

Example 5 with J9ArrayClassPointer

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

the class GCContiguousArrayObjectModel_V1 method getHashcodeOffset.

public UDATA getHashcodeOffset(J9IndexableObjectPointer array) throws CorruptDataException {
    J9ArrayClassPointer clazz = J9IndexableObjectHelper.clazz(array);
    UDATA numberOfElements = getSizeInElements(array);
    J9ROMArrayClassPointer romArrayClass = J9ROMArrayClassPointer.cast(clazz.romClass());
    UDATA size = numberOfElements.leftShift(romArrayClass.arrayShape().bitAnd(0xFFFF).intValue());
    size = size.add(J9IndexableObjectContiguous.SIZEOF);
    return UDATA.roundToSizeofU32(size);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9ROMArrayClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMArrayClassPointer) J9ArrayClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)

Aggregations

J9ArrayClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)4 U32 (com.ibm.j9ddr.vm29.types.U32)3 AddressedCorruptDataException (com.ibm.j9ddr.AddressedCorruptDataException)1 InvalidDataTypeException (com.ibm.j9ddr.InvalidDataTypeException)1 J9ROMArrayClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMArrayClassPointer)1