use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class ObjectFieldInfo method countInstanceFields.
void countInstanceFields() throws CorruptDataException {
/* iterate over fields to count instance fields by size */
Iterable<J9ROMFieldShapePointer> fields = new J9ROMFieldShapeIterator(romClass.romFields(), romClass.romFieldCount());
for (J9ROMFieldShapePointer f : fields) {
U32 modifiers = f.modifiers();
if (!modifiers.anyBitsIn(J9AccStatic)) {
if (modifiers.anyBitsIn(J9FieldFlagObject)) {
instanceObjectCount += 1;
totalObjectCount += 1;
} else if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
instanceDoubleCount += 1;
totalDoubleCount += 1;
} else {
instanceSingleCount += 1;
totalSingleCount += 1;
}
}
}
instanceFieldBackfillEligible = (instanceSingleCount > 0) || (objectCanUseBackfill && (instanceSingleCount > 0));
}
use of com.ibm.j9ddr.vm29.types.U32 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.U32 in project openj9 by eclipse.
the class J9ClassHelper method getRawModifiers.
/**
* Returns "raw" modifiers
*
* Derived from logic in J9VMJavaLangClassNativesCDLC.getModifiersImpl
* @param j9class
* @return
* @throws CorruptDataException
*/
public static int getRawModifiers(J9ClassPointer j9class) throws CorruptDataException {
if (J9ClassHelper.isArrayClass(j9class)) {
J9ArrayClassPointer arrayClass = J9ArrayClassPointer.cast(j9class);
U32 modifiers = arrayClass.leafComponentType().romClass().modifiers();
// OR in the bogus Sun bits
modifiers = modifiers.bitOr(J9JavaAccessFlags.J9AccAbstract);
modifiers = modifiers.bitOr(J9JavaAccessFlags.J9AccFinal);
return modifiers.intValue();
} else {
U32 modifiers = j9class.romClass().modifiers();
if (j9class.romClass().outerClassName().notNull()) {
modifiers = j9class.romClass().memberAccessFlags();
}
return modifiers.intValue();
}
}
use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class J9ClassHelper method size.
public static UDATA size(J9ClassPointer clazz, J9JavaVMPointer vm) throws CorruptDataException {
/*
* Size includes up to 7 fragments:
* 0. RAM class header = J9Class struct + vTable + JIT vTable
* 1. RAM methods + extended method block
* 2. Superclasses
* 3. Instance description
* 4. iTable
* 5. Static slots
* 6. Constant pool
*
* Array classes omit 1, 3, 5 and 6.
*/
// Fragment 0. RAM class header = J9Class struct + vTable + JIT vTable
UDATA size = new UDATA(J9Class.SIZEOF);
UDATA vTableSlotCount = vTable(clazz).at(0);
size = size.add(Scalar.convertSlotsToBytes(vTableSlotCount));
if (vm.jitConfig().notNull()) {
UDATA jitVTableSlotCount = vTableSlotCount.sub(1);
size = size.add(Scalar.convertSlotsToBytes(jitVTableSlotCount));
}
if (!J9ROMClassHelper.isArray(clazz.romClass())) {
// Fragment 1. RAM methods + extended method block
U32 ramMethodsSize = clazz.romClass().romMethodCount().mult((int) J9Method.SIZEOF);
size = size.add(ramMethodsSize);
if (vm.runtimeFlags().allBitsIn(J9Consts.J9_RUNTIME_EXTENDED_METHOD_BLOCK)) {
UDATA extendedMethodBlockSize = Scalar.roundToSizeofUDATA(new UDATA(clazz.romClass().romMethodCount()));
size = size.add(extendedMethodBlockSize);
}
// Fragment 3. Instance description
if (!clazz.instanceDescription().anyBitsIn(1)) {
UDATA highestBitInSlot = new UDATA(UDATA.SIZEOF * 8 - 1);
UDATA instanceDescriptionSize = clazz.totalInstanceSize().rightShift((int) (ObjectReferencePointer.SIZEOF >> 2) + 1);
instanceDescriptionSize = instanceDescriptionSize.add(highestBitInSlot).bitAnd(highestBitInSlot.bitNot());
if (J9BuildFlags.gc_leafBits) {
instanceDescriptionSize = instanceDescriptionSize.mult(2);
}
size = size.add(instanceDescriptionSize);
}
// Fragment 5. Static slots
U32 staticSlotCount = clazz.romClass().objectStaticCount().add(clazz.romClass().singleScalarStaticCount());
if (J9BuildFlags.env_data64) {
staticSlotCount = staticSlotCount.add(clazz.romClass().doubleScalarStaticCount());
} else {
staticSlotCount = staticSlotCount.add(1).bitAnd(~1L).add(clazz.romClass().doubleScalarStaticCount().mult(2));
}
size = size.add(Scalar.convertSlotsToBytes(new UDATA(staticSlotCount)));
// Fragment 6. Constant pool
U32 constantPoolSlotCount = clazz.romClass().ramConstantPoolCount().mult(2);
size = size.add(Scalar.convertSlotsToBytes(new UDATA(constantPoolSlotCount)));
}
// Fragment 2. Superclasses
UDATA classDepth = classDepthAndFlags(clazz).bitAnd(J9JavaAccessFlags.J9AccClassDepthMask);
if (classDepth.eq(0)) {
// java/lang/Object has a single slot superclasses array
size = size.add(UDATA.SIZEOF);
} else {
size = size.add(Scalar.convertSlotsToBytes(classDepth));
}
// Fragment 4. iTable
if (clazz.iTable().notNull()) {
J9ClassPointer superclass = J9ClassPointer.cast(clazz.superclasses().at(classDepth.sub(1)));
if (superclass.isNull() || !superclass.iTable().eq(clazz.iTable())) {
J9ITablePointer iTable = J9ITablePointer.cast(clazz.iTable());
// Scan to the last iTable belonging to classPointer
if (superclass.isNull()) {
while (iTable.next().notNull()) {
iTable = iTable.next();
}
} else {
while (iTable.next().notNull() && !iTable.next().eq(superclass.iTable())) {
iTable = iTable.next();
}
}
// Find the end of the last iTable
if (clazz.romClass().modifiers().allBitsIn(J9Consts.J9_JAVA_INTERFACE)) {
iTable = iTable.add(1);
} else {
iTable = iTable.add(1).addOffset(iTable.interfaceClass().romClass().romMethodCount().mult(UDATA.SIZEOF));
}
size = size.add(iTable.getAddress() - clazz.iTable().getAddress());
}
}
return size;
}
use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class J9MemTagHelper method checkTagSumCheck.
/**
* Checks that the memory tag is not corrupt.
*
* @param[in] tagAddress the in-process or out-of-process address of the
* header/footer memory tag
* @param[in] eyeCatcher the eyecatcher corresponding to the memory tag
*
* @return 0 if the sum check is successful, non-zero otherwise
* @throws CorruptDataException
*/
public static void checkTagSumCheck(J9MemTagPointer tag, long eyeCatcher) throws CorruptDataException {
int sum = 0;
U32Pointer slots;
if (!checkEyecatcher(tag, eyeCatcher)) {
throw new J9MemTagCheckError(tag, "Wrong eyecatcher. Expected 0x" + Long.toHexString(eyeCatcher) + " but was " + UDATA.cast(tag).getHexValue());
}
slots = U32Pointer.cast(tag);
/*
* Could be unrolled into chained xors with a J9VM_ENV_DATA64
* conditional on the extra 2 U_32s
*/
for (int i = 0; i < (J9MemTag.SIZEOF / U32.SIZEOF); i++) {
sum ^= slots.at(i).longValue();
}
if (J9BuildFlags.env_data64) {
U32 a = new U32(UDATA.cast(tag).rightShift(32));
U32 b = new U32(UDATA.cast(tag).bitAnd(U32.MAX));
sum ^= a.longValue() ^ b.longValue();
} else {
sum ^= tag.longValue();
}
if (sum != 0) {
throw new J9MemTagCheckError(tag, "J9MemTag sumcheck failed: " + sum);
}
}
Aggregations