use of com.ibm.j9ddr.vm29.pointer.PointerPointer in project openj9 by eclipse.
the class RamClassWalker method allSlotsInRAMSuperClassesDo.
private void allSlotsInRAMSuperClassesDo() throws CorruptDataException {
/* The classDepth represent the number of superclasses */
final long classDepth = J9ClassHelper.classDepth(ramClass).longValue();
/*
* The superclasses is an array, ramClass.superclasses() points to the
* head and we get the next superclasses by moving the pointer.
* superclasses.add(i) adds sizeof(UDATA) to the value of the
* superclass'pointer
*/
final PointerPointer superclasses = ramClass.superclasses();
for (int i = 0; i < classDepth; i++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, superclasses.add(i), "SuperClass address", "!j9class");
}
classWalkerCallback.addSection(clazz, superclasses, classDepth * PointerPointer.SIZEOF, "Superclasses", false);
}
use of com.ibm.j9ddr.vm29.pointer.PointerPointer 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.pointer.PointerPointer in project openj9 by eclipse.
the class ITableSizeCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
long currentSize = 0;
long duplicatedSize = 0;
long extendedSize = 0;
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer clazz = (J9ClassPointer) classSegmentIterator.next();
int classDepth = clazz.classDepthAndFlags().bitAnd(J9_JAVA_CLASS_DEPTH_MASK).intValue();
J9ITablePointer superITable = J9ITablePointer.NULL;
J9ITablePointer startITable = J9ITablePointer.cast(clazz.iTable());
if (0 != classDepth) {
PointerPointer superclasses = clazz.superclasses();
J9ClassPointer superclazz = J9ClassPointer.cast(superclasses.at(classDepth - 1));
superITable = J9ITablePointer.cast(superclazz.iTable());
}
currentSize += iTableChainSize(startITable, superITable);
duplicatedSize += iTableChainSize(superITable, J9ITablePointer.NULL);
extendedSize += iTableExtendedSize(startITable, superITable);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
long totalSize = duplicatedSize + currentSize;
double percent = (double) totalSize / (double) currentSize;
out.append("iTable duplication" + nl);
out.append("------------------" + nl);
out.append("current iTable size : " + currentSize + nl);
out.append("additional iTable size : " + duplicatedSize + nl);
out.append("total iTable size : " + totalSize + nl);
out.append("growth factor : " + percent + nl);
out.append(nl);
percent = (double) extendedSize / (double) currentSize;
out.append("iTable contains extends" + nl);
out.append("-----------------------" + nl);
out.append("current iTable size : " + currentSize + nl);
out.append("new iTable size : " + extendedSize + nl);
out.append("growth factor : " + percent + nl);
out.append(nl);
}
use of com.ibm.j9ddr.vm29.pointer.PointerPointer in project openj9 by eclipse.
the class VMConstantPoolCommand method run.
/**
* Run method for !vmconstantpool extension.
*
* @param command !vmconstantpool
* @param args args passed by !vmconstantpool extension.
* @param context Context
* @param out PrintStream
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer javaVM;
javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (args.length == 1) {
long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
if (vmaddress != javaVM.getAddress()) {
out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
return;
}
} else if (args.length > 1) {
printUsage(out);
}
J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
int index;
U32Pointer cpShapeDescription;
int constPoolCount;
cpShapeDescription = romClass.cpShapeDescription();
long cpDescription = cpShapeDescription.at(0).longValue();
constPoolCount = romClass.romConstantPoolCount().intValue();
PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
long cpDescriptionIndex = 0;
for (index = 0; index < constPoolCount; index++) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpShapeDescription.at(0).longValue();
cpShapeDescription = cpShapeDescription.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
AbstractPointer ref = PointerPointer.NULL;
if (shapeDesc == J9CPTYPE_CLASS) {
ref = J9ROMClassRefPointer.cast(cpEntry);
} else if (shapeDesc == J9CPTYPE_STRING) {
ref = J9ROMStringRefPointer.cast(cpEntry);
} else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
} else if (shapeDesc == J9CPTYPE_LONG) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
} else if (shapeDesc == J9CPTYPE_DOUBLE) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
} else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
long classRefCPIndex;
if (shapeDesc == J9CPTYPE_FIELD) {
ref = J9ROMFieldRefPointer.cast(cpEntry);
/* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
} else {
ref = J9ROMFieldRefPointer.cast(cpEntry);
classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
}
PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
/* gets the DDR output of the item */
String outString = ref.formatFullInteractive();
String[] parts = outString.split(nl);
/* add a debug extension(!j9romclassref) on the second line of the output */
parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
out.print(join(nl, parts));
} else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
} else if (ref.notNull()) {
out.println(ref.formatFullInteractive());
}
cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.PointerPointer in project openj9 by eclipse.
the class CheckEngine method checkClassStatics.
private int checkClassStatics(J9ClassPointer clazz) {
int result = J9MODRON_GCCHK_RC_OK;
try {
boolean validationRequired = true;
if (J9ClassHelper.isSwappedOut(clazz)) {
/* if class has been hot swapped (J9AccClassHotSwappedOut bit is set) in Fast HCR,
* the ramStatics of the existing class may be reused. The J9ClassReusedStatics
* bit in J9Class->extendedClassFlags will be set if that's the case.
* In Extended HCR mode ramStatics might be not NULL and must be valid
* NOTE: If class is hot swapped and the value in ramStatics is NULL it is valid
* to have the correspondent ROM Class value in objectStaticCount field greater then 0
*/
if (J9ClassHelper.isArrayClass(clazz)) {
/* j9arrayclass should not be hot swapped */
result = J9MODRON_GCCHK_RC_CLASS_HOT_SWAPPED_FOR_ARRAY;
CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
_reporter.report(error);
return result;
}
if (J9ClassHelper.areExtensionsEnabled()) {
/* This is Extended HSR mode so hot swapped class might have NULL in ramStatics field */
if (clazz.ramStatics().isNull()) {
validationRequired = false;
}
}
try {
/* This case can also occur when running -Xint with extensions enabled */
if (J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassReusedStatics)) {
validationRequired = false;
}
} catch (NoSuchFieldError e) {
/* Flag must be missing from the core. */
}
}
if (validationRequired) {
// J9ClassLoaderPointer classLoader = clazz.classLoader();
J9ROMClassPointer romClazz = clazz.romClass();
UDATA numberOfReferences = new UDATA(0);
PointerPointer sectionStart = PointerPointer.NULL;
PointerPointer sectionEnd = PointerPointer.NULL;
/*
* Note: we have no special recognition for J9ArrayClass here
* J9ArrayClass does not have a ramStatics field but something else at this place
* so direct check (NULL != clazz->ramStatics) would not be correct,
* however romClazz->objectStaticCount must be 0 for this case
*/
if (!romClazz.objectStaticCount().eq(0)) {
sectionStart = PointerPointer.cast(clazz.ramStatics());
sectionEnd = sectionStart.add(romClazz.objectStaticCount());
}
/* Iterate all fields of ROM Class looking to statics fields pointed to java objects */
Iterator<J9ObjectFieldOffset> objectFieldOffsetIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(clazz, J9ClassHelper.superclass(clazz), new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC | J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS));
while (objectFieldOffsetIterator.hasNext()) {
J9ObjectFieldOffset fieldOffset = objectFieldOffsetIterator.next();
// J9ROMFieldShapePointer field = fieldOffset.getField();
numberOfReferences = numberOfReferences.add(1);
/* get address of next field */
PointerPointer address = sectionStart.addOffset(fieldOffset.getOffsetOrAddress());
/* an address must be in gc scan range */
if (!(address.gte(sectionStart) && address.lt(sectionEnd))) {
result = J9MODRON_GCCHK_RC_CLASS_STATICS_REFERENCE_IS_NOT_IN_SCANNING_RANGE;
CheckError error = new CheckError(clazz, address, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
_reporter.report(error);
}
/* check only if we have an object */
// TODO kmt : can't easily implement this part of the check
// J9Class* classToCast = vm->internalVMFunctions->internalFindClassUTF8(currentThread, toSearchString, toSearchLength, classLoader, J9_FINDCLASS_FLAG_EXISTING_ONLY);
// if ((NULL == classToCast) || (0 == instanceOfOrCheckCast(J9GC_J9OBJECT_CLAZZ(*address), classToCast))) {
// The issue is that we can't simply call "internalFindClassUTF8" in DDR.
// We could guess at the behaviour of the ClassLoader, but that makes
// distingushing a real problem from a weird ClassLoader delegation
// model difficult.
}
if (!numberOfReferences.eq(romClazz.objectStaticCount())) {
result = J9MODRON_GCCHK_RC_CLASS_STATICS_WRONG_NUMBER_OF_REFERENCES;
CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
_reporter.report(error);
}
}
} 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 result;
}
Aggregations