use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.
the class J9ClassHelper method size.
public static UDATA size(J9ClassPointer clazz, J9JavaVMPointer vm) throws CorruptDataException {
/*
* Size includes up to 7 fragments:
* 0. RAM class header = J9Class struct + vTable + JIT vTable
* 1. RAM methods + extended method block
* 2. Superclasses
* 3. Instance description
* 4. iTable
* 5. Static slots
* 6. Constant pool
*
* Array classes omit 1, 3, 5 and 6.
*/
// Fragment 0. RAM class header = J9Class struct + vTable + JIT vTable
UDATA size = new UDATA(J9Class.SIZEOF);
UDATA vTableSlotCount = vTable(clazz).at(0);
size = size.add(Scalar.convertSlotsToBytes(vTableSlotCount));
if (vm.jitConfig().notNull()) {
UDATA jitVTableSlotCount = vTableSlotCount.sub(1);
size = size.add(Scalar.convertSlotsToBytes(jitVTableSlotCount));
}
if (!J9ROMClassHelper.isArray(clazz.romClass())) {
// Fragment 1. RAM methods + extended method block
U32 ramMethodsSize = clazz.romClass().romMethodCount().mult((int) J9Method.SIZEOF);
size = size.add(ramMethodsSize);
if (vm.runtimeFlags().allBitsIn(J9Consts.J9_RUNTIME_EXTENDED_METHOD_BLOCK)) {
UDATA extendedMethodBlockSize = Scalar.roundToSizeofUDATA(new UDATA(clazz.romClass().romMethodCount()));
size = size.add(extendedMethodBlockSize);
}
// Fragment 3. Instance description
if (!clazz.instanceDescription().anyBitsIn(1)) {
UDATA highestBitInSlot = new UDATA(UDATA.SIZEOF * 8 - 1);
UDATA instanceDescriptionSize = clazz.totalInstanceSize().rightShift((int) (ObjectReferencePointer.SIZEOF >> 2) + 1);
instanceDescriptionSize = instanceDescriptionSize.add(highestBitInSlot).bitAnd(highestBitInSlot.bitNot());
if (J9BuildFlags.gc_leafBits) {
instanceDescriptionSize = instanceDescriptionSize.mult(2);
}
size = size.add(instanceDescriptionSize);
}
// Fragment 5. Static slots
U32 staticSlotCount = clazz.romClass().objectStaticCount().add(clazz.romClass().singleScalarStaticCount());
if (J9BuildFlags.env_data64) {
staticSlotCount = staticSlotCount.add(clazz.romClass().doubleScalarStaticCount());
} else {
staticSlotCount = staticSlotCount.add(1).bitAnd(~1L).add(clazz.romClass().doubleScalarStaticCount().mult(2));
}
size = size.add(Scalar.convertSlotsToBytes(new UDATA(staticSlotCount)));
// Fragment 6. Constant pool
U32 constantPoolSlotCount = clazz.romClass().ramConstantPoolCount().mult(2);
size = size.add(Scalar.convertSlotsToBytes(new UDATA(constantPoolSlotCount)));
}
// Fragment 2. Superclasses
UDATA classDepth = classDepthAndFlags(clazz).bitAnd(J9JavaAccessFlags.J9AccClassDepthMask);
if (classDepth.eq(0)) {
// java/lang/Object has a single slot superclasses array
size = size.add(UDATA.SIZEOF);
} else {
size = size.add(Scalar.convertSlotsToBytes(classDepth));
}
// Fragment 4. iTable
if (clazz.iTable().notNull()) {
J9ClassPointer superclass = J9ClassPointer.cast(clazz.superclasses().at(classDepth.sub(1)));
if (superclass.isNull() || !superclass.iTable().eq(clazz.iTable())) {
J9ITablePointer iTable = J9ITablePointer.cast(clazz.iTable());
// Scan to the last iTable belonging to classPointer
if (superclass.isNull()) {
while (iTable.next().notNull()) {
iTable = iTable.next();
}
} else {
while (iTable.next().notNull() && !iTable.next().eq(superclass.iTable())) {
iTable = iTable.next();
}
}
// Find the end of the last iTable
if (clazz.romClass().modifiers().allBitsIn(J9Consts.J9_JAVA_INTERFACE)) {
iTable = iTable.add(1);
} else {
iTable = iTable.add(1).addOffset(iTable.interfaceClass().romClass().romMethodCount().mult(UDATA.SIZEOF));
}
size = size.add(iTable.getAddress() - clazz.iTable().getAddress());
}
}
return size;
}
use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.
the class J9MethodHelper method getName.
public static String getName(J9MethodPointer methodPointer) throws CorruptDataException {
J9ClassPointer className;
J9ConstantPoolPointer constantPool;
if (methodPointer.isNull())
return "bad ramMethod";
constantPool = ConstantPoolHelpers.J9_CP_FROM_METHOD(methodPointer);
if (constantPool.isNull()) {
return "error reading constant pool from ramMethod";
}
className = ConstantPoolHelpers.J9_CLASS_FROM_CP(constantPool);
if (className.isNull()) {
return "error reading class name from constant pool";
}
J9ROMNameAndSignaturePointer nameAndSignature = ROMHelp.J9_ROM_METHOD_FROM_RAM_METHOD(methodPointer).nameAndSignature();
String name = J9UTF8Helper.stringValue(nameAndSignature.name());
String signature = J9UTF8Helper.stringValue(nameAndSignature.signature());
return J9ClassHelper.getName(className) + "." + name + signature;
}
use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.
the class RomClassWalker method allSlotsInConstantPoolDo.
private void allSlotsInConstantPoolDo() throws CorruptDataException {
J9ROMConstantPoolItemPointer constantPool;
int index;
U32Pointer cpShapeDescription;
int constPoolCount;
constantPool = J9ROMClassHelper.constantPool(romClass);
cpShapeDescription = romClass.cpShapeDescription();
if (cpShapeDescription.isNull()) {
return;
}
constPoolCount = romClass.romConstantPoolCount().intValue();
PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
// The spaces at the end of "Constant Pool" are important since the
// regions are sorted
// by address and size, but when they are equal they are sorted by
// longest name and "Constant Pool" has to come first
classWalkerCallback.addSection(clazz, constantPool, constPoolCount * U64.SIZEOF, "constantPool ", true);
for (index = 0; index < constPoolCount; index++) {
long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(cpShapeDescription, index);
if (shapeDesc == J9CPTYPE_CLASS) {
J9ROMStringRefPointer ref = J9ROMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, ref.utf8DataEA(), "cpFieldUtf8");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.cpTypeEA(), "cpFieldType");
} else if ((shapeDesc == J9CPTYPE_STRING) || (shapeDesc == J9CPTYPE_ANNOTATION_UTF8)) {
J9ROMStringRefPointer ref = J9ROMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, ref.utf8DataEA(), "cpFieldUtf8");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.cpTypeEA(), "cpFieldType");
} else if (shapeDesc == J9CPTYPE_INT) {
J9ROMConstantPoolItemPointer ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot1EA(), "cpFieldInt");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot2EA(), "cpFieldIntUnused");
} else if (shapeDesc == J9CPTYPE_FLOAT) {
J9ROMConstantPoolItemPointer ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot1EA(), "cpFieldFloat");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.slot2EA(), "cpFieldFloatUnused");
} else if (shapeDesc == J9CPTYPE_LONG) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "cpField8");
} else if (shapeDesc == J9CPTYPE_DOUBLE) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "cpField8");
} else if (shapeDesc == J9CPTYPE_FIELD) {
J9ROMFieldRefPointer ref = J9ROMFieldRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_SRPNAS, ref.nameAndSignatureEA(), "cpFieldNAS");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.classRefCPIndexEA(), "cpFieldClassRef");
} else if ((shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD)) {
J9ROMMethodRefPointer ref = J9ROMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_SRPNAS, ref.nameAndSignatureEA(), "cpFieldNAS");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.classRefCPIndexEA(), "cpFieldClassRef");
} else if (shapeDesc == J9CPTYPE_METHOD_TYPE) {
J9ROMMethodTypeRefPointer ref = J9ROMMethodTypeRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, ref.signatureEA(), "signature");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.cpTypeEA(), "cpType");
} else if (shapeDesc == J9CPTYPE_METHODHANDLE) {
J9ROMMethodHandleRefPointer ref = J9ROMMethodHandleRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.methodOrFieldRefIndexEA(), "methodOrFieldRefIndex");
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, ref.handleTypeAndCpTypeEA(), "handleTypeAndCpType");
} else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "cpFieldUnused");
}
cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
}
}
use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.
the class DumpSegregatedStatsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (!GCExtensions.isSegregatedHeap()) {
out.append("Only valid for a segregated heap\n");
return;
}
try {
/* Get the region pool */
MM_GCExtensionsPointer extensions = GCExtensions.getGCExtensionsPointer();
MM_RealtimeGCPointer realtimeGC = MM_RealtimeGCPointer.cast(extensions._globalCollector());
MM_RegionPoolSegregatedPointer regionPool = realtimeGC._memoryPool()._regionPool();
/* Get the size classes */
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMGCSizeClassesPointer sizeClasses = vm.realtimeSizeClasses();
long countTotal = 0;
long countAvailableSmallTotal = 0;
long countFullSmallTotal = 0;
long darkMatterBytesTotal = 0;
long allocCacheBytesTotal = 0;
/* arrayOffset is the total offset into a two dimensional array. Used to walk the
* the array linearly */
long arrayOffset = J9Consts.J9VMGC_SIZECLASSES_MIN_SMALL * MM_RegionPoolSegregated.NUM_DEFRAG_BUCKETS;
out.append("sizeClass | full | available | total | free cell count | dark | cache\n");
out.append("===============================================================================\n");
for (long sizeClassIndex = J9Consts.J9VMGC_SIZECLASSES_MIN_SMALL; sizeClassIndex <= J9Consts.J9VMGC_SIZECLASSES_MAX_SMALL; sizeClassIndex++) {
/* Print the sizeclass */
UDATA cellSize = sizeClasses.smallCellSizesEA().at(sizeClassIndex);
out.format("%2d: %5d | ", sizeClassIndex, cellSize.longValue());
MM_HeapRegionListPointer heapRegionQueue = MM_HeapRegionListPointer.cast(regionPool._smallFullRegionsEA().at(sizeClassIndex));
long countSmall = getTotalRegions(heapRegionQueue);
countFullSmallTotal += countSmall;
/* Print the number of full regions of this size class */
out.format("%4d | ", countSmall);
/* The number of free cells of this sizeclass */
long freeCellCount = 0;
for (long i = 0; i < MM_RegionPoolSegregated.NUM_DEFRAG_BUCKETS; i++) {
long count = 0;
MM_LockingHeapRegionQueuePointer heapRegionList = MM_LockingHeapRegionQueuePointer.cast(regionPool._smallAvailableRegionsEA().add(arrayOffset).at(0));
for (long j = 0; j < regionPool._splitAvailableListSplitCount().longValue(); j++) {
count += getTotalRegions(heapRegionList);
freeCellCount += getFreeCellCount(heapRegionList);
heapRegionList = heapRegionList.add(1);
}
/* increment to the next list */
arrayOffset += 1;
countSmall += count;
countAvailableSmallTotal += count;
/* Print the number of available regions in this defrag bucket */
out.format("%4d ", count);
}
countTotal += countSmall;
/* Print the total number of regions of this size class, and the number of free cells */
out.format("| %5d | %15d |", countSmall, freeCellCount);
/* Print the percentage of darkmatter in this region */
long darkMatterCellCount = regionPool._darkMatterCellCountEA().at(sizeClassIndex).longValue();
darkMatterBytesTotal += darkMatterCellCount * cellSize.longValue();
out.format("%%%3d | ", countSmall == 0 ? 0 : darkMatterCellCount / (countSmall * cellSize.longValue()));
/* Calculate the number of bytes in allocation caches */
long allocCacheSize = 0;
J9VMThreadPointer mainThread = vm.mainThread();
if (mainThread.notNull()) {
J9VMThreadPointer threadCursor = vm.mainThread();
do {
J9VMGCSegregatedAllocationCacheEntryPointer cache = threadCursor.segregatedAllocationCache();
cache = cache.add(sizeClassIndex);
allocCacheSize += cache.top().longValue() - cache.current().longValue();
threadCursor = threadCursor.linkNext();
} while (!threadCursor.eq(mainThread));
}
out.format("%5d\n", allocCacheSize);
allocCacheBytesTotal += allocCacheSize;
}
long regionSize = extensions.heap()._heapRegionManager()._regionSize().longValue();
out.format("region size %d\n", regionSize);
long arrayletLeafSize = extensions._omrVM()._arrayletLeafSize().longValue();
out.format("arraylet leaf size %d\n", arrayletLeafSize);
out.format("small total (full, available) region count %d (%d, %d)\n", countTotal, countFullSmallTotal, countAvailableSmallTotal);
long countFullArraylet = getTotalRegions(regionPool._arrayletFullRegions());
long countAvailArraylet = getTotalRegions(regionPool._arrayletAvailableRegions());
long countTotalArraylet = countFullArraylet + countAvailArraylet;
countTotal += countTotalArraylet;
out.format("arraylet total (full, available) region count %d (%d %d)\n", countTotalArraylet, countFullArraylet, countAvailArraylet);
long countLarge = getTotalRegions(regionPool._largeFullRegions());
countTotal += countLarge;
out.format("large full region count %d\n", countLarge);
long countFree = getTotalRegions(regionPool._singleFreeList());
countTotal += countFree;
out.format("free region count %d\n", countFree);
long countMultiFree = getTotalRegions(regionPool._multiFreeList());
countTotal += countMultiFree;
out.format("multiFree region count %d\n", countMultiFree);
long countCoalesce = getTotalRegions(regionPool._coalesceFreeList());
countTotal += countCoalesce;
out.format("coalesce region count %d\n", countCoalesce);
long heapSize = countTotal * regionSize;
out.format("total region count %d, total heap size %d \n", countTotal, heapSize);
out.format("dark matter total bytes %d (%2.2f%% of heap)\n", darkMatterBytesTotal, 100.0 * darkMatterBytesTotal / heapSize);
out.format("allocation cache total bytes %d (%2.2f%% of heap)\n", allocCacheBytesTotal, 100.0 * allocCacheBytesTotal / heapSize);
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.
the class DumpAllClassloadersCommand method run.
/**
* Run method for !dumpallclassloaders extension.
*
* @param command !dumpallclassloaders
* @param args !dumpallclassloaders extension accepts no args
* @param context Context
* @param out PrintStream
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 0) {
printUsage(out);
return;
}
try {
if (J9BuildFlags.env_data64) {
out.append("+------------------------------------------------------------------------- \n");
out.append("| ClassLoader | SharedLibraries | ClassHashTable | jniIDs Pool |\n");
out.append("| | Pool | | |\n");
out.append("| |-----------------+-----------------+-----------------| \n");
out.append("| Address | used | capacity | used | capacity | used | capacity |\n");
out.append("+-------------------+-----------------+-----------------+----------------- \n");
} else {
out.append("+----------------------------------------------------------------- \n");
out.append("|ClassLoader| SharedLibraries | ClassHashTable | jniIDs Pool |\n");
out.append("| | Pool | | |\n");
out.append("| |-----------------+-----------------+-----------------| \n");
out.append("| Address | used | capacity | used | capacity | used | capacity |\n");
out.append("+-----------+-----------------+-----------------+----------------- \n");
}
GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
J9ClassLoaderPointer classLoaderPointer;
String classLoaderAddress;
long sharedLibPoolNumOfelements;
long sharedLibPoolCapacity;
long classHashTableNumOfelements;
long classHashTableCapacity;
long jniIDsPoolNumOfelements;
long jniIDsPoolCapacity;
while (iterator.hasNext()) {
classLoaderPointer = iterator.next();
classLoaderAddress = classLoaderPointer.getHexAddress();
J9PoolPointer sharedLibraries = classLoaderPointer.sharedLibraries();
if (!sharedLibraries.isNull()) {
Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(sharedLibraries, J9PoolPuddlePointer.class);
sharedLibPoolNumOfelements = pool.numElements();
sharedLibPoolCapacity = pool.capacity();
} else {
sharedLibPoolNumOfelements = 0;
sharedLibPoolCapacity = 0;
}
J9HashTablePointer classHashTable = classLoaderPointer.classHashTable();
if (!classHashTable.isNull()) {
if (!classHashTable.listNodePool().isNull()) {
J9PoolPointer listNodePool = classHashTable.listNodePool();
Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(listNodePool, J9PoolPuddlePointer.class);
classHashTableNumOfelements = pool.numElements();
classHashTableCapacity = pool.capacity();
} else {
classHashTableNumOfelements = classHashTable.numberOfNodes().longValue();
classHashTableCapacity = classHashTable.tableSize().longValue();
}
} else {
classHashTableNumOfelements = 0;
classHashTableCapacity = 0;
}
J9PoolPointer jniIDs = classLoaderPointer.jniIDs();
if (!jniIDs.isNull()) {
Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(jniIDs, J9PoolPuddlePointer.class);
jniIDsPoolNumOfelements = pool.numElements();
jniIDsPoolCapacity = pool.capacity();
} else {
jniIDsPoolNumOfelements = 0;
jniIDsPoolCapacity = 0;
}
String output = format(classLoaderAddress, sharedLibPoolNumOfelements, sharedLibPoolCapacity, classHashTableNumOfelements, classHashTableCapacity, jniIDsPoolNumOfelements, jniIDsPoolCapacity);
out.println(output);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations