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

8331935: Add support for primitive array C1 clone intrinsic in PPC #19250

Closed
wants to merge 6 commits into from

Conversation

varada1110
Copy link
Contributor

@varada1110 varada1110 commented May 15, 2024

https://bugs.openjdk.org/browse/JDK-8302850 port for PPC64

JMH Benchmark Results

Before :

Benchmark                 (size)  Mode  Cnt    Score   Error  Units
ArrayClone.byteArraycopy       0  avgt   15  114.107 ? 1.337  ns/op
ArrayClone.byteArraycopy      10  avgt   15  130.492 ? 0.991  ns/op
ArrayClone.byteArraycopy     100  avgt   15  139.103 ? 1.913  ns/op
ArrayClone.byteArraycopy    1000  avgt   15  321.688 ? 6.033  ns/op
ArrayClone.byteClone           0  avgt   15  227.602 ? 3.393  ns/op
ArrayClone.byteClone          10  avgt   15  237.624 ? 2.996  ns/op
ArrayClone.byteClone         100  avgt   15  239.219 ? 2.835  ns/op

ArrayClone.byteClone        1000  avgt   15  355.571 ? 2.946  ns/op
ArrayClone.intArraycopy        0  avgt   15  113.275 ? 1.099  ns/op
ArrayClone.intArraycopy       10  avgt   15  129.763 ? 1.458  ns/op
ArrayClone.intArraycopy      100  avgt   15  213.327 ? 2.524  ns/op
ArrayClone.intArraycopy     1000  avgt   15  449.650 ? 7.338  ns/op
ArrayClone.intClone            0  avgt   15  225.682 ? 3.048  ns/op
ArrayClone.intClone           10  avgt   15  234.532 ? 2.817  ns/op
ArrayClone.intClone          100  avgt   15  295.934 ? 4.925  ns/op
ArrayClone.intClone         1000  avgt   15  573.368 ? 5.739  ns/op
Finished running test 'micro:java.lang.ArrayClone'
Test report is stored in build/aix-ppc64-server-release/test-results/micro_java_lang_ArrayClone

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   micro:java.lang.ArrayClone                            1     1     0     0   
==============================
TEST SUCCESS

Finished building target 'test' in configuration 'aix-ppc64-server-release'




After:

Benchmark                 (size)  Mode  Cnt    Score    Error  Units
ArrayClone.byteArraycopy       0  avgt   15  113.894 ?  0.993  ns/op
ArrayClone.byteArraycopy      10  avgt   15  131.455 ?  0.956  ns/op
ArrayClone.byteArraycopy     100  avgt   15  139.145 ?  3.002  ns/op
ArrayClone.byteArraycopy    1000  avgt   15  315.957 ? 14.591  ns/op
ArrayClone.byteClone           0  avgt   15   43.753 ?  3.669  ns/op
ArrayClone.byteClone          10  avgt   15   52.329 ?  1.041  ns/op
ArrayClone.byteClone         100  avgt   15  127.711 ?  3.938  ns/op

ArrayClone.byteClone        1000  avgt   15  225.937 ?  1.987  ns/op
ArrayClone.intArraycopy        0  avgt   15  113.788 ?  0.770  ns/op
ArrayClone.intArraycopy       10  avgt   15  131.980 ?  2.102  ns/op
ArrayClone.intArraycopy      100  avgt   15  213.745 ?  2.615  ns/op
ArrayClone.intArraycopy     1000  avgt   15  460.820 ?  7.106  ns/op
ArrayClone.intClone            0  avgt   15   42.074 ?  0.547  ns/op
ArrayClone.intClone           10  avgt   15   80.125 ?  1.735  ns/op
ArrayClone.intClone          100  avgt   15  207.313 ?  2.717  ns/op
ArrayClone.intClone         1000  avgt   15  326.546 ?  5.671  ns/op
Finished running test 'micro:java.lang.ArrayClone'
Test report is stored in build/aix-ppc64-server-release/test-results/micro_java_lang_ArrayClone

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   micro:java.lang.ArrayClone                            1     1     0     0   
==============================
TEST SUCCESS

Hotspot compiler tests results :

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
>> jtreg:test/hotspot/jtreg:hotspot_compiler          1170  1168     2     0 <<
==============================
TEST FAILURE

