annotate src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp @ 17764:595c0f60d50d

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