use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class J9ObjectFieldOffsetIterator_V1 method calculateInstanceSize.
private void calculateInstanceSize(J9ROMClassPointer romClass, J9ClassPointer superClazz) throws CorruptDataException {
lockwordNeeded = NO_LOCKWORD_NEEDED;
/* if we only care about statics we can skip all work related to instance size calculations */
if (!walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_CALCULATE_INSTANCE_SIZE)) {
return;
}
ObjectFieldInfo fieldInfo = new ObjectFieldInfo(romClass);
/*
* Step 1: Calculate the size of the superclass and backfill offset.
* Inherit the instance size and backfillOffset from the superclass.
*/
if (superClazz.notNull()) {
/*
* Note that in the J9Class, we do not store -1 to indicate no back fill,
* we store the total instance size (including the header) instead.
*/
fieldInfo.setSuperclassFieldsSize(superClazz.totalInstanceSize().intValue());
if (!superClazz.backfillOffset().eq(superClazz.totalInstanceSize().add(J9Object.SIZEOF))) {
fieldInfo.setSuperclassBackfillOffset(superClazz.backfillOffset().sub(J9Object.SIZEOF).intValue());
}
} else {
fieldInfo.setSuperclassFieldsSize(0);
}
lockwordNeeded = checkLockwordNeeded(romClass, superClazz, instanceClass);
/*
* remove the lockword from Object (if there is one) only if we don't need a lockword or we do need one
* and we are not re-using the one from Object which we can tell because lockwordNeeded is LOCKWORD_NEEDED as
* opposed to the value of the existing offset.
*/
if ((LOCKWORD_NEEDED.equals(lockwordNeeded)) || (NO_LOCKWORD_NEEDED.equals(lockwordNeeded))) {
if (superClazz.notNull() && !superClazz.lockOffset().eq(new UDATA(-1)) && J9ClassHelper.classDepth(superClazz).isZero()) {
int newSuperSize = fieldInfo.getSuperclassFieldsSize() - LOCKWORD_SIZE;
/* this may have been rounded to 8 bytes so also get rid of the padding */
if (fieldInfo.isSuperclassBackfillSlotAvailable()) {
/* j.l.Object was not end aligned */
newSuperSize -= BACKFILL_SIZE;
fieldInfo.setSuperclassBackfillOffset(NO_BACKFILL_AVAILABLE);
}
fieldInfo.setSuperclassFieldsSize(newSuperSize);
}
}
/*
* Step 2: Determine which extra hidden fields we need and prepend them to the list of hidden fields.
*/
LinkedList<HiddenInstanceField> extraHiddenFields = copyHiddenInstanceFieldsList(vm);
finalizeLinkOffset = new UDATA(0);
if (!superClazz.isNull() && !superClazz.finalizeLinkOffset().isZero()) {
/* Superclass is finalizeable */
finalizeLinkOffset = superClazz.finalizeLinkOffset();
} else {
/* Superclass is not finalizeable */
if (J9ROMClassHelper.finalizeNeeded(romClass)) {
extraHiddenFields.addFirst(new HiddenInstanceField(vm.hiddenFinalizeLinkFieldShape()));
}
}
lockOffset = new UDATA(lockwordNeeded);
if (lockOffset.eq(LOCKWORD_NEEDED)) {
extraHiddenFields.addFirst(new HiddenInstanceField(vm.hiddenLockwordFieldShape()));
}
/*
* Step 3: Calculate the number of various categories of fields: single word primitive, double word primitive, and object references.
* Iterate over fields to count instance fields by size.
*/
fieldInfo.countInstanceFields();
fieldInfo.countAndCopyHiddenFields(extraHiddenFields, hiddenInstanceFieldList);
new UDATA(fieldInfo.calculateTotalFieldsSizeAndBackfill());
firstDoubleOffset = new UDATA(fieldInfo.calculateFieldDataStart());
firstObjectOffset = new UDATA(fieldInfo.addDoublesArea(firstDoubleOffset.intValue()));
firstSingleOffset = new UDATA(fieldInfo.addObjectsArea(firstObjectOffset.intValue()));
if (fieldInfo.isMyBackfillSlotAvailable() && fieldInfo.isBackfillSuitableFieldAvailable()) {
if (fieldInfo.isBackfillSuitableInstanceSingleAvailable()) {
walkFlags = walkFlags.bitOr(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD);
} else if (fieldInfo.isBackfillSuitableInstanceObjectAvailable()) {
walkFlags = walkFlags.bitOr(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD);
}
}
/*
* Calculate offsets (from the object header) for hidden fields. Hidden fields follow immediately the instance fields of the same type.
* Give instance fields priority for backfill slots.
* Note that the hidden fields remember their offsets, so this need be done once only.
*/
if (!hiddenInstanceFieldList.isEmpty()) {
UDATA hiddenSingleOffset = firstSingleOffset.add(J9Object.SIZEOF + (fieldInfo.getNonBackfilledInstanceSingleCount() * U32.SIZEOF));
UDATA hiddenDoubleOffset = firstDoubleOffset.add(J9Object.SIZEOF + (fieldInfo.getInstanceDoubleCount() * U64.SIZEOF));
UDATA hiddenObjectOffset = firstObjectOffset.add(J9Object.SIZEOF + (fieldInfo.getNonBackfilledInstanceObjectCount() * fj9object_t_SizeOf));
boolean useBackfillForObject = false;
boolean useBackfillForSingle = false;
if (fieldInfo.isMyBackfillSlotAvailable() && !walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD | J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD)) {
/* There are no backfill-suitable instance fields, so let the hidden fields use the backfill slot */
if (fieldInfo.isBackfillSuitableSingleAvailable()) {
useBackfillForSingle = true;
} else if (fieldInfo.isBackfillSuitableObjectAvailable()) {
useBackfillForObject = true;
}
}
for (HiddenInstanceField hiddenField : hiddenInstanceFieldList) {
U32 modifiers = hiddenField.shape().modifiers();
if (modifiers.allBitsIn(J9FieldFlagObject)) {
if (useBackfillForObject) {
hiddenField.setFieldOffset(fieldInfo.getMyBackfillOffsetForHiddenField());
useBackfillForObject = false;
} else {
hiddenField.setFieldOffset(hiddenObjectOffset);
hiddenObjectOffset = hiddenObjectOffset.add(fj9object_t_SizeOf);
}
} else if (modifiers.allBitsIn(J9FieldSizeDouble)) {
hiddenField.setFieldOffset(hiddenDoubleOffset);
hiddenDoubleOffset = hiddenDoubleOffset.add(U64.SIZEOF);
} else {
if (useBackfillForSingle) {
hiddenField.setFieldOffset(fieldInfo.getMyBackfillOffsetForHiddenField());
useBackfillForSingle = false;
} else {
hiddenField.setFieldOffset(hiddenSingleOffset);
hiddenSingleOffset = hiddenSingleOffset.add(U32.SIZEOF);
}
}
}
}
backfillOffsetToUse = new IDATA(fieldInfo.getMyBackfillOffset());
/* backfill offset for this class's fields */
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class HashTable_V1 method find.
// find by pointer value
@Override
public StructType find(StructType entry) throws CorruptDataException {
UDATA hash = _hashFn.hash(entry).mod(_table.tableSize());
PointerPointer head = _table.nodes().add(hash);
VoidPointer findNode = VoidPointer.NULL;
if (_table.listNodePool().isNull()) {
PointerPointer node = hashTableFindNodeSpaceOpt(_table, entry, head);
if (node.at(0).notNull()) {
findNode = VoidPointer.cast(node);
} else {
findNode = VoidPointer.NULL;
}
} else if (head.at(0).isNull()) {
findNode = VoidPointer.NULL;
} else if (isAVLTreeTagged(head.at(0))) {
findNode = hashTableFindNodeInTree(_table, entry, head);
} else {
findNode = hashTableFindNodeInList(_table, entry, head);
}
if (!_isInline && findNode.notNull()) {
findNode = PointerPointer.cast(findNode).at(0);
}
StructType node = (StructType) DataType.getStructure(_structType, findNode.getAddress());
return node;
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class ObjectHash method inlineConvertValueToHash.
private static I32 inlineConvertValueToHash(J9JavaVMPointer vm, UDATA objectPointer) throws CorruptDataException {
final U32 MUL1 = new U32(0x85ebca6b);
final U32 MUL2 = new U32(0xc2b2ae35);
U32 hashValue = getSalt(vm, objectPointer);
UDATA shiftedAddress = objectPointer.div(ObjectModel.getObjectAlignmentInBytes());
U32 datum = new U32(shiftedAddress.bitAnd(0xffffffff));
hashValue = mix(hashValue, datum);
if (J9BuildFlags.env_data64) {
datum = new U32(shiftedAddress.rightShift(32));
hashValue = mix(hashValue, datum);
}
hashValue = hashValue.bitXor(UDATA.SIZEOF);
hashValue = hashValue.bitXor(hashValue.rightShift(16));
hashValue = hashValue.mult(MUL1);
hashValue = hashValue.bitXor(hashValue.rightShift(13));
hashValue = hashValue.mult(MUL2);
hashValue = hashValue.bitXor(hashValue.rightShift(16));
return new I32(hashValue);
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class RootScanner method scanNonCollectableObjectsInternal.
private void scanNonCollectableObjectsInternal(long memoryType) throws CorruptDataException {
GCHeapRegionIterator regionIterator = GCHeapRegionIterator.from();
while (regionIterator.hasNext()) {
GCHeapRegionDescriptor region = regionIterator.next();
if (new UDATA(region.getTypeFlags()).allBitsIn(memoryType)) {
GCObjectHeapIterator objectIterator = GCObjectHeapIterator.fromHeapRegionDescriptor(region, true, false);
while (objectIterator.hasNext()) {
J9ObjectPointer object = objectIterator.next();
doClassSlot(J9ObjectHelper.clazz(object));
GCObjectIterator fieldIterator = GCObjectIterator.fromJ9Object(object, true);
GCObjectIterator fieldAddressIterator = GCObjectIterator.fromJ9Object(object, true);
while (fieldIterator.hasNext()) {
doNonCollectableObjectSlot(fieldIterator.next(), fieldAddressIterator.nextAddress());
}
}
}
}
}
use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.
the class StringTable method search.
public J9ObjectPointer search(J9ObjectPointer objectPointer) throws CorruptDataException {
UDATA hashCode = _hashFn.hash(PointerPointer.cast(objectPointer));
UDATA tableIndex = getTableIndex(hashCode);
J9HashTablePointer hashTablePtr = getTable(tableIndex);
HashTable<J9ObjectPointer> currentHashTable = HashTable.fromJ9HashTable(hashTablePtr, false, J9ObjectPointer.class, new StringTable.StringHashFunction<J9ObjectPointer>(), new StringTable.StringComparatorFunction<J9ObjectPointer>());
J9ObjectPointer result = currentHashTable.find(objectPointer);
return result;
}
Aggregations