2 test failures shown here is not related to code change. It is present without this changes

Reported Issue : JDK-8331935


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8331935: Add support for primitive array C1 clone intrinsic in PPC (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19250/head:pull/19250
$ git checkout pull/19250

Update a local copy of the PR:
$ git checkout pull/19250
$ git pull https://git.openjdk.org/jdk.git pull/19250/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19250

View PR using the GUI difftool:
$ git pr show -t 19250

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19250.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 15, 2024

👋 Welcome back varadam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented May 15, 2024

@varada1110 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:

8331935: Add support for primitive array C1 clone intrinsic in PPC

Reviewed-by: mdoerr, amitkumar

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 91 new commits pushed to the master branch:

  • f7862bd: 8331311: C2: Big Endian Port of 8318446: optimize stores into primitive arrays by combining values into larger store
  • b4beda2: 8332537: C2: High memory usage reported for compiler/loopopts/superword/TestAlignVectorFuzzer.java
  • e5383d7: 8333713: C2 SuperWord: cleanup in vectornode.cpp/hpp
  • 944aeb8: 8325155: C2 SuperWord: remove alignment boundaries
  • d8af589: 8026127: Deflater/Inflater documentation incomplete/misleading
  • 6238bc8: 8333456: CompactNumberFormat integer parsing fails when string has no suffix
  • 2a37764: 8333743: Change .jcheck/conf branches property to match valid branches
  • 75dc2f8: 8330182: Start of release updates for JDK 24
  • 054362a: 8332550: [macos] Voice Over: java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
  • 9b436d0: 8333674: Disable CollectorPolicy.young_min_ergo_vm for PPC64
  • ... and 81 more: https://git.openjdk.org/jdk/compare/75220da26f647c6f3dabc05cea81cefaf3a1e195...master

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TheRealMDoerr, @offamitkumar) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented May 15, 2024

@varada1110 The following label will be automatically applied to this pull request:

  • hotspot-compiler

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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label May 15, 2024
@varada1110 varada1110 changed the title JDK-8331935 : Add support for primitive array C1 clone intrinsic JDK-8331935: Add support for primitive array C1 clone intrinsic May 15, 2024
@openjdk openjdk bot changed the title JDK-8331935: Add support for primitive array C1 clone intrinsic 8331935: Add support for primitive array C1 clone intrinsic in PPC May 15, 2024
@TheRealMDoerr
Copy link
Contributor

The test failures will be fixed by #19218. Unrelated.

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

This looks good. Please adapt the indentation. You can mark it as ready for review.

src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

I got crashes when testing on linux ppc64le and noticed that we need one more adaptation to handle stub == nullptr. I suggest the following addition:

diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
index b6d9200b261..dba662a2212 100644
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -1968,7 +1968,11 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
   int shift = shift_amount(basic_type);
 
   if (!(flags & LIR_OpArrayCopy::type_check)) {
-    __ b(cont);
+    if (stub != nullptr) {
+      __ b(cont);
+      __ bind(slow);
+      __ b(*stub->entry());
+    }
   } else {
     // We don't know the array types are compatible.
     if (basic_type != T_OBJECT) {
@@ -2089,9 +2093,9 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
         __ add(dst_pos, tmp, dst_pos);
       }
     }
+    __ bind(slow);
+    __ b(*stub->entry());
   }
-  __ bind(slow);
-  __ b(*stub->entry());
   __ bind(cont);
 
 #ifdef ASSERT

@varada1110
Copy link
Contributor Author

I got crashes when testing on linux ppc64le and noticed that we need one more adaptation to handle stub == nullptr. I suggest the following addition:

diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
index b6d9200b261..dba662a2212 100644
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -1968,7 +1968,11 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
   int shift = shift_amount(basic_type);
 
   if (!(flags & LIR_OpArrayCopy::type_check)) {
-    __ b(cont);
+    if (stub != nullptr) {
+      __ b(cont);
+      __ bind(slow);
+      __ b(*stub->entry());
+    }
   } else {
     // We don't know the array types are compatible.
     if (basic_type != T_OBJECT) {
@@ -2089,9 +2093,9 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
         __ add(dst_pos, tmp, dst_pos);
       }
     }
