-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8369296: Add fast class init checks in interpreter for resolving ConstantPool entries for static field #27676
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
8369296: Add fast class init checks in interpreter for resolving ConstantPool entries for static field #27676
Conversation
…tantPool entries for static field Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
|
/contributor add @iwanowww |
|
👋 Welcome back asmehra! A progress list of the required criteria for merging this PR into |
|
@ashu-mehra This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 144 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
@ashu-mehra |
|
@ashu-mehra The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
|
@offamitkumar @Hamlin-Li @RealFYang @TheRealMDoerr @vnkozlov @adinn @iwanowww can you please review this patch. |
|
Hi @ashu-mehra, This is fixing the test failure on s390: diff --git a/src/hotspot/cpu/s390/templateTable_s390.cpp b/src/hotspot/cpu/s390/templateTable_s390.cpp
index 2b39cc8318c..cf34bff7746 100644
--- a/src/hotspot/cpu/s390/templateTable_s390.cpp
+++ b/src/hotspot/cpu/s390/templateTable_s390.cpp
@@ -2409,6 +2409,7 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no,
assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
NearLabel resolved;
+ Label L_clinit_barrier_slow;
Bytecodes::Code code = bytecode();
switch (code) {
@@ -2425,6 +2426,8 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no,
__ z_bre(resolved);
// resolve first time through
+ // Class initialization barrier slow path lands here as well.
+ __ bind(L_clinit_barrier_slow);
address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_from_cache);
__ load_const_optimized(Z_ARG2, (int)code);
__ call_VM(noreg, entry, Z_ARG2);
@@ -2434,6 +2437,15 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no,
__ bind(resolved);
+ // Class initialization barrier for static fields
+ if (VM_Version::supports_fast_class_init_checks() &&
+ (bytecode() == Bytecodes::_getstatic || bytecode() == Bytecodes::_putstatic)) {
+ const Register field_holder = index;
+
+ __ load_sized_value(field_holder, Address(cache, ResolvedFieldEntry::field_holder_offset()), sizeof(void*), false);
+ __ clinit_barrier(field_holder, Z_thread, nullptr /*L_fast_path*/, &L_clinit_barrier_slow);
+ }
+
BLOCK_COMMENT("} resolve_cache_and_index_for_field");
} |
|
x86- and aarch64-specific changes look good. There are 3 other platforms (ppc, s390, and riscv) which report |
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.
Can we loop to L_clinit_barrier_slow several times until class is initialized?
No, |
First, what do you mean "blocks"? It wait something with lock? Second, my question was that slow path in |
Also, I think |
|
Thank you @ashu-mehra for explanation. So we can call
Agree. |
|
I submitted our testing. |
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
|
@offamitkumar thanks for the patch. I have added it. |
|
/contributor add @offamitkumar |
|
@ashu-mehra |
There are no guarantees that the class is initialized. But the only case when it doesn't hold is when the class is being initialized and current thread is initializing one. So, it is guaranteed that slow path is taken at most once.
|
yes, |
|
@ashu-mehra |
|
x86- and aarch64-specific changes look fine to me. |
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
|
@RealFYang thanks for the patch. I added it. |
|
/contributor add @RealFYang |
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.
Unfortunately, this is no longer correct for PPC64 because the isync instruction is missing on some paths, now. While this looks good for other platforms, can you revert only PPC64 to the previous version, please?
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@TheRealMDoerr thanks for catching the bug. The resolved non-static case is missing the isync. Reverted the ppc changes as suggested. |
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.
Thank you for improving it for all platforms! I think it is better readably, now. Only a minor nit. We'll retest it over the weekend.
| const Register klass = Rscratch; | ||
|
|
||
|
|
||
|
|
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.
Can you remove these extra empty lines, please?
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.
Done
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.
aarch64 and x64 changes looks good to me.
I need to run new testing.
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
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.
My v08 testing passed.
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.
Update to RISC-V part looks fine. And hotspot_runtime still test good with fastdebug build on linux-riscv64.
|
Test results look good on all SAP supported platforms (including linux and AIX on PPC64). |
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.
Riscv part looks good, Thanks!
| assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); | ||
|
|
||
| Label resolved, clinit_barrier_slow; | ||
| Label Lclinit_barrier_slow, Ldone; |
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.
Minor comment: why don't you use L_name instead? Lname is a new idiom for naming labels on most of the platforms. (The convention is either L_name or simply name almost everywhere.)
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.
Sorry, I guess that was my mistake. Changing it would be fine with me. Not a big deal, though.
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 will update the label names to use the convention L_name.
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.
Done
| __ br(Assembler::EQ, resolved); | ||
|
|
||
| // Class initialization barrier for static methods | ||
| if (VM_Version::supports_fast_class_init_checks() && bytecode() == Bytecodes::_invokestatic) { |
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.
FTR VM_Version::supports_fast_class_init_checks() is redundant in platform-specific code.
The method is intended to be used in shared code to support dispatching between 2 execution modes, but for each platform is it known well ahead whether fast class init checks are supported or not.
(It does make sense to keep it as an assert through.)
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.
True, but I also like the current implementation from a readability perspective.
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.
Let's keep it for now. I will remove VM_Version::supports_fast_class_init_checks() from platform-specific code in a follow-up PR.
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.
Sounds good, thanks!
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
|
@iwanowww I addressed your suggestion to rename the labels. |
|
No code change after v08 (only labels were renamed and empty lines removed) - no need to re-test. |
|
okay, lets get this in. Thanks everyone for the reviews and suggestions. |
|
/integrate |
|
Going to push as commit 622a611.
Your commit was automatically rebased without conflicts. |
|
@ashu-mehra Pushed as commit 622a611. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This patch adds fast clinit barrier in the interpreter when resolving cp entry for a static field.
Testing: tested x86-64 by running
hotspot_runtimegroupSpecifically,
runtime/clinit/ClassInitBarrier.javafails if the block for addingclinit_barrieris commented out inTemplateTable::resolve_cache_and_index_for_fieldProgress
Issue
Reviewers
Contributors
<vlivanov@openjdk.org><amitkumar@openjdk.org><fyang@openjdk.org><mdoerr@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27676/head:pull/27676$ git checkout pull/27676Update a local copy of the PR:
$ git checkout pull/27676$ git pull https://git.openjdk.org/jdk.git pull/27676/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27676View PR using the GUI difftool:
$ git pr show -t 27676Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27676.diff
Using Webrev
Link to Webrev Comment