8244955: Additional Fix for JDK-8240124

Wed, 23 Sep 2020 16:26:20 +0300

author
vkempik
date
Wed, 23 Sep 2020 16:26:20 +0300
changeset 10009
8adf45218add
parent 10008
fd3484fadbe3
child 10010
824065fb8b18

8244955: Additional Fix for JDK-8240124
Reviewed-by: mbalao, andrew

src/share/vm/classfile/altHashing.cpp file | annotate | diff | comparison | revisions
src/share/vm/classfile/altHashing.hpp file | annotate | diff | comparison | revisions
src/share/vm/classfile/symbolTable.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp file | annotate | diff | comparison | revisions
src/share/vm/memory/filemap.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/oop.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/symbol.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/classfile/altHashing.cpp	Wed Sep 23 15:18:53 2020 +0300
     1.2 +++ b/src/share/vm/classfile/altHashing.cpp	Wed Sep 23 16:26:20 2020 +0300
     1.3 @@ -115,6 +115,12 @@
     1.4    v[1] ^= 0xee;
     1.5  }
     1.6  
     1.7 +uint32_t halfsiphash_finish32(uint32_t v[4], int rounds) {
     1.8 +  v[2] ^= 0xff;
     1.9 +  halfsiphash_rounds(v, rounds);
    1.10 +  return (v[1] ^ v[3]);
    1.11 +}
    1.12 +
    1.13  static uint64_t halfsiphash_finish64(uint32_t v[4], int rounds) {
    1.14    uint64_t rv;
    1.15    v[2] ^= 0xee;
    1.16 @@ -126,14 +132,14 @@
    1.17    return rv;
    1.18  }
    1.19  
    1.20 -// HalfSipHash-2-4 (64-bit output) for Symbols
    1.21 -uint64_t AltHashing::halfsiphash_64(uint64_t seed, const int8_t* data, int len) {
    1.22 +// HalfSipHash-2-4 (32-bit output) for Symbols
    1.23 +uint32_t AltHashing::halfsiphash_32(uint64_t seed, const uint8_t* data, int len) {
    1.24    uint32_t v[4];
    1.25    uint32_t newdata;
    1.26    int off = 0;
    1.27    int count = len;
    1.28  
    1.29 -  halfsiphash_init64(v, seed);
    1.30 +  halfsiphash_init32(v, seed);
    1.31    // body
    1.32    while (count >= 4) {
    1.33      // Avoid sign extension with 0x0ff
    1.34 @@ -168,17 +174,17 @@
    1.35    halfsiphash_adddata(v, newdata, 2);
    1.36  
    1.37    // finalization
    1.38 -  return halfsiphash_finish64(v, 4);
    1.39 +  return halfsiphash_finish32(v, 4);
    1.40  }
    1.41  
    1.42 -// HalfSipHash-2-4 (64-bit output) for Strings
    1.43 -uint64_t AltHashing::halfsiphash_64(uint64_t seed, const uint16_t* data, int len) {
    1.44 +// HalfSipHash-2-4 (32-bit output) for Strings
    1.45 +uint32_t AltHashing::halfsiphash_32(uint64_t seed, const uint16_t* data, int len) {
    1.46    uint32_t v[4];
    1.47    uint32_t newdata;
    1.48    int off = 0;
    1.49    int count = len;
    1.50  
    1.51 -  halfsiphash_init64(v, seed);
    1.52 +  halfsiphash_init32(v, seed);
    1.53  
    1.54    // body
    1.55    while (count >= 2) {
    1.56 @@ -199,7 +205,7 @@
    1.57    halfsiphash_adddata(v, newdata, 2);
    1.58  
    1.59    // finalization
    1.60 -  return halfsiphash_finish64(v, 4);
    1.61 +  return halfsiphash_finish32(v, 4);
    1.62  }
    1.63  
    1.64  // HalfSipHash-2-4 (64-bit output) for integers (used to create seed)
    1.65 @@ -229,44 +235,44 @@
    1.66  }
    1.67  
    1.68  #ifndef PRODUCT
    1.69 -  void AltHashing::testHalfsiphash_64_ByteArray() {
    1.70 -    // printf("testHalfsiphash_64_CharArray\n");
    1.71 +  void AltHashing::testHalfsiphash_32_ByteArray() {
    1.72      const int factor = 4;
    1.73  
    1.74 -    int8_t vector[256];
    1.75 -    int8_t hashes[factor * 256];
    1.76 +    uint8_t vector[256];
    1.77 +    uint8_t hashes[factor * 256];
    1.78  
    1.79      for (int i = 0; i < 256; i++) {
    1.80 -      vector[i] = (int8_t) i;
    1.81 +      vector[i] = (uint8_t) i;
    1.82      }
    1.83  
    1.84      // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255}
    1.85      for (int i = 0; i < 256; i++) {
    1.86 -      uint64_t hash = AltHashing::halfsiphash_64(256 - i, vector, i);
    1.87 -      hashes[i * factor] = (int8_t) hash;
    1.88 -      hashes[i * factor + 1] = (int8_t)(hash >> 8);
    1.89 -      hashes[i * factor + 2] = (int8_t)(hash >> 16);
    1.90 -      hashes[i * factor + 3] = (int8_t)(hash >> 24);
    1.91 +      uint32_t hash = AltHashing::halfsiphash_32(256 - i, vector, i);
    1.92 +      hashes[i * factor] = (uint8_t) hash;
    1.93 +      hashes[i * factor + 1] = (uint8_t)(hash >> 8);
    1.94 +      hashes[i * factor + 2] = (uint8_t)(hash >> 16);
    1.95 +      hashes[i * factor + 3] = (uint8_t)(hash >> 24);
    1.96      }
    1.97  
    1.98      // hash to get const result.
    1.99 -    uint64_t final_hash = AltHashing::halfsiphash_64(0, hashes, factor*256);
   1.100 +    uint32_t final_hash = AltHashing::halfsiphash_32(0, hashes, factor*256);
   1.101  
   1.102      // Value found using reference implementation for the hashes array.
   1.103 -    // halfsiphash((const uint8_t*)hashes, factor*256, (const uint8_t *)&k,
   1.104 -    //             (uint8_t*)&reference, 8);
   1.105 +    //uint64_t k = 0;  // seed
   1.106 +    //uint32_t reference;
   1.107 +    //halfsiphash((const uint8_t*)hashes, factor*256, (const uint8_t *)&k, (uint8_t*)&reference, 4);
   1.108 +    //printf("0x%x", reference);
   1.109  
   1.110 -    static const uint64_t HALFSIPHASH_64_BYTE_CHECK_VALUE = 0x15a7911e30917ee8;
   1.111 +    static const uint32_t HALFSIPHASH_32_BYTE_CHECK_VALUE = 0xd2be7fd8;
   1.112  
   1.113 -    assert (HALFSIPHASH_64_BYTE_CHECK_VALUE == final_hash,
   1.114 +    assert (HALFSIPHASH_32_BYTE_CHECK_VALUE == final_hash,
   1.115        err_msg(
   1.116 -          "Calculated hash result not as expected. Expected " UINT64_FORMAT " got " UINT64_FORMAT,
   1.117 -          HALFSIPHASH_64_BYTE_CHECK_VALUE,
   1.118 +          "Calculated hash result not as expected. Expected " UINT32_FORMAT " got " UINT32_FORMAT,
   1.119 +          HALFSIPHASH_32_BYTE_CHECK_VALUE,
   1.120            final_hash));
   1.121    }
   1.122  
   1.123 -  void AltHashing::testHalfsiphash_64_CharArray() {
   1.124 -    // printf("testHalfsiphash_64_CharArray\n");
   1.125 +  void AltHashing::testHalfsiphash_32_CharArray() {
   1.126      const int factor = 2;
   1.127  
   1.128      uint16_t vector[256];
   1.129 @@ -278,30 +284,32 @@
   1.130  
   1.131      // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255}
   1.132      for (int i = 0; i < 256; i++) {
   1.133 -      uint64_t hash = AltHashing::halfsiphash_64(256 - i, vector, i);
   1.134 +      uint32_t hash = AltHashing::halfsiphash_32(256 - i, vector, i);
   1.135        hashes[i * factor] = (uint16_t) hash;
   1.136        hashes[i * factor + 1] = (uint16_t)(hash >> 16);
   1.137      }
   1.138  
   1.139      // hash to get const result.
   1.140 -    uint64_t final_hash = AltHashing::halfsiphash_64(0, hashes, factor*256);
   1.141 +    uint32_t final_hash = AltHashing::halfsiphash_32(0, hashes, factor*256);
   1.142  
   1.143      // Value found using reference implementation for the hashes array.
   1.144 -    // halfsiphash((const uint8_t*)hashes, 2*factor*256, (const uint8_t *)&k,
   1.145 -    //             (uint8_t*)&reference, 8);
   1.146 -    static const uint64_t HALFSIPHASH_64_CHAR_CHECK_VALUE = 0xf392d8a6a9e24103;
   1.147 +    //uint64_t k = 0;  // seed
   1.148 +    //uint32_t reference;
   1.149 +    //halfsiphash((const uint8_t*)hashes, 2*factor*256, (const uint8_t *)&k, (uint8_t*)&reference, 4);
   1.150 +    //printf("0x%x", reference);
   1.151  
   1.152 -    assert(HALFSIPHASH_64_CHAR_CHECK_VALUE == final_hash,
   1.153 +    static const uint32_t HALFSIPHASH_32_CHAR_CHECK_VALUE = 0x428bf8a5;
   1.154 +
   1.155 +    assert(HALFSIPHASH_32_CHAR_CHECK_VALUE == final_hash,
   1.156        err_msg(
   1.157 -          "Calculated hash result not as expected. Expected " UINT64_FORMAT " got " UINT64_FORMAT,
   1.158 -          HALFSIPHASH_64_CHAR_CHECK_VALUE,
   1.159 +          "Calculated hash result not as expected. Expected " UINT32_FORMAT " got " UINT32_FORMAT,
   1.160 +          HALFSIPHASH_32_CHAR_CHECK_VALUE,
   1.161            final_hash));
   1.162    }
   1.163  
   1.164    // Test against sample hashes published with the reference implementation:
   1.165    // https://github.com/veorq/SipHash
   1.166    void AltHashing::testHalfsiphash_64_FromReference() {
   1.167 -    // printf("testHalfsiphash_64_FromReference\n");
   1.168  
   1.169      const uint64_t seed = 0x0706050403020100;
   1.170      const uint64_t results[16] = {
   1.171 @@ -332,8 +340,8 @@
   1.172    }
   1.173  
   1.174  void AltHashing::test_alt_hash() {
   1.175 -  testHalfsiphash_64_ByteArray();
   1.176 -  testHalfsiphash_64_CharArray();
   1.177 +  testHalfsiphash_32_ByteArray();
   1.178 +  testHalfsiphash_32_CharArray();
   1.179    testHalfsiphash_64_FromReference();
   1.180  }
   1.181  #endif // PRODUCT
     2.1 --- a/src/share/vm/classfile/altHashing.hpp	Wed Sep 23 15:18:53 2020 +0300
     2.2 +++ b/src/share/vm/classfile/altHashing.hpp	Wed Sep 23 16:26:20 2020 +0300
     2.3 @@ -39,17 +39,17 @@
     2.4    static uint64_t halfsiphash_64(uint64_t seed, const uint32_t* data, int len);
     2.5   #ifndef PRODUCT
     2.6     // Hashing functions used for internal testing
     2.7 -  static void testHalfsiphash_64_ByteArray();
     2.8 -  static void testHalfsiphash_64_CharArray();
     2.9 +  static void testHalfsiphash_32_ByteArray();
    2.10 +  static void testHalfsiphash_32_CharArray();
    2.11    static void testHalfsiphash_64_FromReference();
    2.12   #endif // PRODUCT
    2.13   public:
    2.14    static uint64_t compute_seed();
    2.15  
    2.16    // For Symbols
    2.17 -  static uint64_t halfsiphash_64(uint64_t seed, const int8_t* data, int len);
    2.18 +  static uint32_t halfsiphash_32(uint64_t seed, const uint8_t* data, int len);
    2.19    // For Strings
    2.20 -  static uint64_t halfsiphash_64(uint64_t seed, const uint16_t* data, int len);
    2.21 +  static uint32_t halfsiphash_32(uint64_t seed, const uint16_t* data, int len);
    2.22    NOT_PRODUCT(static void test_alt_hash();)
    2.23  };
    2.24  #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP
     3.1 --- a/src/share/vm/classfile/symbolTable.cpp	Wed Sep 23 15:18:53 2020 +0300
     3.2 +++ b/src/share/vm/classfile/symbolTable.cpp	Wed Sep 23 16:26:20 2020 +0300
     3.3 @@ -224,7 +224,7 @@
     3.4  // Pick hashing algorithm.
     3.5  unsigned int SymbolTable::hash_symbol(const char* s, int len) {
     3.6    return use_alternate_hashcode() ?
     3.7 -           AltHashing::halfsiphash_64(seed(), (const int8_t*)s, len) :
     3.8 +           AltHashing::halfsiphash_32(seed(), (const uint8_t*)s, len) :
     3.9             java_lang_String::hash_code(s, len);
    3.10  }
    3.11  
    3.12 @@ -650,7 +650,7 @@
    3.13  
    3.14  // Pick hashing algorithm
    3.15  unsigned int StringTable::hash_string(const jchar* s, int len) {
    3.16 -  return use_alternate_hashcode() ? AltHashing::halfsiphash_64(seed(), s, len) :
    3.17 +  return use_alternate_hashcode() ? AltHashing::halfsiphash_32(seed(), s, len) :
    3.18                                      java_lang_String::hash_code(s, len);
    3.19  }
    3.20  
     4.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp	Wed Sep 23 15:18:53 2020 +0300
     4.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp	Wed Sep 23 16:26:20 2020 +0300
     4.3 @@ -150,7 +150,7 @@
     4.4    assert(worker_id < _nlists, "Invalid worker id");
     4.5  
     4.6    entry->set_obj(NULL);
     4.7 -  entry->set_java_hash(0);
     4.8 +  entry->set_hash(0);
     4.9  
    4.10    if (_cached[worker_id].length() < _max_list_length) {
    4.11      // Cache is not full
    4.12 @@ -237,14 +237,10 @@
    4.13    _table = new G1StringDedupTable(_min_size);
    4.14  }
    4.15  
    4.16 -void G1StringDedupTable::add(typeArrayOop value, uint64_t hash, G1StringDedupEntry** list) {
    4.17 +void G1StringDedupTable::add(typeArrayOop value, unsigned int hash, G1StringDedupEntry** list) {
    4.18    G1StringDedupEntry* entry = _entry_cache->alloc();
    4.19    entry->set_obj(value);
    4.20 -  if (use_java_hash()) {
    4.21 -    entry->set_java_hash((unsigned int)hash);
    4.22 -  } else {
    4.23 -    entry->set_alt_hash(hash);
    4.24 -  }
    4.25 +  entry->set_hash(hash);
    4.26    entry->set_next(*list);
    4.27    *list = entry;
    4.28    _entries++;
    4.29 @@ -259,7 +255,7 @@
    4.30  void G1StringDedupTable::transfer(G1StringDedupEntry** pentry, G1StringDedupTable* dest) {
    4.31    G1StringDedupEntry* entry = *pentry;
    4.32    *pentry = entry->next();
    4.33 -  uint64_t hash = use_java_hash() ? entry->java_hash() : entry->alt_hash();
    4.34 +  unsigned int hash = entry->hash();
    4.35    size_t index = dest->hash_to_index(hash);
    4.36    G1StringDedupEntry** list = dest->bucket(index);
    4.37    entry->set_next(*list);
    4.38 @@ -274,10 +270,10 @@
    4.39                      value1->length() * sizeof(jchar)))));
    4.40  }
    4.41  
    4.42 -typeArrayOop G1StringDedupTable::lookup(typeArrayOop value, uint64_t hash,
    4.43 +typeArrayOop G1StringDedupTable::lookup(typeArrayOop value, unsigned int hash,
    4.44                                          G1StringDedupEntry** list, uintx &count) {
    4.45    for (G1StringDedupEntry* entry = *list; entry != NULL; entry = entry->next()) {
    4.46 -    if ((use_java_hash() ? entry->java_hash() : entry->alt_hash()) == hash) {
    4.47 +    if (entry->hash() == hash) {
    4.48        typeArrayOop existing_value = entry->obj();
    4.49        if (equals(value, existing_value)) {
    4.50          // Match found
    4.51 @@ -291,7 +287,7 @@
    4.52    return NULL;
    4.53  }
    4.54  
    4.55 -typeArrayOop G1StringDedupTable::lookup_or_add_inner(typeArrayOop value, uint64_t hash) {
    4.56 +typeArrayOop G1StringDedupTable::lookup_or_add_inner(typeArrayOop value, unsigned int hash) {
    4.57    size_t index = hash_to_index(hash);
    4.58    G1StringDedupEntry** list = bucket(index);
    4.59    uintx count = 0;
    4.60 @@ -315,25 +311,19 @@
    4.61    return existing_value;
    4.62  }
    4.63  
    4.64 -unsigned int G1StringDedupTable::java_hash_code(typeArrayOop value) {
    4.65 -  assert(use_java_hash(), "Should not use java hash code");
    4.66 +unsigned int G1StringDedupTable::hash_code(typeArrayOop value) {
    4.67    unsigned int hash;
    4.68    int length = value->length();
    4.69    const jchar* data = (jchar*)value->base(T_CHAR);
    4.70  
    4.71 -  hash = java_lang_String::hash_code(data, length);
    4.72 -
    4.73 +  if (use_java_hash()) {
    4.74 +    hash = java_lang_String::hash_code(data, length);
    4.75 +  } else {
    4.76 +    hash = AltHashing::halfsiphash_32(_table->_hash_seed, (const uint16_t*)data, length);
    4.77 +  }
    4.78    return hash;
    4.79  }
    4.80  
    4.81 -uint64_t G1StringDedupTable::alt_hash_code(typeArrayOop value) {
    4.82 -  assert(!use_java_hash(), "Should not use alt hash code");
    4.83 -
    4.84 -  int length = value->length();
    4.85 -  const jbyte* data = (jbyte*)value->base(T_BYTE);
    4.86 -  return AltHashing::halfsiphash_64(_table->_hash_seed, (const int8_t*)data, length);
    4.87 -}
    4.88 -
    4.89  void G1StringDedupTable::deduplicate(oop java_string, G1StringDedupStat& stat) {
    4.90    assert(java_lang_String::is_instance(java_string), "Must be a string");
    4.91    No_Safepoint_Verifier nsv;
    4.92 @@ -347,7 +337,7 @@
    4.93      return;
    4.94    }
    4.95  
    4.96 -  uint64_t hash = 0;
    4.97 +  unsigned int hash = 0;
    4.98  
    4.99    if (use_java_hash()) {
   4.100      // Get hash code from cache
   4.101 @@ -356,7 +346,7 @@
   4.102  
   4.103    if (hash == 0) {
   4.104      // Compute hash
   4.105 -    hash = alt_hash_code(value);
   4.106 +    hash = hash_code(value);
   4.107      stat.inc_hashed();
   4.108    }
   4.109  
   4.110 @@ -510,9 +500,8 @@
   4.111              // destination partitions. finish_rehash() will do a single
   4.112              // threaded transfer of all entries.
   4.113              typeArrayOop value = (typeArrayOop)*p;
   4.114 -            assert(!use_java_hash(), "Should not be using Java hash");
   4.115 -            uint64_t hash = alt_hash_code(value);
   4.116 -            (*entry)->set_alt_hash(hash);
   4.117 +            unsigned int hash = hash_code(value);
   4.118 +            (*entry)->set_hash(hash);
   4.119            }
   4.120  
   4.121            // Move to next entry
   4.122 @@ -575,14 +564,8 @@
   4.123        guarantee(Universe::heap()->is_in_reserved(value), "Object must be on the heap");
   4.124        guarantee(!value->is_forwarded(), "Object must not be forwarded");
   4.125        guarantee(value->is_typeArray(), "Object must be a typeArrayOop");
   4.126 -      uint64_t hash;
   4.127 -      if (use_java_hash()) {
   4.128 -        hash = (*entry)->java_hash();
   4.129 -        guarantee(java_hash_code(value) == hash, "Table entry has incorrect hash");
   4.130 -      } else {
   4.131 -        hash = (*entry)->alt_hash();
   4.132 -        guarantee(alt_hash_code(value) == hash, "Table entry has incorrect hash");
   4.133 -      }
   4.134 +      unsigned int hash = hash_code(value);
   4.135 +      guarantee((*entry)->hash() == hash, "Table entry has inorrect hash");
   4.136        guarantee(_table->hash_to_index(hash) == bucket, "Table entry has incorrect index");
   4.137        entry = (*entry)->next_addr();
   4.138      }
   4.139 @@ -597,10 +580,7 @@
   4.140        G1StringDedupEntry** entry2 = (*entry1)->next_addr();
   4.141        while (*entry2 != NULL) {
   4.142          typeArrayOop value2 = (*entry2)->obj();
   4.143 -        guarantee(value1 != value2, "Table entries must not have the same array");
   4.144 -        if (use_java_hash()) {
   4.145 -          guarantee(!equals(value1, value2), "Table entries must not have identical arrays");
   4.146 -        }
   4.147 +        guarantee(!equals(value1, value2), "Table entries must not have identical arrays");
   4.148          entry2 = (*entry2)->next_addr();
   4.149        }
   4.150        entry1 = (*entry1)->next_addr();
   4.151 @@ -619,7 +599,7 @@
   4.152      "      [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]\n"
   4.153      "      [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]\n"
   4.154      "      [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]\n"
   4.155 -    "      [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: " UINT64_FORMAT_X "]\n"
   4.156 +    "      [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: " UINT64_FORMAT "]\n"
   4.157      "      [Age Threshold: " UINTX_FORMAT "]",
   4.158      G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
   4.159      _table->_size, _min_size, _max_size,
     5.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp	Wed Sep 23 15:18:53 2020 +0300
     5.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp	Wed Sep 23 16:26:20 2020 +0300
     5.3 @@ -38,11 +38,9 @@
     5.4  class G1StringDedupEntry : public CHeapObj<mtGC> {
     5.5  private:
     5.6    G1StringDedupEntry* _next;
     5.7 -  uint64_t            _hash;
     5.8 +  unsigned int        _hash;
     5.9    typeArrayOop        _obj;
    5.10  
    5.11 -  static const uint64_t java_hash_mask = ((uint64_t)1 << 32) - 1;
    5.12 -
    5.13  public:
    5.14    G1StringDedupEntry() :
    5.15      _next(NULL),
    5.16 @@ -62,19 +60,11 @@
    5.17      _next = next;
    5.18    }
    5.19  
    5.20 -  unsigned int java_hash() {
    5.21 -    return (unsigned int)(_hash & java_hash_mask);
    5.22 -  }
    5.23 -
    5.24 -  void set_java_hash(unsigned int hash) {
    5.25 -    _hash = hash;
    5.26 -  }
    5.27 -
    5.28 -  uint64_t alt_hash() {
    5.29 +  unsigned int hash() {
    5.30      return _hash;
    5.31    }
    5.32  
    5.33 -  void set_alt_hash(uint64_t hash) {
    5.34 +  void set_hash(unsigned int hash) {
    5.35      _hash = hash;
    5.36    }
    5.37  
    5.38 @@ -129,7 +119,7 @@
    5.39    // The hash seed also dictates which hash function to use. A
    5.40    // zero hash seed means we will use the Java compatible hash
    5.41    // function (which doesn't use a seed), and a non-zero hash
    5.42 -  // seed means we use the alternate and better hash function.
    5.43 +  // seed means we use the murmur3 and better hash function.
    5.44    uint64_t                        _hash_seed;
    5.45  
    5.46    // Constants governing table resize/rehash/cache.
    5.47 @@ -156,12 +146,12 @@
    5.48    }
    5.49  
    5.50    // Returns the hash bucket index for the given hash code.
    5.51 -  size_t hash_to_index(uint64_t hash) {
    5.52 +  size_t hash_to_index(unsigned int hash) {
    5.53      return (size_t)hash & (_size - 1);
    5.54    }
    5.55  
    5.56    // Adds a new table entry to the given hash bucket.
    5.57 -  void add(typeArrayOop value, uint64_t hash, G1StringDedupEntry** list);
    5.58 +  void add(typeArrayOop value, unsigned int hash, G1StringDedupEntry** list);
    5.59  
    5.60    // Removes the given table entry from the table.
    5.61    void remove(G1StringDedupEntry** pentry, uint worker_id);
    5.62 @@ -171,15 +161,15 @@
    5.63  
    5.64    // Returns an existing character array in the given hash bucket, or NULL
    5.65    // if no matching character array exists.
    5.66 -  typeArrayOop lookup(typeArrayOop value, uint64_t hash,
    5.67 +  typeArrayOop lookup(typeArrayOop value, unsigned int hash,
    5.68                        G1StringDedupEntry** list, uintx &count);
    5.69  
    5.70    // Returns an existing character array in the table, or inserts a new
    5.71    // table entry if no matching character array exists.
    5.72 -  typeArrayOop lookup_or_add_inner(typeArrayOop value, uint64_t hash);
    5.73 +  typeArrayOop lookup_or_add_inner(typeArrayOop value, unsigned int hash);
    5.74  
    5.75    // Thread safe lookup or add of table entry
    5.76 -  static typeArrayOop lookup_or_add(typeArrayOop value, uint64_t hash) {
    5.77 +  static typeArrayOop lookup_or_add(typeArrayOop value, unsigned int hash) {
    5.78      // Protect the table from concurrent access. Also note that this lock
    5.79      // acts as a fence for _table, which could have been replaced by a new
    5.80      // instance if the table was resized or rehashed.
    5.81 @@ -197,8 +187,7 @@
    5.82  
    5.83    // Computes the hash code for the given character array, using the
    5.84    // currently active hash function and hash seed.
    5.85 -  static unsigned int java_hash_code(typeArrayOop value);
    5.86 -  static uint64_t alt_hash_code(typeArrayOop value);
    5.87 +  static unsigned int hash_code(typeArrayOop value);
    5.88  
    5.89    static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl,
    5.90                                   size_t partition_begin,
     6.1 --- a/src/share/vm/memory/filemap.cpp	Wed Sep 23 15:18:53 2020 +0300
     6.2 +++ b/src/share/vm/memory/filemap.cpp	Wed Sep 23 16:26:20 2020 +0300
     6.3 @@ -125,13 +125,13 @@
     6.4    } else {
     6.5      // Get the hash value.  Use a static seed because the hash needs to return the same
     6.6      // value over multiple jvm invocations.
     6.7 -    uint64_t hash = AltHashing::halfsiphash_64(8191, (const int8_t*)vm_version, version_len);
     6.8 +    uint32_t hash = AltHashing::halfsiphash_32(8191, (const uint8_t*)vm_version, version_len);
     6.9  
    6.10 -    // Truncate the ident, saving room for the 16 hex character hash value.
    6.11 -    strncpy(header_version, vm_version, JVM_IDENT_MAX-17);
    6.12 +    // Truncate the ident, saving room for the 8 hex character hash value.
    6.13 +    strncpy(header_version, vm_version, JVM_IDENT_MAX-9);
    6.14  
    6.15 -    // Append the hash code as 16 hex digits.
    6.16 -    sprintf(&header_version[JVM_IDENT_MAX-17], "%016" PRIx64, hash);
    6.17 +    // Append the hash code as eight hex digits.
    6.18 +    sprintf(&header_version[JVM_IDENT_MAX-9], "%08x", hash);
    6.19      header_version[JVM_IDENT_MAX-1] = 0;  // Null terminate.
    6.20    }
    6.21  }
     7.1 --- a/src/share/vm/oops/oop.cpp	Wed Sep 23 15:18:53 2020 +0300
     7.2 +++ b/src/share/vm/oops/oop.cpp	Wed Sep 23 16:26:20 2020 +0300
     7.3 @@ -111,7 +111,7 @@
     7.4    jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD);
     7.5    if (chars != NULL) {
     7.6      // Use alternate hashing algorithm on the string
     7.7 -    return AltHashing::halfsiphash_64(seed, chars, length);
     7.8 +    return AltHashing::halfsiphash_32(seed, chars, length);
     7.9    } else {
    7.10      vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash");
    7.11      return 0;
     8.1 --- a/src/share/vm/oops/symbol.cpp	Wed Sep 23 15:18:53 2020 +0300
     8.2 +++ b/src/share/vm/oops/symbol.cpp	Wed Sep 23 16:26:20 2020 +0300
     8.3 @@ -210,7 +210,7 @@
     8.4  unsigned int Symbol::new_hash(juint seed) {
     8.5    ResourceMark rm;
     8.6    // Use alternate hashing algorithm on this symbol.
     8.7 -  return AltHashing::halfsiphash_64(seed, (const int8_t*)as_C_string(), utf8_length());
     8.8 +  return AltHashing::halfsiphash_32(seed, (const uint8_t*)as_C_string(), utf8_length());
     8.9  }
    8.10  
    8.11  void Symbol::increment_refcount() {

mercurial