use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class CheckEngine method checkJ9ObjectPointer.
private int checkJ9ObjectPointer(J9ObjectPointer object, J9ObjectPointer[] newObject, GCHeapRegionDescriptor[] regionDesc) throws CorruptDataException {
newObject[0] = object;
if (object.isNull()) {
return J9MODRON_GCCHK_RC_OK;
}
regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
if (regionDesc[0] == null) {
/* Is the object on the stack? */
GCVMThreadListIterator threadListIterator = GCVMThreadListIterator.from();
while (threadListIterator.hasNext()) {
J9VMThreadPointer vmThread = threadListIterator.next();
if (isObjectOnStack(object, vmThread.stackObject())) {
return J9MODRON_GCCHK_RC_STACK_OBJECT;
}
}
UDATA classSlot = UDATA.cast(object.clazz());
if (classSlot.eq(J9MODRON_GCCHK_J9CLASS_EYECATCHER)) {
return J9MODRON_GCCHK_RC_OBJECT_SLOT_POINTS_TO_J9CLASS;
}
return J9MODRON_GCCHK_RC_NOT_FOUND;
}
// if (0 == regionDesc->objectAlignment) {
if (!regionDesc[0].containsObjects()) {
/* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
}
/* Now we know object is not on stack we can check that it's correctly aligned
* for a J9Object.
*/
if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_UNALIGNED;
}
if (isMidscavengeFlagSet()) {
if (GCExtensions.isVLHGC() || (regionDesc[0].getTypeFlags().allBitsIn(MEMORY_TYPE_NEW))) {
// TODO: ideally, we should only check this in the evacuate segment
// TODO: do some safety checks first -- is there enough room in the segment?
GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
if (scavengerForwardedHeader.isForwardedPointer()) {
newObject[0] = scavengerForwardedHeader.getForwardedObject();
reportForwardedObject(object, newObject[0]);
// Replace the object and resume
object = newObject[0];
regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
if (regionDesc[0] == null) {
/* Is the object on the stack? */
GCVMThreadListIterator threadListIterator = GCVMThreadListIterator.from();
while (threadListIterator.hasNext()) {
J9VMThreadPointer vmThread = threadListIterator.next();
if (isObjectOnStack(object, vmThread.stackObject())) {
return J9MODRON_GCCHK_RC_STACK_OBJECT;
}
}
return J9MODRON_GCCHK_RC_NOT_FOUND;
}
// if (0 == regionDesc->objectAlignment) {
if (!regionDesc[0].containsObjects()) {
/* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
}
/* make sure the forwarded pointer is also aligned */
if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_UNALIGNED;
}
}
}
}
if (isScavengerBackoutFlagSet()) {
GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
if (scavengerForwardedHeader.isReverseForwardedPointer()) {
newObject[0] = scavengerForwardedHeader.getReverseForwardedPointer();
reportForwardedObject(object, newObject[0]);
// Replace the object and resume
object = newObject[0];
regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
if (regionDesc[0] == null) {
return J9MODRON_GCCHK_RC_NOT_FOUND;
}
if (!regionDesc[0].containsObjects()) {
/* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
}
if (!regionDesc[0].getTypeFlags().allBitsIn(MEMORY_TYPE_NEW)) {
/* reversed forwarded should point to Evacuate */
return J9MODRON_GCCHK_RC_REVERSED_FORWARDED_OUTSIDE_EVACUATE;
}
/* make sure the forwarded pointer is also aligned */
if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_UNALIGNED;
}
}
}
/* Check that elements of a double array are aligned on an 8-byte boundary. For continuous
* arrays, verifying that the J9Indexable object is aligned on an 8-byte boundary is sufficient.
* For arraylets, depending on the layout, elements of the array may be stored on arraylet leafs
* or on the spine. Arraylet leafs should always be aligned on 8-byte boundaries. Checking both
* the first and last element will ensure that we are always checking that elements are aligned
* on the spine.
* */
long classShape = -1;
try {
classShape = ObjectModel.getClassShape(J9ObjectHelper.clazz(object)).longValue();
} catch (CorruptDataException cde) {
/* don't bother to report an error yet -- a later step will catch this. */
}
if (classShape == OBJECT_HEADER_SHAPE_DOUBLES) {
J9IndexableObjectPointer array = J9IndexableObjectPointer.cast(object);
int size = 0;
VoidPointer elementPtr = VoidPointer.NULL;
try {
size = ObjectModel.getSizeInElements(object).intValue();
} catch (InvalidDataTypeException ex) {
// size in elements can not be larger then 2G but it is...
// We could report an error at this point, but the C version
// doesn't -- we'll catch it later
} catch (IllegalArgumentException ex) {
// We could report an error at this point, but the C version
// doesn't -- we'll catch it later
}
if (0 != size) {
elementPtr = ObjectModel.getElementAddress(array, 0, U64.SIZEOF);
if (elementPtr.anyBitsIn(U64.SIZEOF - 1)) {
return J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED;
}
elementPtr = ObjectModel.getElementAddress(array, size - 1, U64.SIZEOF);
if (elementPtr.anyBitsIn(U64.SIZEOF - 1)) {
return J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED;
}
}
}
return J9MODRON_GCCHK_RC_OK;
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class J9ObjectFieldFormatter method postFormat.
@Override
public FormatWalkResult postFormat(String name, String type, String declaredType, int typeCode, long address, PrintStream out, Context context, IStructureFormatter structureFormatter) throws CorruptDataException {
if (typeCode == TYPE_STRUCTURE_POINTER && StructureCommandUtil.typeToCommand(type).equals("!j9object")) {
PointerPointer slotPtr = PointerPointer.cast(address);
J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
if (object.isNull()) {
return FormatWalkResult.KEEP_WALKING;
}
J9ClassPointer clazz = J9ObjectHelper.clazz(object);
out.print(" // ");
if (J9ClassHelper.isArrayClass(clazz)) {
out.print(J9ClassHelper.getArrayName(clazz));
} else {
out.print(J9ClassHelper.getName(clazz));
}
}
return FormatWalkResult.KEEP_WALKING;
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class J9ObjectStructureFormatter method printSubArrayType.
void printSubArrayType(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, int begin, int end, J9IndexableObjectPointer array) throws CorruptDataException {
U32 arraySize = J9IndexableObjectHelper.size(array);
if (arraySize.anyBitsIn(0x80000000)) {
arraySize = new U32(Integer.MAX_VALUE);
}
int finish = Math.min(arraySize.intValue(), end);
if (begin < finish) {
String className = J9IndexableObjectHelper.getClassName(array);
char signature = className.charAt(1);
switch(signature) {
case 'B':
case 'Z':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 1);
out.println(String.format("[%d] = %3d, 0x%02x", index, U8Pointer.cast(slot).at(0).longValue(), U8Pointer.cast(slot).at(0).longValue()));
}
break;
case 'C':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
long value = U16Pointer.cast(slot).at(0).longValue();
out.println(String.format("[%d] = %5d, 0x%2$04x, '%c'", index, value, (char) value));
}
break;
case 'S':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
out.println(String.format("[%d] = %6d, 0x%04x", index, I16Pointer.cast(slot).at(0).longValue(), U16Pointer.cast(slot).at(0).longValue()));
}
break;
case 'I':
case 'F':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 4);
out.println(String.format("[%d] = %10d, 0x%08x, %8.8fF", index, I32Pointer.cast(slot).at(0).longValue(), U32Pointer.cast(slot).at(0).longValue(), FloatPointer.cast(slot).floatAt(0)));
}
break;
case 'J':
case 'D':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 8);
out.println(String.format("[%d] = %2d, 0x%016x, %8.8fF", index, I64Pointer.cast(slot).at(0).longValue(), I64Pointer.cast(slot).at(0).longValue(), DoublePointer.cast(slot).doubleAt(0)));
}
break;
case 'L':
case '[':
for (int index = begin; index < finish; index++) {
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, (int) ObjectReferencePointer.SIZEOF);
if (slot.notNull()) {
long compressedPtrValue;
if (J9BuildFlags.gc_compressedPointers) {
compressedPtrValue = I32Pointer.cast(slot).at(0).longValue();
} else {
compressedPtrValue = DataType.getProcess().getPointerAt(slot.getAddress());
}
padding(out, tabLevel);
out.println(String.format("[%d] = !fj9object 0x%x = !j9object 0x%x", index, compressedPtrValue, ObjectReferencePointer.cast(slot).at(0).longValue()));
} else {
padding(out, tabLevel);
out.println(String.format("[%d] = null", slot));
}
}
break;
}
}
/* check if it just printed a range; if so, give cmd to see all data */
arraySize = J9IndexableObjectHelper.size(array);
if (begin > 0 || arraySize.longValue() > finish) {
out.println(String.format("To print entire range: !j9indexableobject %s %d %d\n", array.getHexAddress(), 0, arraySize.longValue()));
}
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class CompressedRefMappingCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length == 0) {
printHelp(out);
return;
}
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
if (command.startsWith("!fj9object")) {
J9ObjectPointer mappedValue;
if (J9BuildFlags.gc_compressedPointers) {
mappedValue = ObjectAccessBarrier.convertPointerFromToken(ptr.getAddress());
} else {
mappedValue = J9ObjectPointer.cast(ptr);
}
if (command.startsWith("!fj9objecttoj9object")) {
out.println(String.format("!fj9object %s -> !j9object %s", ptr.getHexAddress(), mappedValue.getHexAddress()));
} else {
context.execute("!j9object", new String[] { mappedValue.getHexAddress() }, out);
}
} else {
long tokenValue;
if (J9BuildFlags.gc_compressedPointers) {
tokenValue = ObjectAccessBarrier.convertTokenFromPointer(J9ObjectPointer.cast(ptr));
} else {
tokenValue = ptr.getAddress();
}
out.println(String.format("!j9object %s -> !fj9object 0x%s\n", ptr.getHexAddress(), Long.toHexString(tokenValue)));
}
}
use of com.ibm.j9ddr.vm29.structure.J9Object in project openj9 by eclipse.
the class ObjectRefsCommand method dumpHeapReferences.
/**
* Write the on heap references stanza to the output stream.
* @param vm
* @param targetObject
* @param out
* @throws CorruptDataException
*/
private void dumpHeapReferences(J9JavaVMPointer vm, J9ObjectPointer targetObject, PrintStream out) throws CorruptDataException {
if (GCExtensions.isVLHGC()) {
Table table = new Table("On Heap References");
table.row("object (!j9object)", "field (!j9object)", "!mm_heapregiondescriptorvlhgc", "AC (type)");
/* iterate over all heap regions */
GCHeapRegionIterator regionIterator = GCHeapRegionIterator.from();
while (regionIterator.hasNext()) {
GCHeapRegionDescriptor region = regionIterator.next();
if (region.containsObjects()) {
MM_HeapRegionDescriptorVLHGCPointer vlhgcRegion = MM_HeapRegionDescriptorVLHGCPointer.cast(region.getHeapRegionDescriptorPointer());
MM_AllocationContextTarokPointer currentAllocationContextTarok = vlhgcRegion._allocateData()._owningContext();
/* iterate over all objects in region */
GCObjectHeapIterator heapObjectIterator = region.objectIterator(true, false);
while (heapObjectIterator.hasNext()) {
J9ObjectPointer currentObject = heapObjectIterator.next();
/* Iterate over the object's fields and list any that point at @ref targetObject */
GCObjectIterator fieldIterator = GCObjectIterator.fromJ9Object(currentObject, false);
while (fieldIterator.hasNext()) {
J9ObjectPointer currentTargetObject = fieldIterator.next();
if (currentTargetObject.eq(targetObject)) {
/* found a reference to our targetObject, add it to the table */
J9ClassPointer objectClass = J9ObjectHelper.clazz(currentObject);
String objectClassString = J9ClassHelper.getJavaName(objectClass);
table.row(currentObject.getHexAddress() + " //" + objectClassString, currentTargetObject.getHexAddress(), vlhgcRegion.getHexAddress(), currentAllocationContextTarok.getHexAddress() + " (" + currentAllocationContextTarok._allocationContextType() + ")");
}
}
}
}
}
table.render(out);
}
}
Aggregations