use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9Class.
private boolean verifyJ9Class(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
boolean passed = verifyJ9ClassHeader(javaVM, out, classPointer);
if (!classPointer.classLoader().isNull()) {
J9MemorySegmentPointer segment = classPointer.classLoader().classSegments();
segment = findSegmentInClassLoaderForAddress(classPointer, segment);
if (segment.isNull()) {
reportError(out, "class=0x%s not found in classLoader=0x%s", Long.toHexString(classPointer.getAddress()), Long.toHexString(classPointer.classLoader().getAddress()));
passed = false;
}
}
if (!verifyJ9ClassSubclassHierarchy(javaVM, out, classPointer)) {
passed = false;
}
return passed;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9ROMClassSanity.
/*
* Based on vmchk/checkromclasses.c r1.5
*
* J9ROMClass sanity:
* SRP check:
* Ensure J9ROMClass->interfaces SRP is in the same segment if J9ROMClass->interfaceCount != 0.
* Ensure J9ROMClass->romMethods SRP is in the same segment if J9ROMClass->romMethodCount != 0.
* Ensure J9ROMClass->romFields SRP is in the same segment if J9ROMClass->romFieldCount != 0.
* Ensure J9ROMClass->innerClasses SRP is in the same segment if J9ROMClass->innerClasseCount != 0.
* Ensure cpShapeDescription in the same segment.
* Ensure all SRPs are in range on 64 bit platforms (including className, superclassName, and outerClassName).
*
* ConstantPool count check:
* Ensure ramConstantPoolCount <= romConstantPoolCount
*/
private void checkJ9ROMClassSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking ROM classes");
// Stolen from RootScaner.scanClasses()
// GCClassLoaderIterator gcClassLoaderIterator =
// GCClassLoaderIterator.from();
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
int count = 0;
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
verifyJ9ROMClass(out, vm, clazz);
count++;
}
}
reportMessage(out, "Checking %d ROM classes done", count);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyAddressInSegment.
private void verifyAddressInSegment(PrintStream out, J9JavaVMPointer vm, J9MemorySegmentPointer segment, long address, String description) throws CorruptDataException {
U8Pointer heapBase = segment.heapBase();
U8Pointer heapAlloc = segment.heapAlloc();
if (address < heapBase.getAddress() || (address >= heapAlloc.getAddress())) {
reportError(out, "address 0x%s (%s) not in segment [heapBase=0x%s, heapAlloc=0x%s]", address, description, Long.toHexString(heapBase.getAddress()), Long.toHexString(heapAlloc.getAddress()));
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class SegmentsUtil method addSegmentsToArrayList.
private static void addSegmentsToArrayList(J9MemorySegmentListPointer segmentListPointer, ArrayList<J9MemorySegmentPointer> segmentArray, int segmentType) throws CorruptDataException {
MemorySegmentIterator segmentIterator = new MemorySegmentIterator(segmentListPointer, segmentType, false);
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer seg = (J9MemorySegmentPointer) segmentIterator.next();
segmentArray.add(seg);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class CheckEngine method checkJ9ClassPointer.
public int checkJ9ClassPointer(J9ClassPointer clazz, boolean allowUndead) throws CorruptDataException {
// Java-ism. Need to check this first before doing compares etc.
if (clazz == null || clazz.isNull()) {
return J9MODRON_GCCHK_RC_NULL_CLASS_POINTER;
}
// Short circuit if we've recently checked this class.
int cacheIndex = (int) (clazz.longValue() % CLASS_CACHE_SIZE);
if (allowUndead && clazz.eq(_checkedClassCacheAllowUndead[cacheIndex])) {
return J9MODRON_GCCHK_RC_OK;
} else if (clazz.eq(_checkedClassCache[cacheIndex])) {
return J9MODRON_GCCHK_RC_OK;
}
if (UDATA.cast(clazz).anyBitsIn(J9MODRON_GCCHK_J9CLASS_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_CLASS_POINTER_UNALIGNED;
}
J9MemorySegmentPointer segment = findSegmentForClass(clazz);
if (segment == null) {
return J9MODRON_GCCHK_RC_CLASS_NOT_FOUND;
}
if (!allowUndead) {
if ((segment.type().longValue() & MEMORY_TYPE_UNDEAD_CLASS) != 0) {
return J9MODRON_GCCHK_RC_CLASS_IS_UNDEAD;
}
}
/* Check to ensure J9Class header has the correct eyecatcher. */
int result = checkJ9ClassHeader(clazz);
if (J9MODRON_GCCHK_RC_OK != result) {
return result;
}
/* Check to ensure J9Class is not unloaded */
result = checkJ9ClassIsNotUnloaded(clazz);
if (J9MODRON_GCCHK_RC_OK != result) {
return result;
}
if ((_cycle.getCheckFlags() & J9MODRON_GCCHK_VERIFY_RANGE) != 0) {
IDATA delta = segment.heapAlloc().sub(U8Pointer.cast(clazz));
/* Basic check that there is enough room for the class header */
if (delta.lt(J9Class.SIZEOF)) {
return J9MODRON_GCCHK_RC_CLASS_INVALID_RANGE;
}
}
/* class checked out. Record it in the cache so we don't need to check it again. */
if (allowUndead) {
_checkedClassCacheAllowUndead[cacheIndex] = clazz;
} else {
_checkedClassCache[cacheIndex] = clazz;
}
return J9MODRON_GCCHK_RC_OK;
}
Aggregations