use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class SegmentsUtil method dbgDumpSegmentList.
public static void dbgDumpSegmentList(PrintStream out, J9MemorySegmentListPointer segmentListPointer) throws CorruptDataException {
String fmt = null;
if (J9BuildFlags.env_data64) {
out.append("+----------------+----------------+----------------+----------------+--------+--------+\n");
out.append("| segment | start | alloc | end | type | size |\n");
out.append("+----------------+----------------+----------------+----------------+--------+--------+\n");
fmt = " %016x %016x %016x %016x %08x %8x";
} else {
out.append("+--------+--------+--------+--------+--------+--------+\n");
out.append("|segment | start | alloc | end | type | size |\n");
out.append("+--------+--------+--------+--------+--------+--------+\n");
fmt = " %08x %08x %08x %08x %08x %8x";
}
MemorySegmentIterator segmentIterator = new MemorySegmentIterator(segmentListPointer, MemorySegmentIterator.MEMORY_ALL_TYPES, false);
long totalMemory = 0L, totalMemoryInUse = 0L;
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer seg = (J9MemorySegmentPointer) segmentIterator.next();
totalMemory += seg.size().longValue();
totalMemoryInUse += seg.heapAlloc().sub(seg.heapBase()).longValue();
String msg = String.format(fmt, seg.getAddress(), seg.heapBase().getAddress(), seg.heapAlloc().getAddress(), seg.heapTop().getAddress(), seg.type().longValue(), seg.size().longValue());
out.append(msg);
out.append(nl);
seg = segmentListPointer.nextSegment();
}
if (J9BuildFlags.env_data64) {
out.append("+----------------+----------------+----------------+----------------+--------+--------+\n");
} else {
out.append("+--------+--------+--------+--------+--------+--------+\n");
}
printMemoryUsed(out, totalMemory, totalMemoryInUse);
out.append(nl);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method findSegmentInClassLoaderForAddress.
/**
* Based on vmchk/checkclasses.c function: findSegmentInClassLoaderForAddress
*
* This method searches classloader's segments to find out on which segment this ROMClass lays in.
* @param classLoader Classloader that romclass is being searched
* @param romClassPointer ROMClass that is searched in classloader segments
* @return Classloader segment which has this romclass, otherwise null.
* @throws CorruptDataException
*/
public J9MemorySegmentPointer findSegmentInClassLoaderForAddress(J9ClassLoaderPointer classLoader, J9ROMClassPointer romClassPointer) throws CorruptDataException {
MemorySegmentIterator memorySegmentIterator = new MemorySegmentIterator(classLoader.classSegments(), MemorySegmentIterator.MEMORY_ALL_TYPES, true);
J9MemorySegmentPointer memorySegmentPointer = J9MemorySegmentPointer.NULL;
J9MemorySegmentPointer foundMemorySegmentPointer = J9MemorySegmentPointer.NULL;
while (memorySegmentIterator.hasNext()) {
Object next2 = memorySegmentIterator.next();
memorySegmentPointer = (J9MemorySegmentPointer) next2;
if (romClassPointer.getAddress() >= memorySegmentPointer.heapBase().longValue() && romClassPointer.getAddress() < memorySegmentPointer.heapAlloc().longValue()) {
foundMemorySegmentPointer = memorySegmentPointer;
break;
}
}
return foundMemorySegmentPointer;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9ClassSanity.
/*
* Based on vmchk/checkclasses.c r1.7
*
* J9Class sanity:
* Eyecatcher check:
* Ensure J9Class->eyecatcher == 0x99669966.
*
* Superclasses check:
* Ensure J9Class->superclasses != null unless J9Class is Object.
*
* ClassObject null check:
* Ensure J9Class->classObject != null if (J9Class->initializeStatus == J9ClassInitSucceeded)
*
* ClassLoader segment check:
* Ensure J9Class->classLoader->classSegments contains J9Class.
*
* ConstantPool check:
* Ensure J9Class->ramConstantPool->ramClass is equal to the J9Class.
*
* Subclass hierarchy check:
* Ensure subclasses can be traversed per the J9Class classDepth.
*
* Obsolete class check:
* Ensure obsolete classes are found in the replacedClass linked list on the currentClass.
*/
private void checkJ9ClassSanity(J9JavaVMPointer javaVM, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking classes");
// Stolen from RootScaner.scanClasses()
// GCClassLoaderIterator gcClassLoaderIterator =
// GCClassLoaderIterator.from();
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(javaVM.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
int count = 0;
int obsoleteCount = 0;
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
if (!J9ClassHelper.isObsolete(clazz)) {
verifyJ9Class(javaVM, out, clazz);
} else {
verifyObsoleteJ9Class(javaVM, out, clazz);
obsoleteCount++;
}
count++;
}
}
reportMessage(out, "Checking %d classes (%d obsolete) done", count, obsoleteCount);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9ROMClass.
private void verifyJ9ROMClass(PrintStream out, J9JavaVMPointer vm, J9ClassPointer clazz) throws CorruptDataException {
J9ROMClassPointer romClass = clazz.romClass();
J9ClassLoaderPointer classLoader = clazz.classLoader();
J9MemorySegmentPointer segment = findSegmentInClassLoaderForAddress(classLoader, romClass);
if (!segment.isNull()) {
long address;
if (romClass.interfaceCount().longValue() != 0) {
address = romClass.interfaces().getAddress();
verifyAddressInSegment(out, vm, segment, address, "romClass->interfaces");
}
if (romClass.romMethodCount().longValue() != 0) {
address = romClass.romMethods().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->romMethods");
}
if (romClass.romFieldCount().longValue() != 0) {
address = romClass.romFields().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->romFields");
}
if (romClass.innerClassCount().longValue() != 0) {
address = romClass.innerClasses().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->innerClasses");
}
U32Pointer cpShapeDescription = romClass.cpShapeDescription();
/* TODO: is !isNull() check required or not? */
if (!cpShapeDescription.isNull()) {
address = cpShapeDescription.getAddress();
verifyAddressInSegment(out, vm, segment, address, "romClass->cpShapeDescription");
}
}
{
J9UTF8Pointer className = romClass.className();
J9UTF8Pointer superclassName = romClass.superclassName();
J9UTF8Pointer outerClassName = romClass.outerClassName();
if (className.isNull() || !verifyUTF8(className)) {
reportError(out, "invalid className=0x%s utf8 for romClass=0x%s", Long.toHexString(className.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!superclassName.isNull() && !verifyUTF8(superclassName)) {
reportError(out, "invalid superclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(superclassName.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!outerClassName.isNull() && !verifyUTF8(outerClassName)) {
reportError(out, "invalid outerclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(outerClassName.getAddress()), Long.toHexString(romClass.getAddress()));
}
}
U32 ramConstantPoolCount = romClass.ramConstantPoolCount();
U32 romConstantPoolCount = romClass.romConstantPoolCount();
if (ramConstantPoolCount.gt(romConstantPoolCount)) {
reportError(out, "ramConstantPoolCount=%d > romConstantPoolCount=%d for romClass=0x%s", ramConstantPoolCount.longValue(), romConstantPoolCount.longValue(), Long.toHexString(romClass.getAddress()));
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9MethodSanity.
/*
* Based on vmchk/checkmethods.c r1.5
*
* J9Method sanity:
* Bytecode check:
* Ensure (bytecodes - sizeof(J9ROMMethod) is in the right "area" to be a ROM Method.
* Use ROMClass to determine where ROM methods for that class begin.
* Constant pool check:
* Ensure method's constant pool is the same as that of its J9Class.
* Useful to validate that HCR doesn't violate this invariant.
* VTable check:
* If method of a non-interface class has modifier J9AccMethodVTable,
* ensure it exists in the VTable of its J9Class.
* Useful to validate that HCR doesn't violate this invariant.
*/
private void checkJ9MethodSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking methods");
// 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();
if (!J9ClassHelper.isObsolete(clazz)) {
count += verifyClassMethods(vm, out, clazz);
}
}
}
reportMessage(out, "Checking %d methods done", count);
}
Aggregations