+    __ bind(slow);
+    __ b(*stub->entry());
   }
-  __ bind(slow);
-  __ b(*stub->entry());
   __ bind(cont);
 
 #ifdef ASSERT

Hi @TheRealMDoerr , I have applied the suggested changes and I have fixed the indentation fixes. Testing is also done.
Thank you

@varada1110 varada1110 marked this pull request as ready for review May 16, 2024 09:12
@openjdk openjdk bot added the rfr Pull request is ready for review label May 16, 2024
@mlbridge
Copy link

mlbridge bot commented May 16, 2024

Webrevs

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

LGTM. I'll rerun tests. Please ask somebody from your team to do a 2nd review.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 16, 2024
@varada1110
Copy link
Contributor Author

Thanks @TheRealMDoerr
Hi @offamitkumar, Could you please review the code?

Copy link
Member

@offamitkumar offamitkumar left a comment

Choose a reason for hiding this comment

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

Good

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

I got test failures on AIX which need investigation: compiler/c2/Test6910605_2.java
assert(oopDesc::is_oop(s)) failed: JVM_ArrayCopy: src not an oop

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 16, 2024
@varada1110
Copy link
Contributor Author

I got test failures on AIX which need investigation: compiler/c2/Test6910605_2.java assert(oopDesc::is_oop(s)) failed: JVM_ArrayCopy: src not an oop

Hi @TheRealMDoerr , this test failure was not showing for me.
I retested with 'JAVA_OPTIONS=-XX:TieredStopAtLevel=1' and the test is passing

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   jtreg:test/hotspot/jtreg/compiler/c2/Test6910605_2.java
                                                         1     1     0     0   
==============================
TEST SUCCESS

@TheRealMDoerr
Copy link
Contributor

I can reproduce it on linux with the fastdebug build.

@varada1110
Copy link
Contributor Author

I can reproduce it on linux with the fastdebug build.

