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

Eliminate redundant ClassFromCP/ClassByName records #4694

Merged
merged 3 commits into from
Feb 13, 2019

Conversation

jdmpapin
Copy link
Contributor

This series reduces the number of records generated for ClassFromCP and ClassByName:

  • self-referential ClassFromCP and ClassByName records are unnecessary;
  • we don't need both ClassFromCP and ClassByName for the same class, beholder pair; and
  • using ClassByName instead of ClassFromCP for fresh classes saves a ClassChain record.

Whenever a class C contains (in a signature or constant pool entry) a
reference to a class with the same name as C, that class reference must
resolve to C itself, so no record is necessary.

Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
No beholder needs both a ClassByName and ClassFromCP record identifying
the same class, since constant pool entries are also specified by name.
The name used in the constant pool at a given index will always match in
a successful load, because the beholder will have passed class chain
validation.

Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
If a class is first encountered by the symbol validation manager as the
result of ClassFromCP, it is necessary to generate both the originally
requested ClassFromCP record and a ClassChain validation record. A
ClassByName with the same beholder has the same results as ClassFromCP
would, and it subsumes ClassChain, so that only ClassByName is needed.
The ClassByName record is larger than the ClassFromCP alone, but smaller
than the two records would have been together.

Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
{
bool operator()(const ClassFromAnyCPIndex &a, const ClassFromAnyCPIndex &b) const
{
std::less<TR_OpaqueClassBlock*> lt;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curiosity question: how come you didn't use LexicalOrder here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to keep LexicalOrder file-local in SymbolValidationManager.cpp. It could be useful more generally, but we'd have to figure out where to put it—certainly not in SymbolValidationManager.hpp. I suppose we could also move the implementation of LessClassFromAnyCPIndex::operator() into the cpp file

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I think it's fine as is for now; if ever there's a need for another "less" operator, we can then move the LexicalOrder class somewhere more appropriate.

@@ -631,7 +631,12 @@ TR::SymbolValidationManager::addClassFromCPRecord(TR_OpaqueClassBlock *clazz, J9
if (recordExists(&byName))
return true; // already have an equivalent ClassByName

bool added = addClassRecord(clazz, new (_region) ClassFromCPRecord(clazz, beholder, cpIndex));
bool added;
if (!isAlreadyValidated(clazz)) // save a ClassChainRecord
Copy link
Contributor

Choose a reason for hiding this comment

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

The idea here is that

  1. because a ClassFromCP+ClassChain is larger than ClassByName, it is better to generate a ClassByName if we've never generated a ClassChain record.
  2. because ClassFromCP is smaller than ClassByName, it is better to generate a ClassFromCP if we have generated a ClassChain record.

Is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, especially since in 2 the ClassFromCP will suppress any later ClassByName that would be equivalent

@dsouzai
Copy link
Contributor

dsouzai commented Feb 12, 2019

jenkins test sanity xlinux,win,plinux,zlinux jdk8,jdk11

@dsouzai dsouzai merged commit 9b73857 into eclipse-openj9:master Feb 13, 2019
@jdmpapin jdmpapin deleted the svm.cp-byname branch April 9, 2021 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants