src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
changeset 53408 e17d7ffad9e3
parent 53281 672b629e1f72
child 53483 60add902a57a
--- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp	Sun Jan 20 12:20:37 2019 -0500
+++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp	Mon Jan 21 09:44:27 2019 +0100
@@ -1,6 +1,6 @@
 /*
- * 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
@@ -3186,35 +3186,6 @@
     return start;
   }
 
-
-  // Compute CRC32/CRC32C function.
-  void generate_CRC_updateBytes(const char* name, Register table, 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);
-
-      BLOCK_COMMENT("return");
-      __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
-      __ blr();
-
-      BLOCK_COMMENT("} Stub body");
-  }
-
   /**
   *  Arguments:
   *
@@ -3492,111 +3463,15 @@
    *   R3_RET     - int   crc result
    */
   // Compute CRC32 function.
-  address generate_CRC32_updateBytes(const char* name) {
+  address generate_CRC32_updateBytes(bool is_crc32c) {
     __ align(CodeEntryAlignment);
-    StubCodeMark mark(this, "StubRoutines", name);
+    StubCodeMark mark(this, "StubRoutines", is_crc32c ? "CRC32C_updateBytes" : "CRC32_updateBytes");
     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();
-
-      BLOCK_COMMENT("} Stub body");
-    } else {
-      StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
-      generate_CRC_updateBytes(name, table, true);
-    }
-
+    __ crc32(R3_ARG1, R4_ARG2, R5_ARG3, R2, R6, R7, R8, R9, R10, R11, R12, is_crc32c);
+    __ blr();
     return start;
   }
 
-
-  /**
-   * Arguments:
-   *
-   * Inputs:
-   *   R3_ARG1    - int   crc
-   *   R4_ARG2    - byte* buf
-   *   R5_ARG3    - int   length (of buffer)
-   *
-   * scratch:
-   *   R2, R6-R12
-   *
-   * Ouput:
-   *   R3_RET     - int   crc result
-   */
-  // Compute CRC32C function.
-  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();
-
-      BLOCK_COMMENT("} Stub body");
-    } else {
-      StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
-      generate_CRC_updateBytes(name, table, false);
-    }
-
-    return start;
-  }
-
-
   // Initialization
   void generate_initial() {
     // Generates all stubs and initializes the entry points
@@ -3621,14 +3496,20 @@
 
     // CRC32 Intrinsics.
     if (UseCRC32Intrinsics) {
-      StubRoutines::_crc_table_adr    = (address)StubRoutines::ppc64::_crc_table;
-      StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes("CRC32_updateBytes");
+      StubRoutines::_crc_table_adr = (address)StubRoutines::ppc64::_crc_table;
+      if (VM_Version::has_vpmsumb()) {
+        StubRoutines::ppc64::_crc_constants = StubRoutines::ppc64::generate_crc_constants(REVERSE_CRC32_POLY);
+      }
+      StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes(false);
     }
 
     // CRC32C Intrinsics.
     if (UseCRC32CIntrinsics) {
       StubRoutines::_crc32c_table_addr = (address)StubRoutines::ppc64::_crc32c_table;
-      StubRoutines::_updateBytesCRC32C = generate_CRC32C_updateBytes("CRC32C_updateBytes");
+      if (VM_Version::has_vpmsumb()) {
+        StubRoutines::ppc64::_crc32c_constants = StubRoutines::ppc64::generate_crc_constants(REVERSE_CRC32C_POLY);
+      }
+      StubRoutines::_updateBytesCRC32C = generate_CRC32_updateBytes(true);
     }
   }