-
Notifications
You must be signed in to change notification settings - Fork 729
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
Updated recognized methods for newer JDKs #18383
Conversation
@vijaysun-omr @zl-wang Could you take a look at this? |
I assume the presence of two signatures that could be recognized for I would also appreciate a quick review from @hzongaro for this PR. |
@@ -2887,6 +2888,7 @@ void TR_ResolvedJ9Method::construct() | |||
{x(TR::sun_misc_Unsafe_putFloatVolatile_jlObjectJF_V, "putFloatRelease", "(Ljava/lang/Object;JF)V")}, | |||
{x(TR::sun_misc_Unsafe_putDoubleVolatile_jlObjectJD_V, "putDoubleRelease", "(Ljava/lang/Object;JD)V")}, | |||
{x(TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V, "putObjectRelease", "(Ljava/lang/Object;JLjava/lang/Object;)V")}, | |||
{x(TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V, "putReferenceRelease", "(Ljava/lang/Object;JLjava/lang/Object;)V")}, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the motivation to keep the enum name of TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V
for method putReferenceRelease
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the convention that was already being used in the area. For example one line up the existing putObjectRelease
also reuses TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V
.
putObjectRelease
does nothing but call putObjectVolatile
.
putReferenceRelease
does nothing but call putReferenceVolatile
.
putObjectRelease
, putObjectVolatile
and putReferenceVolatile
are all recognized as TR::sun_misc_Unsafe_putObjectVolatile_jlObjectJjlObject_V
. So it seemed to me that putReferenceRelease
should also do the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. for these particular methods, this might be the right way to go. otherwise, more works are required to optimize them, since their bytecode(s) contain another call.
@@ -2921,6 +2923,7 @@ void TR_ResolvedJ9Method::construct() | |||
{x(TR::sun_misc_Unsafe_getFloatVolatile_jlObjectJ_F, "getFloatAcquire", "(Ljava/lang/Object;J)F")}, | |||
{x(TR::sun_misc_Unsafe_getDoubleVolatile_jlObjectJ_D, "getDoubleAcquire", "(Ljava/lang/Object;J)D")}, | |||
{x(TR::sun_misc_Unsafe_getObjectVolatile_jlObjectJ_jlObject, "getObjectAcquire", "(Ljava/lang/Object;J)Ljava/lang/Object;")}, | |||
{x(TR::sun_misc_Unsafe_getObjectVolatile_jlObjectJ_jlObject, "getReferenceAcquire", "(Ljava/lang/Object;J)Ljava/lang/Object;")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
The new recognized |
@@ -2141,6 +2141,7 @@ void TR_ResolvedJ9Method::construct() | |||
{x(TR::java_util_HashMap_findNullKeyEntry, "findNullKeyEntry", "()Ljava/util/HashMap$Entry;")}, | |||
{x(TR::java_util_HashMap_get, "get", "(Ljava/lang/Object;)Ljava/lang/Object;")}, | |||
{x(TR::java_util_HashMap_getNode, "getNode", "(ILjava/lang/Object;)Ljava/util/HashMap$Node;")}, | |||
{x(TR::java_util_HashMap_getNode, "getNode", "(Ljava/lang/Object;)Ljava/util/HashMap$Node;")}, | |||
{x(TR::java_util_HashMap_putImpl, "putImpl", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as well, same enum name for essentially different recognized methods, any implications? hoped these different methods don't exist at the same time in a single level of language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the same question I had, maybe I just asked it in an unclear manner .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, I reused it because it was almost the same method and all the locations that used the recognized method wanted to do the exact same thing. But, they aren't completely identical so it might be better to separate them even if the two versions don't ever exist in the same JDK level at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that would be cleaner. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now split off the new Hashmap.get
to map to java_util_HashMap_getNode_Object
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making that change. I think people have often reused enumerated values for recognized methods because it was convenient thing to do. However, it's a potential source of future bugs if someone makes a change to the treatment of a recognized method without realizing that more than one method might be affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over all, I think the changes look good. Just one suggestion for some pre-existing code in UnsafeFastPath.cpp
.
Also, the commit guidlines ask that the first line of a commit be in the imperative mood. May I ask you to change "Updated recognized methods for newer JDKs" to something like "Update recognized methods for newer JDKs", and if you are not going to squash the second commit, change "New recognized method for HashMap.getNode" to something like "Add new recognized method for HashMap.getNode"?
@@ -2141,6 +2141,7 @@ void TR_ResolvedJ9Method::construct() | |||
{x(TR::java_util_HashMap_findNullKeyEntry, "findNullKeyEntry", "()Ljava/util/HashMap$Entry;")}, | |||
{x(TR::java_util_HashMap_get, "get", "(Ljava/lang/Object;)Ljava/lang/Object;")}, | |||
{x(TR::java_util_HashMap_getNode, "getNode", "(ILjava/lang/Object;)Ljava/util/HashMap$Node;")}, | |||
{x(TR::java_util_HashMap_getNode, "getNode", "(Ljava/lang/Object;)Ljava/util/HashMap$Node;")}, | |||
{x(TR::java_util_HashMap_putImpl, "putImpl", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making that change. I think people have often reused enumerated values for recognized methods because it was convenient thing to do. However, it's a potential source of future bugs if someone makes a change to the treatment of a recognized method without realizing that more than one method might be affected.
break; | ||
case TR::java_util_concurrent_ConcurrentHashMap_tabAt: | ||
case TR::java_util_concurrent_ConcurrentHashMap_setTabAt: | ||
isArrayOperation = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as you're modifying this file, may I ask you to add a break
at the end of this case? There doesn't seem to be any reason for it to want to fall through, and if someone adds another case to this switch in the future, they might not notice they'll need to add a break
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this. The commit title will also be updated and the commits squashed.
Method recognition has been updated for the following three cases: As of JDK12, ConcurrentHashMap.tabAt now calls Unsafe.getReferenceAcquire instead of Unsafe.getObjectVolatile. Unsafe.getReferenceAcquire is now recognized so it triggers the Unsafe Fast Path opt. As of JDK12, ConcurrentHashMap.setTabAt now calls Unsafe.putReferenceRelease instead of Unsafe.putObjectVolatile. Unsafe.putReferenceRelease is also now recognized for Unsafe Fast Path. As of JDK15, the signature for HashMap.getNode no longer has an int parameter. An entry for this case has been added so the method is forced to be inlined like it was before. All locations that use the existing HashMap.getNode recognized method entry have been updated to also work with the new one. This change also includes minor code clean up inside UnsafeFastPath.cpp. A break has been added to a switch block for code clarity and some whitespace has been fixed. Signed-off-by: jimmyk <[email protected]> added break
74e65bb
to
0d0bd0f
Compare
I added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks!
jenkins test sanity plinux,aix,xlinux,zlinuxjit jdk8,jdk17 |
Jimmy reached out regarding to failure seen on Z with CRIU tests in the build. The failure seen in the test are seen in nightly builds on OpenJ9 jenkins as well [1][2]. Searching around, Jason has already opened up issue on Jenkins two days ago reporting same failure in internal jenkins (#18384). Will look into those failures. As far as this PR goes, I can confirm, failures seen on Z are not related to the changes in this PR. [1]. https://openj9-jenkins.osuosl.org/job/Test_openjdk17_j9_sanity.functional_s390x_linux_Nightly_testList_0/591/tapResults/ |
https://openj9-jenkins.osuosl.org/job/Test_openjdk17_j9_sanity.functional_ppc64le_linux_Personal/350/
This is a known issue and exists in builds that do not include my recognized method changes. https://openj9-jenkins.osuosl.org/job/Test_openjdk17_j9_sanity.functional_x86-64_linux_Personal/454/
I am currently looking into why there was a timeout. https://openj9-jenkins.osuosl.org/job/Test_openjdk8_j9_sanity.functional_s390x_linux_jit_Personal/4/ |
I was able to reproduce both the timeout issue in test rc018 in So all of the failures in testing look to be existing issues that are unrelated to my changes. |
good. merging ... |
Method recognition has been updated for the following three cases:
As of JDK12,
ConcurrentHashMap.tabAt
now callsUnsafe.getReferenceAcquire
instead ofUnsafe.getObjectVolatile
.Unsafe.getReferenceAcquire
is now recognized so it triggers the Unsafe Fast Path opt.As of JDK12,
ConcurrentHashMap.setTabAt
now callsUnsafe.putReferenceRelease
instead ofUnsafe.putObjectVolatile
.Unsafe.putReferenceRelease
is also now recognized for Unsafe Fast Path.As of JDK15, the signature for
HashMap.getNode
no longer has an int parameter. An entry for this case has been added so the method is forced to be inlined like it was before.