Yes. The test failing with fastdebug build

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/hotspot/openjdk/jdk-varada/src/hotspot/share/prims/jvm.cpp:301), pid=27263472, tid=4884
#  assert(oopDesc::is_oop(s)) failed: JVM_ArrayCopy: src not an oop
#
# JRE version: OpenJDK Runtime Environment (23.0) (fastdebug build 23-internal-adhoc.hotspot.jdk-varada)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 23-internal-adhoc.hotspot.jdk-varada, mixed mode, emulated-client, tiered, compressed oops, compressed class ptrs, g1 gc, aix-ppc64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/hotspot/openjdk/jdk-varada/build/aix-ppc64-server-fastdebug/test-support/jtreg_test_hotspot_jtreg_compiler_c2_Test6910605_2_java/scratch/0/hs_err_pid27263472.log
[0.762s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#```

@TheRealMDoerr
Copy link
Contributor

I also have a minor cleanup proposal for LIR_Assembler::emit_arraycopy:

diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
index dba662a2212..2424d820177 100644
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -1827,18 +1827,17 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
 
   int flags = op->flags();
   ciArrayKlass* default_type = op->expected_type();
-  BasicType basic_type = default_type != nullptr ? default_type->element_type()->basic_type() : T_ILLEGAL;
+  BasicType basic_type = (default_type != nullptr) ? default_type->element_type()->basic_type() : T_ILLEGAL;
   if (basic_type == T_ARRAY) basic_type = T_OBJECT;
 
   // Set up the arraycopy stub information.
   ArrayCopyStub* stub = op->stub();
-  const int frame_resize = frame::native_abi_reg_args_size - sizeof(frame::java_abi); // C calls need larger frame.
 
   // Always do stub if no type information is available. It's ok if
   // the known type isn't loaded since the code sanity checks
   // in debug mode and the type isn't required when we know the exact type
   // also check that the type is an array type.
-  if (op->expected_type() == nullptr) {
+  if (default_type == nullptr) {
     assert(src->is_nonvolatile() && src_pos->is_nonvolatile() && dst->is_nonvolatile() && dst_pos->is_nonvolatile() &&
            length->is_nonvolatile(), "must preserve");
     address copyfunc_addr = StubRoutines::generic_arraycopy();
@@ -1873,7 +1872,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
     return;
   }
 
-  assert(default_type != nullptr && default_type->is_array_klass(), "must be true at this point");
+  assert(default_type != nullptr && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
   Label cont, slow, copyfunc;
 
   bool simple_check_flag_set = flags & (LIR_OpArrayCopy::src_null_check |

Would be nice to have.

Copy link
Member

@offamitkumar offamitkumar left a comment

Choose a reason for hiding this comment

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

I guess you can update this as well:

diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
index 2424d820177..0c1e23c6353 100644
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -2107,7 +2107,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
     // subtype which we can't check or src is the same array as dst
     // but not necessarily exactly of type default_type.
     Label known_ok, halt;
-    metadata2reg(op->expected_type()->constant_encoding(), tmp);
+    metadata2reg(default_type->constant_encoding(), tmp);
     if (UseCompressedClassPointers) {
       // Tmp holds the default type. It currently comes uncompressed after the
       // load of a constant, so encode it.

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

Looks good and the tests have passed.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 21, 2024
Copy link
Member

@offamitkumar offamitkumar left a comment

Choose a reason for hiding this comment

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

I have compared with s390x and it looks fine to me. But note that I don't have AIX machine to test.

@varada1110
Copy link
Contributor Author

Thank you @TheRealMDoerr @offamitkumar . I am running the tests: hotspot_compiler, hotspot_gc, hotspot_serviceability and hotspot_runtime for tier1, tier2 and tier3 with fastdebug, slowdebug and release. I will update the results.

@offamitkumar
Copy link
Member

with fastdebug, slowdebug and release.

I think with fastdebug is sufficient.

@TheRealMDoerr
Copy link
Contributor

I've put it again into our nightly tests and haven't seen any errors which may have been caused by this PR. There are currently some unrelated errors. So, I think it's good to go.

@shipilev
Copy link
Member

There is currently a regression in the original code, JDK-8332670, which may explain some instability on PPC.

@TheRealMDoerr
Copy link
Contributor

Thanks for the hint! We should wait for that one to be fixed.

@varada1110 varada1110 closed this May 31, 2024
@varada1110 varada1110 reopened this May 31, 2024
@varada1110
Copy link
Contributor Author

Thank you @TheRealMDoerr @offamitkumar . I am running the tests: hotspot_compiler, hotspot_gc, hotspot_serviceability and hotspot_runtime for tier1, tier2 and tier3 with fastdebug, slowdebug and release. I will update the results.

Completed the testing for fastdebug. There are few unrelated test failures

@TheRealMDoerr
Copy link
Contributor

#19538 is integrated, so we can ship this one, too.

@varada1110
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jun 7, 2024
@openjdk
Copy link

openjdk bot commented Jun 7, 2024

@varada1110
Your change (at version b339ecb) is now ready to be sponsored by a Committer.

@offamitkumar
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Jun 7, 2024

Going to push as commit 6968770.
Since your change was applied there have been 94 commits pushed to the master branch:

  • a2030ff: 8332516: Serial: Always sample promoted bytes to avoid getting stuck in Full GCs
  • bf7f1c4: 8333211: NMT Reports: replace manual indentation handling with auto indent
  • 8ffc35d: 8333724: Problem list security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java#teliasonerarootcav1
  • f7862bd: 8331311: C2: Big Endian Port of 8318446: optimize stores into primitive arrays by combining values into larger store
  • b4beda2: 8332537: C2: High memory usage reported for compiler/loopopts/superword/TestAlignVectorFuzzer.java
  • e5383d7: 8333713: C2 SuperWord: cleanup in vectornode.cpp/hpp
  • 944aeb8: 8325155: C2 SuperWord: remove alignment boundaries
  • d8af589: 8026127: Deflater/Inflater documentation incomplete/misleading
  • 6238bc8: 8333456: CompactNumberFormat integer parsing fails when string has no suffix
  • 2a37764: 8333743: Change .jcheck/conf branches property to match valid branches
  • ... and 84 more: https://git.openjdk.org/jdk/compare/75220da26f647c6f3dabc05cea81cefaf3a1e195...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 7, 2024
@openjdk openjdk bot closed this Jun 7, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jun 7, 2024
@openjdk
Copy link

openjdk bot commented Jun 7, 2024

@offamitkumar @varada1110 Pushed as commit 6968770.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
4 participants