use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class GCScavengerForwardedHeader_V1 method getForwardedObjectNoCheck.
protected J9ObjectPointer getForwardedObjectNoCheck() throws CorruptDataException {
if (J9BuildFlags.interp_compressedObjectHeader && !J9BuildFlags.env_littleEndian) {
/* compressed big endian - read two halves separately */
U32 low = U32Pointer.cast(objectPointer.clazzEA()).at(0).bitAnd(~ALL_TAGS);
U32 high = U32Pointer.cast(objectPointer.clazzEA()).at(1);
J9ObjectPointer forwardedObject = J9ObjectPointer.cast(new UDATA(low).bitOr(new UDATA(high).leftShift(32)));
return forwardedObject;
} else {
/* Little endian or not compressed - read all UDATA bytes at once */
J9ObjectPointer forwardedObject = J9ObjectPointer.cast(UDATAPointer.cast(objectPointer.clazzEA()).at(0));
return forwardedObject.untag(ALL_TAGS);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class GCScavengerForwardedHeader_V1 method getObjectSize.
@Override
public UDATA getObjectSize() throws CorruptDataException {
J9ObjectPointer forwardedObject = getForwardedObjectNoCheck();
UDATA forwardedObjectSize;
if (ObjectModel.hasBeenMoved(forwardedObject) && !ObjectModel.hasBeenHashed(forwardedObject)) {
// this hashed but not moved yet object just has been forwarded
// so hash slot was added which increase size of the object
forwardedObjectSize = ObjectModel.getSizeInBytesWithHeader(forwardedObject);
forwardedObjectSize = ObjectModel.adjustSizeInBytes(forwardedObjectSize);
} else {
forwardedObjectSize = ObjectModel.getConsumedSizeInBytesWithHeader(forwardedObject);
}
return forwardedObjectSize;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class J9ObjectHelper method stringValue.
public static String stringValue(J9ObjectPointer objPointer) throws CorruptDataException {
if (!J9ObjectHelper.getClassName(objPointer).equals("java/lang/String")) {
throw new IllegalArgumentException();
}
// No synchronization needed here because the type of java/lang/String.value is immutable
if (isStringBackedByByteArray == null) {
try {
getObjectField(objPointer, getFieldOffset(objPointer, "value", "[B"));
isStringBackedByByteArray = new Boolean(true);
} catch (NoSuchElementException e) {
getObjectField(objPointer, getFieldOffset(objPointer, "value", "[C"));
isStringBackedByByteArray = new Boolean(false);
}
}
J9ObjectPointer valueObject = isStringBackedByByteArray.booleanValue() ? getObjectField(objPointer, getFieldOffset(objPointer, "value", "[B")) : getObjectField(objPointer, getFieldOffset(objPointer, "value", "[C"));
if (valueObject.isNull()) {
return "<Uninitialized String>";
}
int offset = 0;
int count = getIntField(objPointer, getFieldOffset(objPointer, "count", "I"));
boolean isStringCompressed = false;
AlgorithmVersion version = AlgorithmVersion.getVersionOf(AlgorithmVersion.STRING_COMPRESSION_VERSION);
switch(version.getAlgorithmVersion()) {
case 1:
boolean enableCompression = getBooleanField(objPointer, getFieldOffset(objPointer, "enableCompression", "Z"));
if (enableCompression) {
if (count >= 0) {
isStringCompressed = true;
} else {
count = count & 0x7FFFFFFF;
}
}
break;
default:
offset = getIntField(objPointer, getFieldOffset(objPointer, "offset", "I"));
break;
}
char[] charValue = new char[count];
J9IndexableObjectPointer valueArray = J9IndexableObjectPointer.cast(valueObject);
if (isStringBackedByByteArray.booleanValue()) {
byte[] value = (byte[]) J9IndexableObjectHelper.getData(valueArray);
if (isStringCompressed) {
for (int i = 0; i < count; ++i) {
charValue[i] = byteToCharUnsigned(getByteFromArrayByIndex(value, i));
}
} else {
for (int i = 0; i < count; ++i) {
charValue[i] = getCharFromArrayByIndex(value, i);
}
}
} else {
char[] value = (char[]) J9IndexableObjectHelper.getData(valueArray);
if (isStringCompressed) {
for (int i = 0; i < count; ++i) {
charValue[i] = byteToCharUnsigned(getByteFromArrayByIndex(value, i));
}
} else {
for (int i = 0; i < count; ++i) {
charValue[i] = getCharFromArrayByIndex(value, i);
}
}
}
return new String(charValue, offset, count);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class RamClassWalker method allSlotsInConstantPoolDo.
private void allSlotsInConstantPoolDo() throws CorruptDataException {
final J9ROMClassPointer romClass = ramClass.romClass();
final int constPoolCount = romClass.ramConstantPoolCount().intValue();
final J9ConstantPoolPointer cpp = J9ConstantPoolPointer.cast(ramClass.ramConstantPool());
U32Pointer cpDescriptionSlots = romClass.cpShapeDescription();
PointerPointer cpEntry = PointerPointer.cast(ramClass.ramConstantPool());
long cpDescription = 0;
long cpEntryCount = ramClass.romClass().ramConstantPoolCount().longValue();
long cpDescriptionIndex = 0;
while (cpEntryCount > 0) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpDescriptionSlots.at(0).longValue();
cpDescriptionSlots = cpDescriptionSlots.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
/*
* A switch statement can't be used on long type, it might be
* erroneous to cast it to an int as it might change in the future.
*/
long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_RAM_UTF8, ref.stringObjectEA(), "stringObject");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
if (slotType == J9CPTYPE_STRING) {
classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_STRING", false);
} else {
classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_ANNOTATION_UTF8", false);
}
} else if (slotType == J9CPTYPE_METHOD_TYPE) {
J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.type();
if (slot.notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type", "!j9object");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slotCountEA(), "slotCount");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodTypeRef.SIZEOF, "J9CPTYPE_METHOD_TYPE", false);
} else if (slotType == J9CPTYPE_METHODHANDLE) {
J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.methodHandle();
if (slot.notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle", "!j9object");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodHandleRef.SIZEOF, "J9CPTYPE_METHODHANDLE", false);
} else if (slotType == J9CPTYPE_CLASS) {
J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
if (ref.value().notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value", "!j9class");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.modifiersEA(), "modifiers");
classWalkerCallback.addSection(clazz, ref, J9RAMClassRef.SIZEOF, "J9CPTYPE_CLASS", false);
} else if (slotType == J9CPTYPE_INT) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldInt");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_INT", false);
} else if (slotType == J9CPTYPE_FLOAT) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldFloat");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_FLOAT", false);
} else if (slotType == J9CPTYPE_LONG) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_LONG");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_LONG", false);
} else if (slotType == J9CPTYPE_DOUBLE) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_DOUBLE");
classWalkerCallback.addSection(clazz, ref, I64.SIZEOF, "J9CPTYPE_DOUBLE", false);
} else if (slotType == J9CPTYPE_FIELD) {
J9RAMFieldRefPointer ref = J9RAMFieldRefPointer.cast(cpEntry);
J9RAMStaticFieldRefPointer staticRef = J9RAMStaticFieldRefPointer.cast(cpEntry);
/* if the field ref is resolved static, it has 'flagsAndClass', for other cases (unresolved and resolved instance) it has 'flags'. */
if ((staticRef.flagsAndClass().longValue() > 0) && (staticRef.valueOffset().longValue() != -1)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_IDATA, staticRef.flagsAndClassEA(), "flagsAndClass");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.flagsEA(), "flags");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueOffsetEA(), "valueOffset");
classWalkerCallback.addSection(clazz, ref, J9RAMFieldRef.SIZEOF, "J9CPTYPE_FIELD", false);
} else if (slotType == J9CPTYPE_INTERFACE_METHOD) {
J9RAMInterfaceMethodRefPointer ref = J9RAMInterfaceMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.interfaceClassEA(), "interfaceClass", "!j9class");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
classWalkerCallback.addSection(clazz, ref, J9RAMInterfaceMethodRef.SIZEOF, "J9CPTYPE_INTERFACE_METHOD", false);
} else if (slotType == J9CPTYPE_STATIC_METHOD) {
J9RAMStaticMethodRefPointer ref = J9RAMStaticMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMStaticMethodRef.SIZEOF, "J9CPTYPE_STATIC_METHOD", false);
} else if ((slotType == J9CPTYPE_UNUSED) || (slotType == J9CPTYPE_UNUSED8)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry, "unused");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry.add(1), "unused");
classWalkerCallback.addSection(clazz, cpEntry, 2 * UDATA.SIZEOF, "J9CPTYPE_UNUSED", false);
} else if (slotType == J9CPTYPE_INSTANCE_METHOD) {
J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_INSTANCE_METHOD", false);
} else if (slotType == J9CPTYPE_HANDLE_METHOD) {
J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodTypeIndexAndArgCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_HANDLE_METHOD", false);
}
cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
cpEntryCount -= 1;
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
// 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, cpp, constPoolCount * 2 * UDATA.SIZEOF, "Constant Pool ", false);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class ClassloadersSummaryCommand method getStat.
public Collection<ClassloadersSummaryNode> getStat() throws CorruptDataException {
Map<J9ClassLoaderPointer, Counter> classloadersCount = new HashMap<J9ClassLoaderPointer, Counter>();
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
while (iterator.hasNext()) {
J9ClassLoaderPointer classLoader = iterator.next();
classloadersCount.put(classLoader, new Counter(0));
}
/* Iterate through all classes and count how many were loaded by each classLoader */
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
Counter counter = classloadersCount.get(classPointer.classLoader());
if (counter != null) {
counter.addOne();
} else {
classloadersCount.put(classPointer.classLoader(), new Counter(1));
}
}
J9ObjectPointer sys = vm.systemClassLoader().classLoaderObject();
final UDATA valueROM = new UDATA(J9MemorySegment.MEMORY_TYPE_ROM_CLASS);
final UDATA valueRAM = new UDATA(J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
Map<String, ClassloadersSummaryNode> classloaders = new LinkedHashMap<String, ClassloadersSummaryNode>();
for (Map.Entry<J9ClassLoaderPointer, Counter> entry : classloadersCount.entrySet()) {
J9ObjectPointer classLoaderObject = entry.getKey().classLoaderObject();
boolean isSystem = classLoaderObject.equals(sys);
String loader = isSystem ? "*System*" : J9ObjectHelper.getClassName(classLoaderObject);
/* For each classloader, iterate through each associated memory segment and identify whether it is
* a ROM or a RAM type memory segment */
long romSegmentCount = 0;
long ramSegmentCount = 0;
long romSegmentAllocatedMem = 0;
long ramSegmentAllocatedMem = 0;
J9MemorySegmentPointer segment = entry.getKey().classSegments();
while (segment.notNull()) {
if ((segment.type().bitAnd(valueROM)).equals(valueROM)) {
romSegmentCount += 1;
romSegmentAllocatedMem += segment.size().longValue();
} else if ((segment.type().bitAnd(valueRAM)).equals(valueRAM)) {
ramSegmentCount += 1;
ramSegmentAllocatedMem += segment.size().longValue();
}
segment = segment.nextSegmentInClassLoader();
}
ClassloadersSummaryNode cpentry = classloaders.get(loader);
if (cpentry == null) {
// If the classLoader is not in the list, add it with "# Classloaders = 1" and "# Loaded Classes = classesLoaded"
classloaders.put(loader, new ClassloadersSummaryNode(loader, 1L, entry.getValue().getCount(), ramSegmentCount, romSegmentCount, romSegmentAllocatedMem, ramSegmentAllocatedMem));
} else {
// If the classLoader is in the list, increment "# Classloaders" by 1 and increment "# Loaded Classes" by classesLoaded
cpentry.numClassloaders += 1;
cpentry.numLoadedClasses += entry.getValue().getCount();
cpentry.ramSegmentCounter += ramSegmentCount;
cpentry.romSegmentCounter += romSegmentCount;
cpentry.totalROMSegmentAllocatedMemory += romSegmentAllocatedMem;
cpentry.totalRAMSegmentAllocatedMemory += ramSegmentAllocatedMem;
}
}
return classloaders.values();
}
Aggregations