use of com.ibm.j9ddr.vm29.types.UDATA 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);
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class GCArrayletObjectModelBase_V1 method getSpineSizeWithoutHeader.
/**
* Get the spine size without header for an arraylet with these properties
* @param layout The layout of the indexable object
* @param numberArraylets Number of arraylets for this indexable object
* @param dataSize How many elements are in the indexable object
* @param alignData Should the data section be aligned
* @return spineSize The actual size in byte of the spine
*/
protected UDATA getSpineSizeWithoutHeader(long layout, UDATA numberArraylets, UDATA dataSize, boolean alignData) throws CorruptDataException {
UDATA spineArrayoidSize;
UDATA spinePaddingSize;
/* The spine consists of three (possibly empty) sections, not including the header:
* 1. the alignment word - padding between arrayoid and inline-data
* 2. the arrayoid - an array of pointers to the leaves
* 3. in-line data
* In hybrid specs, the spine may also include padding for a secondary size field in empty arrays
*/
if (J9BuildFlags.gc_hybridArraylets) {
spineArrayoidSize = new UDATA(0);
spinePaddingSize = new UDATA(0);
if (GC_ArrayletObjectModelBase$ArrayLayout.InlineContiguous != layout) {
if (!dataSize.eq(0)) {
/* not in-line, so there in an arrayoid */
spinePaddingSize = alignData ? new UDATA(ObjectModel.getObjectAlignmentInBytes() - ObjectReferencePointer.SIZEOF) : new UDATA(0);
spineArrayoidSize = numberArraylets.mult(ObjectReferencePointer.SIZEOF);
}
}
} else {
spinePaddingSize = alignData ? new UDATA(ObjectReferencePointer.SIZEOF) : new UDATA(0);
spineArrayoidSize = numberArraylets.mult(ObjectReferencePointer.SIZEOF);
}
UDATA spineDataSize = new UDATA(0);
if (GC_ArrayletObjectModelBase$ArrayLayout.InlineContiguous == layout) {
// All data in spine
spineDataSize = dataSize;
} else if (GC_ArrayletObjectModelBase$ArrayLayout.Hybrid == layout) {
// TODO: lpnguyen put this pattern that appears everywhere into UDATA and think up a name, or just use mod?00
// Last arraylet in spine.
spineDataSize = dataSize.bitAnd(arrayletLeafSizeMask);
}
return spinePaddingSize.add(spineArrayoidSize).add(spineDataSize);
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class GCArrayletObjectModelBase_V1 method getArrayLayout.
/**
* Get the layout for the given indexable object
* @param objPtr Pointer to a array object
* @return the ArrayLayout for objectPtr
*/
protected long getArrayLayout(J9IndexableObjectPointer array) throws CorruptDataException {
if (J9BuildFlags.gc_hybridArraylets) {
/* Trivial check for InlineContiguous. */
if (!J9IndexableObjectContiguousPointer.cast(array).size().eq(0)) {
return GC_ArrayletObjectModelBase$ArrayLayout.InlineContiguous;
}
}
/* Check if the objPtr is in the allowed arraylet range. */
if ((array.gte(arrayletRangeBase)) && (array.lt(arrayletRangeTop))) {
UDATA dataSizeInBytes = getDataSizeInBytes(array);
long layout = getArrayLayout(J9IndexableObjectHelper.clazz(array), dataSizeInBytes);
return layout;
}
return GC_ArrayletObjectModelBase$ArrayLayout.InlineContiguous;
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class GCArrayletObjectModelBase_V1 method numArraylets.
/**
* Return the total number of arraylets for an indexable object with a size of dataInSizeByte, including a (possibly empty) leaf in the spine.
* @param dataSizeInBytes size of an array in bytes (not elements)
* @return the number of arraylets used for an array of dataSizeInBytes bytes
*/
protected UDATA numArraylets(UDATA unadjustedDataSizeInBytes) throws CorruptDataException {
UDATA numberOfArraylets = new UDATA(1);
if (!UDATA.MAX.eq(arrayletLeafSize)) {
/* We add one to unadjustedDataSizeInBytes to ensure that it's always possible to determine the address
* of the after-last element without crashing. Handle the case of UDATA_MAX specially, since we use that
* for any object whose size overflows the address space.
*/
UDATA dataSizeInBytes = UDATA.MAX.eq(unadjustedDataSizeInBytes) ? UDATA.MAX : unadjustedDataSizeInBytes.add(1);
/* CMVC 135307 : following logic for calculating the leaf count would not overflow dataSizeInBytes.
* the assumption is leaf size is order of 2. It's identical to:
* if (dataSizeInBytes % leafSize) is 0
* leaf count = dataSizeInBytes >> leafLogSize
* else
* leaf count = (dataSizeInBytes >> leafLogSize) + 1
*/
numberOfArraylets = (dataSizeInBytes.rightShift(arrayletLeafLogSize)).add(((dataSizeInBytes.bitAnd(arrayletLeafSizeMask)).add(arrayletLeafSizeMask)).rightShift(arrayletLeafLogSize));
}
return numberOfArraylets;
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class GCArrayletObjectModelBase_V1 method getSpineSize.
/**
* Get the spine size for the given indexable object
* @param objPtr Pointer to an array object
* @return The total size in bytes of objPtr's array spine;
* includes header, arraylet ptrs, and (if present) padding & inline data
*/
protected UDATA getSpineSize(J9IndexableObjectPointer array) throws CorruptDataException {
long layout = getArrayLayout(array);
boolean alignData = shouldAlignSpineDataSection(J9IndexableObjectHelper.clazz(array));
UDATA dataSize = getDataSizeInBytes(array);
UDATA numberArraylets = numArraylets(dataSize);
return getSpineSize(layout, numberArraylets, dataSize, alignData);
}
Aggregations