use of com.ibm.j9ddr.vm29.j9.gc.GCClassIterator in project openj9 by eclipse.
the class CheckEngine method checkClassHeap.
public int checkClassHeap(J9ClassPointer clazz, J9MemorySegmentPointer segment) {
int result;
/*
* Verify that this is, in fact, a class
*/
try {
result = checkJ9Class(clazz, segment, _cycle.getCheckFlags());
if (J9MODRON_GCCHK_RC_OK != result) {
CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
_reporter.report(error);
}
/*
* Process object slots in the class
*/
GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
while (classIterator.hasNext()) {
PointerPointer slotPtr = PointerPointer.cast(classIterator.nextAddress());
J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
result = checkObjectIndirect(object);
if (J9MODRON_GCCHK_RC_OK != result) {
String elementName = "";
switch(classIterator.getState()) {
case GCClassIterator.state_statics:
elementName = "static ";
break;
case GCClassIterator.state_constant_pool:
elementName = "constant ";
break;
case GCClassIterator.state_slots:
elementName = "slots ";
break;
}
CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_OK;
}
if (GCExtensions.isStandardGC()) {
/* If the slot has its old bit OFF, the class's remembered bit should be ON */
if (object.notNull() && !ObjectModel.isOld(object)) {
if (!ObjectModel.isRemembered(clazz.classObject())) {
CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REMEMBERED_SET_OLD_OBJECT, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_OK;
}
}
}
}
if (J9MODRON_GCCHK_RC_OK != checkClassStatics(clazz)) {
return J9MODRON_SLOT_ITERATOR_OK;
}
J9ClassPointer replaced = clazz.replacedClass();
if (replaced.notNull()) {
if (!J9ClassHelper.isSwappedOut(replaced)) {
CheckError error = new CheckError(clazz, clazz.replacedClassEA(), _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REPLACED_CLASS_HAS_NO_HOTSWAP_FLAG, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_OK;
}
}
/*
* Process class slots in the class
*/
GCClassIteratorClassSlots classIteratorClassSlots = GCClassIteratorClassSlots.fromJ9Class(clazz);
while (classIteratorClassSlots.hasNext()) {
PointerPointer classSlotPtr = PointerPointer.cast(classIteratorClassSlots.nextAddress());
J9ClassPointer classSlot = J9ClassPointer.cast(classSlotPtr.at(0));
String elementName = "";
result = J9MODRON_GCCHK_RC_OK;
switch(classIteratorClassSlots.getState()) {
case GCClassIteratorClassSlots.state_constant_pool:
/* may be NULL */
if (classSlot.notNull()) {
result = checkJ9ClassPointer(classSlot);
}
elementName = "constant ";
break;
case GCClassIteratorClassSlots.state_superclasses:
/* must not be NULL */
result = checkJ9ClassPointer(classSlot);
elementName = "superclass ";
break;
case GCClassIteratorClassSlots.state_interfaces:
/* must not be NULL */
result = checkJ9ClassPointer(classSlot);
elementName = "interface ";
break;
case GCClassIteratorClassSlots.state_array_class_slots:
/* may be NULL */
if (classSlot.notNull()) {
result = checkJ9ClassPointer(classSlot);
}
elementName = "array class ";
}
if (J9MODRON_GCCHK_RC_OK != result) {
CheckError error = new CheckError(clazz, classSlotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_OK;
}
}
} catch (CorruptDataException e) {
// TODO : cde should be part of the error
CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
_reporter.report(error);
}
return J9MODRON_SLOT_ITERATOR_OK;
}
use of com.ibm.j9ddr.vm29.j9.gc.GCClassIterator in project openj9 by eclipse.
the class LiveSetWalker method scanObject.
private static void scanObject(HashSet<J9ObjectPointer> visitedObjects, ObjectVisitor visitor, J9ObjectPointer object, VoidPointer address) {
if (visitedObjects.contains(object)) {
return;
}
if (!visitor.visit(object, address)) {
return;
}
visitedObjects.add(object);
try {
GCObjectIterator objectIterator = GCObjectIterator.fromJ9Object(object, true);
GCObjectIterator addressIterator = GCObjectIterator.fromJ9Object(object, true);
while (objectIterator.hasNext()) {
J9ObjectPointer slot = objectIterator.next();
VoidPointer addr = addressIterator.nextAddress();
if (slot.notNull()) {
scanObject(visitedObjects, visitor, slot, addr);
}
}
if (J9ObjectHelper.getClassName(object).equals("java/lang/Class")) {
J9ClassPointer clazz = ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object);
// Iterate the Object slots
GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
GCClassIterator classAddressIterator = GCClassIterator.fromJ9Class(clazz);
while (classIterator.hasNext()) {
J9ObjectPointer slot = classIterator.next();
VoidPointer addr = classAddressIterator.nextAddress();
if (slot.notNull()) {
scanObject(visitedObjects, visitor, slot, addr);
}
}
// Iterate the Class slots
GCClassIteratorClassSlots classSlotIterator = GCClassIteratorClassSlots.fromJ9Class(clazz);
GCClassIteratorClassSlots classSlotAddressIterator = GCClassIteratorClassSlots.fromJ9Class(clazz);
while (classSlotIterator.hasNext()) {
J9ClassPointer slot = classSlotIterator.next();
VoidPointer addr = classSlotAddressIterator.nextAddress();
J9ObjectPointer classObject = ConstantPoolHelpers.J9VM_J9CLASS_TO_HEAPCLASS(slot);
if (classObject.notNull()) {
scanObject(visitedObjects, visitor, classObject, addr);
}
}
}
} catch (CorruptDataException e) {
EventManager.raiseCorruptDataEvent("Corruption found while walking the live set, object: " + object.getHexAddress(), e, false);
}
visitor.finishVisit(object, address);
}
Aggregations