Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new DDR command constantpool #15404

Merged
merged 1 commit into from
Sep 22, 2022
Merged

Conversation

thallium
Copy link
Contributor

@thallium thallium force-pushed the master branch 4 times, most recently from cd91689 to d17b615 Compare June 29, 2022 20:48
@thallium thallium force-pushed the master branch 2 times, most recently from 8a90b4f to c739e04 Compare July 6, 2022 15:29
@thallium
Copy link
Contributor Author

thallium commented Jul 6, 2022

@fengxue-IS ready to be reviewed

@thallium thallium changed the title [WIP] Add new DDR command constantpool Add new DDR command constantpool Jul 11, 2022
Copy link
Contributor

@fengxue-IS fengxue-IS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work overall, some formatting changes and display message

note: please use (unresolved) instead of NULL

addCommand("constantpool", "<ramclass>", "dump constant pool for the given ram class.");
}

public J9ClassPointer findClassByName(J9JavaVMPointer vm, String name) throws CorruptDataException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All helper methods should be private rather than public unless they will be used in other classes

String romInfo = "";
String value = "";
if (cpType == J9ConstantPool.J9CPTYPE_CLASS) {
cpTypeString = "Class";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be better to have either an map or helper to translate cpType to String and use that directly

}
}
value += ")";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an else case to catch any CP type that are either incorrect or new type which may be added in future to remind us of updating the tool.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add either a error message or exception throw to make this visible when a unexpected CP type is detected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing Error is inappropriate here: the problem may be a corrupt core file, so CorruptDataException is more likely the right exception.

Comment on lines 207 to 209
romInfo = constantRef.dataEA().getHexAddress();
if (i < ramCPCount) {
ramInfo = ramCPP.getHexAddress();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please put the matching struct type before the address ie !J9RAMSingleSlotConstantRef and !J9ROMSingleSlotConstantRef
same for float/long/double

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the same thing for long and double since they uses two slots?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long and double constants don't have an entry in RAM CP, so there is nothing to check/put for ramInfo.
long/double will still use the same 2 slot structure type in ROM CP as J9ROMConstantRef
so should print romInfo = "!j9romconstantref " + romCPP.getHexAddress();

Comment on lines 244 to 248
ramInfo = staticRef.valueOffset().getHexValue(); // resolved static
} else if (ref.flags().gt(ref.valueOffset())) {
ramInfo = ref.valueOffset().getHexValue(); // resolved instance
} else {
ramInfo = "NULL"; // unresolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the field type (object/static) info after the offset
so something like
0x000000000000001C (Static offset)

for unresolved entries maybe use (unresolved) to be more clear

romInfo = "!j9rommethod " + ROMHelp.J9_ROM_METHOD_FROM_RAM_METHOD(sendMethod).getHexAddress();
}
} else {
ramInfo = "Method Index: " + methodIndex.longValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be VTableOffset:

ramInfo = "Method Index: " + methodIndex.longValue();
}
} else { // standard interface method
ramInfo = "Method Index: " + methodIndex.longValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ITable Index: here

ramInfo = "Method Index: " + methodIndex.longValue();
}
} else {
ramInfo = "NULL";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before, use (unresolved)

}
J9ROMNameAndSignaturePointer nameAndSignature = romMethodRef.nameAndSignature();
romInfo = "!j9romnameandsignature " + nameAndSignature.getHexAddress();
value = "invoke/invokeExact";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to get the name/signature from the ROM info, I think that would be better than having a generic invoke/invokeExact

@thallium thallium requested a review from fengxue-IS July 13, 2022 18:46
Copy link
Contributor

@fengxue-IS fengxue-IS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, few minor nit pick

}
}
value += ")";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add either a error message or exception throw to make this visible when a unexpected CP type is detected

Copy link
Contributor

@fengxue-IS fengxue-IS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@fengxue-IS
Copy link
Contributor

@keithc-ca can you please review this, thanks
@tajila FYI

debugtools/DDR_VM/src/com/ibm/j9ddr/AuxFieldInfo29.dat Outdated Show resolved Hide resolved
Comment on lines 526 to 513
} catch (NoSuchFieldException | NoClassDefFoundError e) {
throw new CorruptDataException(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please list exceptions alphabetically and add a comment explaining why it's reasonable to classify it as corruption.


public class J9ConstantPoolCommand extends Command {
private static final HashMap<Long, String> cpTypeToString = new HashMap<Long, String>();
private static final int METHOD_INDEX_OFFSET = 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is poorly named; perhaps you meant to use J9_ITABLE_INDEX_SHIFT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also used for virtual method, and it's hard-coded elsewhere so I can't come up with a good name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J9_ITABLE_INDEX_SHIFT is 10, and that should be defined and used in rightShift(10) calls, this value of 8 has always been hardcoded as number in VM, we should look to make that into a constant in the future, in this PR, we can just name it J9_METHOD_INDEX_SHIFT

@fengxue-IS
Copy link
Contributor

@keithc-ca can this PR be merged or do you have any additional concern that you would like to see addressed?

@keithc-ca
Copy link
Contributor

I'll have another look shortly.

Copy link
Contributor

@keithc-ca keithc-ca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of my comments were inappropriately marked as "resolved". I've unresolved the ones I still think need attention.

@thallium
Copy link
Contributor Author

thallium commented Aug 9, 2022

I might somehow messed up with the branch and I'm trying to get it fixed.

@fengxue-IS
Copy link
Contributor

FYI 379aa5a seem to be the snapshot before incorrect merge

@thallium
Copy link
Contributor Author

thallium commented Aug 9, 2022

FYI 379aa5a seem to be the snapshot before incorrect merge

yeah I pushed the master branch in my java 19 repo without realizing it's not in sync with my java 18 repo which contains the latest changes.

@keithc-ca
Copy link
Contributor

See #15128 (comment).

@fengxue-IS
Copy link
Contributor

See #15128 (comment).

Copying reply from #15128 (comment)

This is expected as when a classfile is loaded by the VM, CP entries will be optimized by the JVM (items reordered : ldc entries moved to the top, long and double moved to the end, UTF8 that do not get referenced directly gets removed from constantpool and referenced via SRPs)

@fengxue-IS
Copy link
Contributor

@keithc-ca can you take another look

@thallium thallium force-pushed the master branch 2 times, most recently from e83e1be to f6548fa Compare August 30, 2022 20:52
@thallium
Copy link
Contributor Author

@keithc-ca Your comments have been addressed

Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
@keithc-ca
Copy link
Contributor

jenkins test sanity alinux64 jdk8,jdk17

@keithc-ca keithc-ca merged commit cbbacda into eclipse-openj9:master Sep 22, 2022
keithc-ca added a commit to keithc-ca/openj9 that referenced this pull request May 10, 2023
It was needlessly added in eclipse-openj9#15404.

Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
midronij pushed a commit to midronij/openj9 that referenced this pull request May 24, 2023
It was needlessly added in eclipse-openj9#15404.

Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
midronij pushed a commit to midronij/openj9 that referenced this pull request Jun 1, 2023
It was needlessly added in eclipse-openj9#15404.

Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New DDR command constantpool
3 participants