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

Ensure addClassFromCPRecord emits CP record #20680

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cjjdespres
Copy link
Contributor

The addClassFromCPRecord method of the symbol validation manager should make sure that a ClassFromCPRecord is always added to the current compilation.

The addClassFromCPRecord method of the symbol validation manager should
make sure that a ClassFromCPRecord is always added to the current
compilation.

Signed-off-by: Christian Despres <[email protected]>
@cjjdespres
Copy link
Contributor Author

@dsouzai I'm fairly sure that a ClassFromCPRecord needs to be added here if the class hasn't already been remembered. I can't see a reason why it can be skipped, at least.

@cjjdespres
Copy link
Contributor Author

I have tested this to see if it helped with #20529 (comment), and unfortunately it does not. I'm curious - if this record does need to be added, do we need to make sure that a ClassFromCPRecord is added for these as well?

bool
TR::SymbolValidationManager::addDefiningClassFromCPRecord(TR_OpaqueClassBlock *clazz, J9ConstantPool *constantPoolOfBeholder, uint32_t cpIndex, bool isStatic)
{
TR_OpaqueClassBlock *beholder = _fej9->getClassFromCP(constantPoolOfBeholder);
SVM_ASSERT_ALREADY_VALIDATED(this, beholder);
if (skipFieldRefClassRecord(clazz, beholder, cpIndex))
return true;
else
return addClassRecord(clazz, new (_region) DefiningClassFromCPRecord(clazz, beholder, cpIndex, isStatic));
}
bool
TR::SymbolValidationManager::addStaticClassFromCPRecord(TR_OpaqueClassBlock *clazz, J9ConstantPool *constantPoolOfBeholder, uint32_t cpIndex)
{
TR_OpaqueClassBlock *beholder = _fej9->getClassFromCP(constantPoolOfBeholder);
SVM_ASSERT_ALREADY_VALIDATED(this, beholder);
if (skipFieldRefClassRecord(clazz, beholder, cpIndex))
return true;
else
return addClassRecord(clazz, new (_region) StaticClassFromCPRecord(clazz, beholder, cpIndex));
}

In the compilation in the linked comment, a DefiningClassFromCPRecord was created for a class/beholder/cp index triple without a ClassFromCPRecord being created for it.

@cjjdespres
Copy link
Contributor Author

cjjdespres commented Nov 26, 2024

I tried #20680 (comment), but it seemed to result in a very large number of class from CP validation failures at load time. It might be DeclaringClassFromFieldOrStatic that could use a DefiningClassFromCPRecord, if that's appropriate.

@cjjdespres cjjdespres marked this pull request as draft November 26, 2024 20:53
@cjjdespres
Copy link
Contributor Author

I should test this a bit more.

@dsouzai
Copy link
Contributor

dsouzai commented Nov 27, 2024

@dsouzai I'm fairly sure that a ClassFromCPRecord needs to be added here if the class hasn't already been remembered. I can't see a reason why it can be skipped, at least.

This was done in #4694; as per the commit message:

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.

@cjjdespres
Copy link
Contributor Author

That does make sense. I noticed that class from CP records were often skipped. I'm trying something else to try to resolve the validation failures related to CP entries with dependency tracking; since the lack of record is intentional I'll likely just close this.

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.

2 participants