hotspot/src/share/vm/gc/g1/g1StringDedupTable.hpp
author tschatzl
Wed, 25 Nov 2015 14:43:29 +0100
changeset 34300 6075c1e0e913
parent 33628 09241459a8b8
child 35061 be6025ebffea
permissions -rw-r--r--
8136679: JFR event for adaptive IHOP Reviewed-by: tbenson, mgerdin, sangheki, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     4
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     8
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    13
 * accompanied this code).
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    14
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    18
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    21
 * questions.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    22
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    23
 */
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1STRINGDEDUPTABLE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    26
#define SHARE_VM_GC_G1_G1STRINGDEDUPTABLE_HPP
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
    28
#include "gc/g1/g1StringDedupStat.hpp"
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    29
#include "runtime/mutexLocker.hpp"
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    30
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    31
class G1StringDedupEntryCache;
30175
543725014c9d 8076457: Fix includes of inline.hpp in GC code
stefank
parents: 23472
diff changeset
    32
class G1StringDedupUnlinkOrOopsDoClosure;
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    33
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    34
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    35
// Table entry in the deduplication hashtable. Points weakly to the
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    36
// character array. Can be chained in a linked list in case of hash
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    37
// collisions or when placed in a freelist in the entry cache.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    38
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    39
class G1StringDedupEntry : public CHeapObj<mtGC> {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    40
private:
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    41
  G1StringDedupEntry* _next;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    42
  unsigned int      _hash;
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    43
  bool              _latin1;
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    44
  typeArrayOop      _obj;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    45
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    46
public:
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    47
  G1StringDedupEntry() :
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    48
    _next(NULL),
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    49
    _hash(0),
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    50
    _latin1(false),
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    51
    _obj(NULL) {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    52
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    53
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    54
  G1StringDedupEntry* next() {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    55
    return _next;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    56
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    57
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    58
  G1StringDedupEntry** next_addr() {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    59
    return &_next;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    60
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    61
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    62
  void set_next(G1StringDedupEntry* next) {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    63
    _next = next;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    64
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    65
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    66
  unsigned int hash() {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    67
    return _hash;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    68
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    69
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    70
  void set_hash(unsigned int hash) {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    71
    _hash = hash;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    72
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    73
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    74
  bool latin1() {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    75
    return _latin1;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    76
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    77
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    78
  void set_latin1(bool latin1) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    79
    _latin1 = latin1;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    80
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
    81
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    82
  typeArrayOop obj() {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    83
    return _obj;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    84
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    85
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    86
  typeArrayOop* obj_addr() {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    87
    return &_obj;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    88
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    89
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    90
  void set_obj(typeArrayOop obj) {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    91
    _obj = obj;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    92
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    93
};
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    94
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    95
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    96
// The deduplication hashtable keeps track of all unique character arrays used
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    97
// by String objects. Each table entry weakly points to an character array, allowing
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    98
// otherwise unreachable character arrays to be declared dead and pruned from the
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    99
// table.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   100
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   101
// The table is dynamically resized to accommodate the current number of table entries.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   102
// The table has hash buckets with chains for hash collision. If the average chain
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   103
// length goes above or below given thresholds the table grows or shrinks accordingly.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   104
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   105
// The table is also dynamically rehashed (using a new hash seed) if it becomes severely
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   106
// unbalanced, i.e., a hash chain is significantly longer than average.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   107
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   108
// All access to the table is protected by the StringDedupTable_lock, except under
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   109
// safepoints in which case GC workers are allowed to access a table partitions they
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   110
// have claimed without first acquiring the lock. Note however, that this applies only
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   111
// the table partition (i.e. a range of elements in _buckets), not other parts of the
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   112
// table such as the _entries field, statistics counters, etc.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   113
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   114
class G1StringDedupTable : public CHeapObj<mtGC> {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   115
private:
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   116
  // The currently active hashtable instance. Only modified when
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   117
  // the table is resizes or rehashed.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   118
  static G1StringDedupTable*      _table;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   119
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   120
  // Cache for reuse and fast alloc/free of table entries.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   121
  static G1StringDedupEntryCache* _entry_cache;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   122
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   123
  G1StringDedupEntry**            _buckets;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   124
  size_t                          _size;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   125
  uintx                           _entries;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   126
  uintx                           _shrink_threshold;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   127
  uintx                           _grow_threshold;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   128
  bool                            _rehash_needed;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   129
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   130
  // The hash seed also dictates which hash function to use. A
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   131
  // zero hash seed means we will use the Java compatible hash
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   132
  // function (which doesn't use a seed), and a non-zero hash
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   133
  // seed means we use the murmur3 hash function.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   134
  jint                            _hash_seed;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   135
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   136
  // Constants governing table resize/rehash/cache.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   137
  static const size_t             _min_size;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   138
  static const size_t             _max_size;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   139
  static const double             _grow_load_factor;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   140
  static const double             _shrink_load_factor;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   141
  static const uintx              _rehash_multiple;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   142
  static const uintx              _rehash_threshold;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   143
  static const double             _max_cache_factor;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   144
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   145
  // Table statistics, only used for logging.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   146
  static uintx                    _entries_added;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   147
  static uintx                    _entries_removed;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   148
  static uintx                    _resize_count;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   149
  static uintx                    _rehash_count;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   150
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   151
  G1StringDedupTable(size_t size, jint hash_seed = 0);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   152
  ~G1StringDedupTable();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   153
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   154
  // Returns the hash bucket at the given index.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   155
  G1StringDedupEntry** bucket(size_t index) {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   156
    return _buckets + index;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   157
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   158
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   159
  // Returns the hash bucket index for the given hash code.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   160
  size_t hash_to_index(unsigned int hash) {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   161
    return (size_t)hash & (_size - 1);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   162
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   163
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   164
  // Adds a new table entry to the given hash bucket.
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   165
  void add(typeArrayOop value, bool latin1, unsigned int hash, G1StringDedupEntry** list);
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   166
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   167
  // Removes the given table entry from the table.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   168
  void remove(G1StringDedupEntry** pentry, uint worker_id);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   169
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   170
  // Transfers a table entry from the current table to the destination table.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   171
  void transfer(G1StringDedupEntry** pentry, G1StringDedupTable* dest);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   172
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   173
  // Returns an existing character array in the given hash bucket, or NULL
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   174
  // if no matching character array exists.
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   175
  typeArrayOop lookup(typeArrayOop value, bool latin1, unsigned int hash,
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   176
                      G1StringDedupEntry** list, uintx &count);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   177
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   178
  // Returns an existing character array in the table, or inserts a new
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   179
  // table entry if no matching character array exists.
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   180
  typeArrayOop lookup_or_add_inner(typeArrayOop value, bool latin1, unsigned int hash);
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   181
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   182
  // Thread safe lookup or add of table entry
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   183
  static typeArrayOop lookup_or_add(typeArrayOop value, bool latin1, unsigned int hash) {
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   184
    // Protect the table from concurrent access. Also note that this lock
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   185
    // acts as a fence for _table, which could have been replaced by a new
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   186
    // instance if the table was resized or rehashed.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   187
    MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   188
    return _table->lookup_or_add_inner(value, latin1, hash);
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   189
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   190
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   191
  // Returns true if the hashtable is currently using a Java compatible
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   192
  // hash function.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   193
  static bool use_java_hash() {
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   194
    return _table->_hash_seed == 0;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   195
  }
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   196
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   197
  static bool equals(typeArrayOop value1, typeArrayOop value2);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   198
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   199
  // Computes the hash code for the given character array, using the
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   200
  // currently active hash function and hash seed.
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   201
  static unsigned int hash_code(typeArrayOop value, bool latin1);
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   202
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   203
  static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   204
                                 size_t partition_begin,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   205
                                 size_t partition_end,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   206
                                 uint worker_id);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   207
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   208
public:
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   209
  static void create();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   210
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   211
  // Deduplicates the given String object, or adds its backing
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   212
  // character array to the deduplication hashtable.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   213
  static void deduplicate(oop java_string, G1StringDedupStat& stat);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   214
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   215
  // If a table resize is needed, returns a newly allocated empty
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   216
  // hashtable of the proper size.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   217
  static G1StringDedupTable* prepare_resize();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   218
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   219
  // Installs a newly resized table as the currently active table
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   220
  // and deletes the previously active table.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   221
  static void finish_resize(G1StringDedupTable* resized_table);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   222
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   223
  // If a table rehash is needed, returns a newly allocated empty
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   224
  // hashtable and updates the hash seed.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   225
  static G1StringDedupTable* prepare_rehash();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   226
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   227
  // Transfers rehashed entries from the currently active table into
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   228
  // the new table. Installs the new table as the currently active table
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   229
  // and deletes the previously active table.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   230
  static void finish_rehash(G1StringDedupTable* rehashed_table);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   231
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   232
  // If the table entry cache has grown too large, trim it down according to policy
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   233
  static void trim_entry_cache();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   234
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   235
  static void unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl, uint worker_id);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   236
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   237
  static void print_statistics(outputStream* st);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   238
  static void verify();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   239
};
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
   240
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30175
diff changeset
   241
#endif // SHARE_VM_GC_G1_G1STRINGDEDUPTABLE_HPP