150 size_t hash_to_index(unsigned int hash) { |
160 size_t hash_to_index(unsigned int hash) { |
151 return (size_t)hash & (_size - 1); |
161 return (size_t)hash & (_size - 1); |
152 } |
162 } |
153 |
163 |
154 // Adds a new table entry to the given hash bucket. |
164 // Adds a new table entry to the given hash bucket. |
155 void add(typeArrayOop value, unsigned int hash, G1StringDedupEntry** list); |
165 void add(typeArrayOop value, bool latin1, unsigned int hash, G1StringDedupEntry** list); |
156 |
166 |
157 // Removes the given table entry from the table. |
167 // Removes the given table entry from the table. |
158 void remove(G1StringDedupEntry** pentry, uint worker_id); |
168 void remove(G1StringDedupEntry** pentry, uint worker_id); |
159 |
169 |
160 // Transfers a table entry from the current table to the destination table. |
170 // Transfers a table entry from the current table to the destination table. |
161 void transfer(G1StringDedupEntry** pentry, G1StringDedupTable* dest); |
171 void transfer(G1StringDedupEntry** pentry, G1StringDedupTable* dest); |
162 |
172 |
163 // Returns an existing character array in the given hash bucket, or NULL |
173 // Returns an existing character array in the given hash bucket, or NULL |
164 // if no matching character array exists. |
174 // if no matching character array exists. |
165 typeArrayOop lookup(typeArrayOop value, unsigned int hash, |
175 typeArrayOop lookup(typeArrayOop value, bool latin1, unsigned int hash, |
166 G1StringDedupEntry** list, uintx &count); |
176 G1StringDedupEntry** list, uintx &count); |
167 |
177 |
168 // Returns an existing character array in the table, or inserts a new |
178 // Returns an existing character array in the table, or inserts a new |
169 // table entry if no matching character array exists. |
179 // table entry if no matching character array exists. |
170 typeArrayOop lookup_or_add_inner(typeArrayOop value, unsigned int hash); |
180 typeArrayOop lookup_or_add_inner(typeArrayOop value, bool latin1, unsigned int hash); |
171 |
181 |
172 // Thread safe lookup or add of table entry |
182 // Thread safe lookup or add of table entry |
173 static typeArrayOop lookup_or_add(typeArrayOop value, unsigned int hash) { |
183 static typeArrayOop lookup_or_add(typeArrayOop value, bool latin1, unsigned int hash) { |
174 // Protect the table from concurrent access. Also note that this lock |
184 // Protect the table from concurrent access. Also note that this lock |
175 // acts as a fence for _table, which could have been replaced by a new |
185 // acts as a fence for _table, which could have been replaced by a new |
176 // instance if the table was resized or rehashed. |
186 // instance if the table was resized or rehashed. |
177 MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag); |
187 MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag); |
178 return _table->lookup_or_add_inner(value, hash); |
188 return _table->lookup_or_add_inner(value, latin1, hash); |
179 } |
189 } |
180 |
190 |
181 // Returns true if the hashtable is currently using a Java compatible |
191 // Returns true if the hashtable is currently using a Java compatible |
182 // hash function. |
192 // hash function. |
183 static bool use_java_hash() { |
193 static bool use_java_hash() { |
186 |
196 |
187 static bool equals(typeArrayOop value1, typeArrayOop value2); |
197 static bool equals(typeArrayOop value1, typeArrayOop value2); |
188 |
198 |
189 // Computes the hash code for the given character array, using the |
199 // Computes the hash code for the given character array, using the |
190 // currently active hash function and hash seed. |
200 // currently active hash function and hash seed. |
191 static unsigned int hash_code(typeArrayOop value); |
201 static unsigned int hash_code(typeArrayOop value, bool latin1); |
192 |
202 |
193 static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl, |
203 static uintx unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl, |
194 size_t partition_begin, |
204 size_t partition_begin, |
195 size_t partition_end, |
205 size_t partition_end, |
196 uint worker_id); |
206 uint worker_id); |