Search in sources :

Example 1 with U32

use of com.ibm.j9ddr.vm29.types.U32 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 */
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) IDATA(com.ibm.j9ddr.vm29.types.IDATA)

Example 2 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class ObjectHash method mix.

static U32 mix(U32 hashValue, U32 datum) {
    final U32 MUL1 = new U32(0xcc9e2d51);
    final U32 MUL2 = new U32(0x1b873593);
    final U32 ADD1 = new U32(0xe6546b64);
    datum = datum.mult(MUL1);
    datum = rotateLeft(datum, 15);
    datum = datum.mult(MUL2);
    hashValue = hashValue.bitXor(datum);
    hashValue = rotateLeft(hashValue, 13);
    hashValue = hashValue.mult(5);
    hashValue = hashValue.add(ADD1);
    return hashValue;
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32)

Example 3 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class ObjectFieldInfo method countAndCopyHiddenFields.

int countAndCopyHiddenFields(LinkedList<HiddenInstanceField> hiddenFieldList, ArrayList<HiddenInstanceField> hiddenFieldArray) throws CorruptDataException {
    String className = J9UTF8Helper.stringValue(romClass.className());
    hiddenFieldCount = 0;
    for (HiddenInstanceField hiddenField : hiddenFieldList) {
        if (hiddenField.className() == null || className.equals(hiddenField.className())) {
            U32 modifiers = hiddenField.shape().modifiers();
            if (modifiers.anyBitsIn(J9FieldFlagObject)) {
                totalObjectCount += 1;
            } else if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
                totalDoubleCount += 1;
            } else {
                totalSingleCount += 1;
            }
            hiddenFieldArray.add(hiddenField);
            hiddenFieldCount += 1;
        }
    }
    return hiddenFieldCount;
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32)

Example 4 with U32

use of com.ibm.j9ddr.vm29.types.U32 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);
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) I32(com.ibm.j9ddr.vm29.types.I32)

Example 5 with U32

use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.

the class MonitorTableList method peek.

/**
 * Search all the monitor tables in the J9JavaVM->monitorTables for the inflated monitor corresponding to the specified object
 *
 * @throws CorruptDataException
 *
 * @param object the object
 *
 * @returns the J9ObjectMonitorPointer found in the table, or J9ObjectMonitorPointer.NULL if no entry was found
 *
 * @see util/thrinfo.c : monitorTablePeek
 */
public static J9ObjectMonitorPointer peek(J9ObjectPointer object) throws CorruptDataException {
    if ((null == object) || (object.isNull())) {
        return J9ObjectMonitorPointer.NULL;
    }
    MonitorTable table = null;
    if (!initialized) {
        initializeCaches();
    }
    J9ObjectMonitorPointer objectMonitor = J9ObjectMonitorPointer.NULL;
    long hashcode = new U32(ObjectModel.getObjectHashCode(object)).longValue();
    int index = (int) (hashcode % monitorTables.length);
    table = monitorTables[index];
    if (table == null) {
        return objectMonitor;
    }
    if (null != table) {
        objectMonitor = table.peek(object);
        if (null == objectMonitor) {
            return J9ObjectMonitorPointer.NULL;
        }
    }
    return objectMonitor;
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer)

Aggregations

U32 (com.ibm.j9ddr.vm29.types.U32)44 UDATA (com.ibm.j9ddr.vm29.types.UDATA)16 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)9 CorruptDataException (com.ibm.j9ddr.CorruptDataException)6 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)6 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)6 J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)6 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)5 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)5 OMRMemCategoryPointer (com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer)4 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)3 J9ArrayClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)3 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)3 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)3 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)3 U16 (com.ibm.j9ddr.vm29.types.U16)3 U8 (com.ibm.j9ddr.vm29.types.U8)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 J9ROMFieldShapeIterator (com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator)2 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)2