1.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp Sat Sep 12 00:09:03 2020 +0300 1.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp Wed Sep 23 15:18:53 2020 +0300 1.3 @@ -38,8 +38,10 @@ 1.4 class G1StringDedupEntry : public CHeapObj<mtGC> { 1.5 private: 1.6 G1StringDedupEntry* _next; 1.7 - unsigned int _hash; 1.8 - typeArrayOop _obj; 1.9 + uint64_t _hash; 1.10 + typeArrayOop _obj; 1.11 + 1.12 + static const uint64_t java_hash_mask = ((uint64_t)1 << 32) - 1; 1.13 1.14 public: 1.15 G1StringDedupEntry() : 1.16 @@ -60,11 +62,19 @@ 1.17 _next = next; 1.18 } 1.19 1.20 - unsigned int hash() { 1.21 + unsigned int java_hash() { 1.22 + return (unsigned int)(_hash & java_hash_mask); 1.23 + } 1.24 + 1.25 + void set_java_hash(unsigned int hash) { 1.26 + _hash = hash; 1.27 + } 1.28 + 1.29 + uint64_t alt_hash() { 1.30 return _hash; 1.31 } 1.32 1.33 - void set_hash(unsigned int hash) { 1.34 + void set_alt_hash(uint64_t hash) { 1.35 _hash = hash; 1.36 } 1.37 1.38 @@ -119,8 +129,8 @@ 1.39 // The hash seed also dictates which hash function to use. A 1.40 // zero hash seed means we will use the Java compatible hash 1.41 // function (which doesn't use a seed), and a non-zero hash 1.42 - // seed means we use the murmur3 hash function. 1.43 - jint _hash_seed; 1.44 + // seed means we use the alternate and better hash function. 1.45 + uint64_t _hash_seed; 1.46 1.47 // Constants governing table resize/rehash/cache. 1.48 static const size_t _min_size; 1.49 @@ -137,7 +147,7 @@ 1.50 static uintx _resize_count; 1.51 static uintx _rehash_count; 1.52 1.53 - G1StringDedupTable(size_t size, jint hash_seed = 0); 1.54 + G1StringDedupTable(size_t size, uint64_t hash_seed = 0); 1.55 ~G1StringDedupTable(); 1.56 1.57 // Returns the hash bucket at the given index. 1.58 @@ -146,12 +156,12 @@ 1.59 } 1.60 1.61 // Returns the hash bucket index for the given hash code. 1.62 - size_t hash_to_index(unsigned int hash) { 1.63 + size_t hash_to_index(uint64_t hash) { 1.64 return (size_t)hash & (_size - 1); 1.65 } 1.66 1.67 // Adds a new table entry to the given hash bucket. 1.68 - void add(typeArrayOop value, unsigned int hash, G1StringDedupEntry** list); 1.69 + void add(typeArrayOop value, uint64_t hash, G1StringDedupEntry** list); 1.70 1.71 // Removes the given table entry from the table. 1.72 void remove(G1StringDedupEntry** pentry, uint worker_id); 1.73 @@ -161,15 +171,15 @@ 1.74 1.75 // Returns an existing character array in the given hash bucket, or NULL 1.76 // if no matching character array exists. 1.77 - typeArrayOop lookup(typeArrayOop value, unsigned int hash, 1.78 + typeArrayOop lookup(typeArrayOop value, uint64_t hash, 1.79 G1StringDedupEntry** list, uintx &count); 1.80 1.81 // Returns an existing character array in the table, or inserts a new 1.82 // table entry if no matching character array exists. 1.83 - typeArrayOop lookup_or_add_inner(typeArrayOop value, unsigned int hash); 1.84 + typeArrayOop lookup_or_add_inner(typeArrayOop value, uint64_t hash); 1.85 1.86 // Thread safe lookup or add of table entry 1.87 - static typeArrayOop lookup_or_add(typeArrayOop value, unsigned int hash) { 1.88 + static typeArrayOop lookup_or_add(typeArrayOop value, uint64_t hash) { 1.89 // Protect the table from concurrent access. Also note that this lock 1.90 // acts as a fence for _table, which could have been replaced by a new 1.91 // instance if the table was resized or rehashed. 1.92 @@ -187,7 +197,8 @@ 1.93 1.94 // Computes the hash code for the given character array, using the 1.95 // currently active hash function and hash seed. 1.96 - static unsigned int hash_code(typeArrayOop value); 1.97 + static unsigned int java_hash_code(typeArrayOop value); 1.98 + static uint64_t alt_hash_code(typeArrayOop value); 1.99 1.100 static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl, 1.101 size_t partition_begin,