< prev index next >

src/hotspot/cpu/ppc/stubGenerator_ppc.cpp

Print this page
rev 53302 : 8216060: [PPC64] Vector CRC implementation should be used by interpreter and be faster for short arrays
Reviewed-by: gromero, goetz

@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2018, SAP SE. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -3186,29 +3186,25 @@
     return start;
   }
 
 
   // Compute CRC32/CRC32C function.
-  void generate_CRC_updateBytes(const char* name, Register table, bool invertCRC) {
+  void generate_CRC_updateBytes(const char* name, Register table, Register vector_constants, bool invertCRC) {
 
       // arguments to kernel_crc32:
       const Register crc     = R3_ARG1;  // Current checksum, preset by caller or result from previous call.
       const Register data    = R4_ARG2;  // source byte array
       const Register dataLen = R5_ARG3;  // #bytes to process
 
-      const Register t0      = R2;
-      const Register t1      = R7;
-      const Register t2      = R8;
-      const Register t3      = R9;
-      const Register tc0     = R10;
-      const Register tc1     = R11;
-      const Register tc2     = R12;
-
       BLOCK_COMMENT("Stub body {");
       assert_different_registers(crc, data, dataLen, table);
 
-      __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, table, invertCRC);
+      if (vector_constants == noreg) {
+        __ kernel_crc32_1word(crc, data, dataLen, table, R2, R7, R8, R9, R10, R11, R12, table, invertCRC);
+      } else {
+        __ kernel_crc32_vpmsum(crc, data, dataLen, table, vector_constants, R7, R8, R9, R10, R11, R12, invertCRC);
+      }
 
       BLOCK_COMMENT("return");
       __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
       __ blr();
 

@@ -3495,46 +3491,24 @@
   address generate_CRC32_updateBytes(const char* name) {
     __ align(CodeEntryAlignment);
     StubCodeMark mark(this, "StubRoutines", name);
     address start = __ function_entry();  // Remember stub start address (is rtn value).
 
-    const Register table   = R6;       // crc table address
-
     // arguments to kernel_crc32:
     const Register crc     = R3_ARG1;  // Current checksum, preset by caller or result from previous call.
     const Register data    = R4_ARG2;  // source byte array
     const Register dataLen = R5_ARG3;  // #bytes to process
 
-    if (VM_Version::has_vpmsumb()) {
-      const Register constants    = R2;  // constants address
-      const Register bconstants   = R8;  // barret table address
-
-      const Register t0      = R9;
-      const Register t1      = R10;
-      const Register t2      = R11;
-      const Register t3      = R12;
-      const Register t4      = R7;
-
-      BLOCK_COMMENT("Stub body {");
-      assert_different_registers(crc, data, dataLen, table);
-
-      StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
-      StubRoutines::ppc64::generate_load_crc_constants_addr(_masm, constants);
-      StubRoutines::ppc64::generate_load_crc_barret_constants_addr(_masm, bconstants);
-
-      __ kernel_crc32_1word_vpmsum(crc, data, dataLen, table, constants, bconstants, t0, t1, t2, t3, t4, true);
-
-      BLOCK_COMMENT("return");
-      __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
-      __ blr();
+    const Register table   = R6;       // crc table address
+    Register vector_constants = noreg;
 
-      BLOCK_COMMENT("} Stub body");
-    } else {
       StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
-      generate_CRC_updateBytes(name, table, true);
+    if (VM_Version::has_vpmsumb()) {
+      vector_constants = R2;
+      StubRoutines::ppc64::generate_load_crc_constants_addr(_masm, vector_constants);
     }
-
+    generate_CRC_updateBytes(name, table, vector_constants, true);
     return start;
   }
 
 
   /**

@@ -3555,46 +3529,24 @@
   address generate_CRC32C_updateBytes(const char* name) {
     __ align(CodeEntryAlignment);
     StubCodeMark mark(this, "StubRoutines", name);
     address start = __ function_entry();  // Remember stub start address (is rtn value).
 
-    const Register table   = R6;       // crc table address
-
     // arguments to kernel_crc32:
     const Register crc     = R3_ARG1;  // Current checksum, preset by caller or result from previous call.
     const Register data    = R4_ARG2;  // source byte array
     const Register dataLen = R5_ARG3;  // #bytes to process
 
-    if (VM_Version::has_vpmsumb()) {
-      const Register constants    = R2;  // constants address
-      const Register bconstants   = R8;  // barret table address
-
-      const Register t0      = R9;
-      const Register t1      = R10;
-      const Register t2      = R11;
-      const Register t3      = R12;
-      const Register t4      = R7;
-
-      BLOCK_COMMENT("Stub body {");
-      assert_different_registers(crc, data, dataLen, table);
-
-      StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
-      StubRoutines::ppc64::generate_load_crc32c_constants_addr(_masm, constants);
-      StubRoutines::ppc64::generate_load_crc32c_barret_constants_addr(_masm, bconstants);
-
-      __ kernel_crc32_1word_vpmsum(crc, data, dataLen, table, constants, bconstants, t0, t1, t2, t3, t4, false);
-
-      BLOCK_COMMENT("return");
-      __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
-      __ blr();
+    const Register table   = R6;       // crc table address
+    Register vector_constants = noreg;
 
-      BLOCK_COMMENT("} Stub body");
-    } else {
       StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
-      generate_CRC_updateBytes(name, table, false);
+    if (VM_Version::has_vpmsumb()) {
+      vector_constants = R2;
+      StubRoutines::ppc64::generate_load_crc32c_constants_addr(_masm, vector_constants);
     }
-
+    generate_CRC_updateBytes(name, table, vector_constants, false);
     return start;
   }
 
 
   // Initialization
< prev index next >