use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer in project openj9 by eclipse.
the class DTFJJavaFieldInstance method get.
public Object get(JavaObject object) throws CorruptDataException, MemoryAccessException {
if (null == object) {
throw new NullPointerException("JavaObject is null");
}
try {
switch(getSigFlag()) {
case BOOLEAN_SIGNATURE:
return Boolean.valueOf(getBoolean(object));
case BYTE_SIGNATURE:
return Byte.valueOf(getByte(object));
case CHAR_SIGNATURE:
return Character.valueOf(getChar(object));
case SHORT_SIGNATURE:
return Short.valueOf(getShort(object));
case INTEGER_SIGNATURE:
return Integer.valueOf(getInt(object));
case FLOAT_SIGNATURE:
return new Float(getFloat(object));
case LONG_SIGNATURE:
return Long.valueOf(getLong(object));
case DOUBLE_SIGNATURE:
return new Double(getDouble(object));
case ARRAY_PREFIX_SIGNATURE:
case OBJECT_PREFIX_SIGNATURE:
J9ROMFieldShapePointer fieldShape = fieldOffset.getField();
DTFJJavaObject jobj = validateJavaObject(object);
checkDataTypeConversion(jobj, FIELD_OBJECT | FIELD_ARRAY);
J9ObjectPointer data = J9ObjectHelper.getObjectField(jobj.getJ9ObjectPointer(), fieldOffset);
if (data.isNull()) {
return null;
} else {
return new DTFJJavaObject(null, data);
}
default:
throw new IllegalArgumentException("Cannot determine the correct data type");
}
} catch (Throwable t) {
// the whitelist will cause IllegalArgumentException to be re-thrown
throw J9DDRDTFJUtils.handleAllButMemAccExAsCorruptDataException(DTFJContext.getProcess(), t, whitelist);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method printObjectField.
public void printObjectField(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, J9ClassPointer fromClass, J9ObjectFieldOffset objectFieldOffset) throws CorruptDataException {
J9ROMFieldShapePointer fieldShape = objectFieldOffset.getField();
UDATA fieldOffset = objectFieldOffset.getOffsetOrAddress();
boolean isHiddenField = objectFieldOffset.isHidden();
String className = J9UTF8Helper.stringValue(fromClass.romClass().className());
String fieldName = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().name());
String fieldSignature = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().signature());
U8Pointer valuePtr = dataStart;
valuePtr = valuePtr.add(fieldOffset);
padding(out, tabLevel);
out.print(String.format("%s %s = ", fieldSignature, fieldName));
if (fieldShape.modifiers().anyBitsIn(J9FieldSizeDouble)) {
out.print(U64Pointer.cast(valuePtr).at(0).getHexValue());
} else if (fieldShape.modifiers().anyBitsIn(J9FieldFlagObject)) {
AbstractPointer ptr = J9BuildFlags.gc_compressedPointers ? U32Pointer.cast(valuePtr) : UDATAPointer.cast(valuePtr);
out.print(String.format("!fj9object 0x%x", ptr.at(0).longValue()));
} else {
out.print(I32Pointer.cast(valuePtr).at(0).getHexValue());
}
out.print(String.format(" (offset=%d) (%s)", fieldOffset.longValue(), className));
if (isHiddenField) {
out.print(" <hidden>");
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer in project openj9 by eclipse.
the class J9ObjectFieldOffsetIterator_V1 method fieldOffsetsFindNext.
// Based on fieldOffsetsFindNext from resolvefield.c
private void fieldOffsetsFindNext() throws CorruptDataException {
while (romFieldsShapeIterator.hasNext()) {
J9ROMFieldShapePointer localField = (J9ROMFieldShapePointer) romFieldsShapeIterator.next();
U32 modifiers = localField.modifiers();
/* count the index for jvmti */
index = index.add(1);
if (modifiers.anyBitsIn(J9AccStatic)) {
if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC)) {
/* found a static, the walk wants statics */
if (modifiers.anyBitsIn(J9FieldFlagObject)) {
offset = new UDATA(objectStaticsSeen.mult(UDATA.SIZEOF));
objectStaticsSeen = objectStaticsSeen.add(1);
field = localField;
break;
} else if (!(walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS))) {
if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
/* Add single scalar and object counts together, round up to 2 and divide by 2 to get number of doubles used by singles */
UDATA doubleSlots;
if (J9BuildFlags.env_data64) {
doubleSlots = new UDATA(romClass.objectStaticCount().add(romClass.singleScalarStaticCount()));
} else {
doubleSlots = new UDATA(romClass.objectStaticCount().add(romClass.singleScalarStaticCount()).add(1)).rightShift(1);
}
offset = doubleSlots.mult(U64.SIZEOF).add(doubleStaticsSeen.mult(U64.SIZEOF));
doubleStaticsSeen = doubleStaticsSeen.add(1);
} else {
offset = new UDATA(romClass.objectStaticCount().mult(UDATA.SIZEOF).add(singleStaticsSeen.mult(UDATA.SIZEOF)));
singleStaticsSeen = singleStaticsSeen.add(1);
}
field = localField;
break;
}
}
} else {
if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE)) {
if (modifiers.anyBitsIn(J9FieldFlagObject)) {
if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD)) {
// Assert_VM_true(state->backfillOffsetToUse >= 0);
offset = new UDATA(backfillOffsetToUse);
walkFlags = walkFlags.bitAnd(new U32(new UDATA(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD).bitNot()));
} else {
offset = firstObjectOffset.add(objectsSeen.mult(fj9object_t_SizeOf));
objectsSeen = objectsSeen.add(1);
}
field = localField;
break;
} else if (!walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS)) {
if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
offset = firstDoubleOffset.add(doubleSeen.mult(U64.SIZEOF));
doubleSeen = doubleSeen.add(1);
} else {
if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD)) {
// Assert_VM_true(state->backfillOffsetToUse >= 0);
offset = new UDATA(backfillOffsetToUse);
walkFlags = walkFlags.bitAnd(new U32(new UDATA(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD).bitNot()));
} else {
offset = firstSingleOffset.add(singlesSeen.mult(U32.SIZEOF));
singlesSeen = singlesSeen.add(1);
}
}
field = localField;
break;
}
}
}
}
// At this point all the info we need is stashed away in private state variables
return;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer 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.pointer.generated.J9ROMFieldShapePointer in project openj9 by eclipse.
the class RomClassWalker method allSlotsInROMFieldDo.
private int allSlotsInROMFieldDo(J9ROMFieldShapePointer field) throws CorruptDataException {
int fieldLength = 0;
U32Pointer initialValue;
U32 modifiers;
J9ROMNameAndSignaturePointer fieldNAS = field.nameAndSignature();
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, fieldNAS.nameEA(), "name");
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, fieldNAS.signatureEA(), "signature");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, field.modifiersEA(), "modifiers");
modifiers = field.modifiers();
initialValue = U32Pointer.cast(field.add(1));
if (modifiers.anyBitsIn(J9FieldFlagConstant)) {
if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(initialValue), "fieldInitialValue");
initialValue = initialValue.add(2);
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_I32, initialValue, "fieldInitialValue");
initialValue = initialValue.add(1);
}
}
if (modifiers.anyBitsIn(J9FieldFlagHasGenericSignature)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, initialValue, "fieldGenSigUTF8");
initialValue = initialValue.add(1);
}
if (modifiers.allBitsIn(J9FieldFlagHasFieldAnnotations)) {
initialValue = initialValue.add(allSlotsInAnnotationDo(initialValue, "fieldAnnotation"));
}
fieldLength = (int) (initialValue.getAddress() - field.getAddress());
classWalkerCallback.addSection(clazz, field, fieldLength, "field", true);
return fieldLength;
}
Aggregations