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

Reimplement getMethodFromName around other queries #4175

Merged
merged 2 commits into from
Jan 4, 2019

Conversation

jdmpapin
Copy link
Contributor

@jdmpapin jdmpapin commented Jan 3, 2019

This series reimplements getMethodFromName in terms of getSystemClassFromClassName and getMethodFromClass in order to eliminate the unnecessary MethodByName validation kind.

This way it needs no special treatment in TR_J9SharedCacheVM, since the
required records are naturally created within the two simpler queries.

The callingMethod is now ignored because all callers pass the names of
JCL classes that are loaded by the bootstrap loader. The only
restriction that could be imposed by using the loader associated with
callingMethod would be to potentially "hide" the class, but in that case
the existing code retries with the bootstrap class loader anyway. So now
the bootstrap loader is used on the first attempt.

getMethodFromName is split into two virtual methods, one without this
extra parameter, so that OMR can also remove the parameter without
breaking compatibility.

For TR_ValidateMethodFromClassAndSig, the callingClass ("beholder") is
now optional. Callers of getMethodFromClass do not have to provide a
callingClass, and in particular none is provided in getMethodFromName.

Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
This record is unused now that getMethodFromName() is implemented in
terms of getSystemClassFromClassName() and getMethodFromClass().

Signed-off-by: Devin Papineau <devinmp@ca.ibm.com>
Copy link
Contributor

@dsouzai dsouzai left a comment

Choose a reason for hiding this comment

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

One question, if the callingClass is optional, why do we need to specify it in the validation record at all?

@jdmpapin
Copy link
Contributor Author

jdmpapin commented Jan 3, 2019

If provided, it's used for testing visibility

@dsouzai
Copy link
Contributor

dsouzai commented Jan 3, 2019

As I'm not an expert on the Java semantics, @andrewcraik could you give this a once over?

@dsouzai
Copy link
Contributor

dsouzai commented Jan 3, 2019

If provided, it's used for testing visibility

Is it possible during the validation run where previously we would fail the AOT load when getClassFromID returned NULL, now because it's optional we might incorrectly get back NULL and not fail the load?

@andrewcraik
Copy link
Contributor

I'll look tomorrow morning when I have time to go through it properly - I'm going to launch sanity now in the hope the review doesn't require major changes.

@andrewcraik
Copy link
Contributor

Jenkins test sanity xlinux,win,plinux jdk8,jdk11

@dsouzai
Copy link
Contributor

dsouzai commented Jan 4, 2019

TOTAL: 211   EXECUTED: 134   PASSED: 134   FAILED: 0   SKIPPED: 77
ALL TESTS PASSED

No idea why the xlinux jdk11 build shows as failed :S. I asked the question here https://openj9.slack.com/archives/C8312LCV9/p1546610068034700

@jdmpapin
Copy link
Contributor Author

jdmpapin commented Jan 4, 2019

If provided, it's used for testing visibility

Is it possible during the validation run where previously we would fail the AOT load when getClassFromID returned NULL, now because it's optional we might incorrectly get back NULL and not fail the load?

We would only fail the load as a quiet failure of the assertion that prevents unexpected null return values, but e.g. debug builds would crash. It's not a legitimate situation that requires load failure.

We can get null only if beholderID is the null ID, i.e. if at compile time the callingClass was null. No other ID can become null, since that would collide with the null ID. Any (earlier) validation that tried to set the value of another ID to null would have already failed the load beforehand.

@dsouzai
Copy link
Contributor

dsouzai commented Jan 4, 2019

We can get null only if beholderID is the null ID, i.e. if at compile time the callingClass was null.

I see, that makes sense; I got confused because of the SymOptional which evoked the idea that the SVM could return NULL if an ID wasn't found; but taking a look at SymbolValidationManager::getSymbolFromID, an ID that wasn't found will result in the appropriate failure via the SVM_ASSERT.

@dsouzai
Copy link
Contributor

dsouzai commented Jan 4, 2019

I'm ok to merge this once @andrewcraik takes a look at the refactoring done for TR_J9VM::getMethodFromName

@andrewcraik
Copy link
Contributor

So I'm fine with this - there is a capability reduction in that the current code can find a non-system loader from the constant pool and use that to look up a class while the new implementation only uses the system loader. That being said the types we lookup by name are loaded by the system loader since they are only core JCL types. Further, the lookup using the non-system loader falls back to the system loader so you don't get an accurate result for a lookup anyway (you will miss some failures) so the non-system case is not correct anyway.

I'm fine with this change - if we need the non-system loader case it deserves a different API anyway.

Copy link
Contributor

@andrewcraik andrewcraik left a comment

Choose a reason for hiding this comment

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

LGTM

@dsouzai dsouzai merged commit ba85e60 into eclipse-openj9:master Jan 4, 2019
@jdmpapin jdmpapin deleted the svm.method-by-name branch April 9, 2021 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants