use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class CheckClassHeap method check.
@Override
public void check() {
try {
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(_javaVM.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
_engine.clearPreviousObjects();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
if (_engine.checkClassHeap(clazz, segment) != CheckBase.J9MODRON_SLOT_ITERATOR_OK) {
return;
}
_engine.pushPreviousClass(clazz);
}
}
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class CheckEngine method checkJ9Class.
private int checkJ9Class(J9ClassPointer clazz, J9MemorySegmentPointer segment, int checkFlags) throws CorruptDataException {
if (clazz.isNull()) {
return J9MODRON_GCCHK_RC_OK;
}
if (clazz.anyBitsIn(J9MODRON_GCCHK_J9CLASS_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_CLASS_POINTER_UNALIGNED;
}
/* Check that the class header containes the expected values */
int ret = checkJ9ClassHeader(clazz);
if (J9MODRON_GCCHK_RC_OK != ret) {
return ret;
}
/* Check that class is not unloaded */
ret = checkJ9ClassIsNotUnloaded(clazz);
if (J9MODRON_GCCHK_RC_OK != ret) {
return ret;
}
if ((checkFlags & J9MODRON_GCCHK_VERIFY_RANGE) != J9MODRON_GCCHK_VERIFY_RANGE) {
UDATA delta = UDATA.cast(segment.heapAlloc()).sub(UDATA.cast(clazz));
/* Basic check that there is enough room for the object header */
if (delta.lt(J9Class.SIZEOF)) {
return J9MODRON_GCCHK_RC_CLASS_INVALID_RANGE;
}
}
return J9MODRON_GCCHK_RC_OK;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer 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.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class RootScanner method scanClasses.
protected void scanClasses() throws CorruptDataException {
J9ClassLoaderPointer sysClassLoader = _vm.systemClassLoader();
J9ClassLoaderPointer appClassLoader = J9ClassLoaderPointer.cast(_vm.applicationClassLoader());
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(_vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
Reachability reachability;
if (J9BuildFlags.gc_dynamicClassUnloading) {
long dynamicClassUnloadingFlag = _extensions.dynamicClassUnloading();
if (MM_GCExtensions$DynamicClassUnloading.DYNAMIC_CLASS_UNLOADING_NEVER == dynamicClassUnloadingFlag) {
reachability = Reachability.STRONG;
} else {
if (clazz.classLoader().eq(sysClassLoader) || clazz.classLoader().eq(appClassLoader)) {
reachability = Reachability.STRONG;
} else {
reachability = Reachability.WEAK;
}
}
} else {
reachability = Reachability.STRONG;
}
setReachability(reachability);
doClass(clazz);
}
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class GCSegmentIterator method next.
public J9MemorySegmentPointer next() {
try {
if (hasNext()) {
J9MemorySegmentPointer currentMemorySegment = memorySegment;
memorySegment = memorySegment.nextSegment();
return currentMemorySegment;
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
} catch (CorruptDataException cde) {
// can try to recover from this
raiseCorruptDataEvent("Error getting next item", cde, false);
return null;
}
}
Aggregations