use of com.ibm.j9ddr.vm29.types.UDATA 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);
}
use of com.ibm.j9ddr.vm29.types.UDATA 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;
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class GCMemoryPool method freeEntryCheckGeneric.
/**
* Check individual entries. This check is the same for ALL collectors
* @param freeListEntry A structure to a free entry for all collectors (except Balanced)
* @throws CorruptFreeEntryException This needs to be caught by a listener to be of any use
* @return None. This function throws exceptions which are caught by the listener in checkFreeLists()
*/
protected void freeEntryCheckGeneric(GCHeapLinkedFreeHeader freeListEntry) throws CorruptDataException, CorruptFreeEntryException {
MM_HeapLinkedFreeHeaderPointer freeListEntryAddress = freeListEntry.getHeader();
UDATA size = freeListEntry.getSize();
GCHeapRegionDescriptor region = getRegion();
U8Pointer entryEndingAddressInclusive = U8Pointer.cast(freeListEntry.getHeader()).add(size.sub(1));
if (freeListEntry.getHeader().isNull()) {
throw new CorruptFreeEntryException("freeEntryCorrupt", freeListEntryAddress);
}
/* Make sure its a multi-slot dead object */
if (!(ObjectModel.isDeadObject(freeListEntry.getObject()) && !ObjectModel.isSingleSlotDeadObject(freeListEntry.getObject()))) {
throw new CorruptFreeEntryException("freeEntryCorrupt", freeListEntryAddress);
}
/* Self checks */
if (!region.isAddressInRegion(VoidPointer.cast(freeListEntryAddress))) {
throw new CorruptFreeEntryException("freeEntryCorrupt", freeListEntryAddress);
}
if (!region.isAddressInRegion(VoidPointer.cast(entryEndingAddressInclusive))) {
throw new CorruptFreeEntryException("sizeFieldInvalid", freeListEntryAddress);
}
}
use of com.ibm.j9ddr.vm29.types.UDATA 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);
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class GCHeapMap method getSlotIndexAndMask.
/**
* Return the index into the heap map bits array and the bitmask to use.
* @param object
* @return an array containing the slot index and bit mask
*/
public UDATA[] getSlotIndexAndMask(J9ObjectPointer object) {
UDATA heapBaseOffset = UDATA.cast(object).sub(UDATA.cast(_heapBase));
if (heapBaseOffset.gte(_maxOffset)) {
throw new IllegalArgumentException("Object is not in heap: " + object);
}
UDATA bitIndex = heapBaseOffset.bitAnd(_heapMapBitMask);
bitIndex = bitIndex.rightShift(_heapMapBitShift);
UDATA bitMask = new UDATA(1).leftShift(bitIndex);
UDATA slotIndex = heapBaseOffset.rightShift(new UDATA(_heapMapIndexShift));
UDATA[] result = new UDATA[2];
result[0] = slotIndex;
result[1] = bitMask;
return result;
}
Aggregations