Mercurial > hg > truffle
comparison src/share/vm/utilities/hashtable.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 5e2dc722e70d |
children | a5d6f0c3585f |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #ifndef SHARE_VM_UTILITIES_HASHTABLE_HPP | 25 #ifndef SHARE_VM_UTILITIES_HASHTABLE_HPP |
26 #define SHARE_VM_UTILITIES_HASHTABLE_HPP | 26 #define SHARE_VM_UTILITIES_HASHTABLE_HPP |
27 | 27 |
28 #include "classfile/classLoaderData.hpp" | |
28 #include "memory/allocation.hpp" | 29 #include "memory/allocation.hpp" |
29 #include "oops/oop.hpp" | 30 #include "oops/oop.hpp" |
30 #include "oops/symbol.hpp" | 31 #include "oops/symbol.hpp" |
31 #include "runtime/handles.hpp" | 32 #include "runtime/handles.hpp" |
32 | 33 |
281 static bool use_alternate_hashcode() { return _seed != 0; } | 282 static bool use_alternate_hashcode() { return _seed != 0; } |
282 static jint seed() { return _seed; } | 283 static jint seed() { return _seed; } |
283 | 284 |
284 private: | 285 private: |
285 static jint _seed; | 286 static jint _seed; |
286 | |
287 unsigned int new_hash(Symbol* s); | |
288 unsigned int new_hash(oop string); | |
289 }; | 287 }; |
290 | 288 |
291 | 289 |
292 // Verions of hashtable where two handles are used to compute the index. | 290 // Verions of hashtable where two handles are used to compute the index. |
293 | 291 |
300 TwoOopHashtable(int table_size, int entry_size, HashtableBucket<F>* t, | 298 TwoOopHashtable(int table_size, int entry_size, HashtableBucket<F>* t, |
301 int number_of_entries) | 299 int number_of_entries) |
302 : Hashtable<T, F>(table_size, entry_size, t, number_of_entries) {} | 300 : Hashtable<T, F>(table_size, entry_size, t, number_of_entries) {} |
303 | 301 |
304 public: | 302 public: |
305 unsigned int compute_hash(Symbol* name, Handle loader) { | 303 unsigned int compute_hash(Symbol* name, ClassLoaderData* loader_data) { |
306 // Be careful with identity_hash(), it can safepoint and if this | |
307 // were one expression, the compiler could choose to unhandle each | |
308 // oop before calling identity_hash() for either of them. If the first | |
309 // causes a GC, the next would fail. | |
310 unsigned int name_hash = name->identity_hash(); | 304 unsigned int name_hash = name->identity_hash(); |
311 unsigned int loader_hash = loader.is_null() ? 0 : loader->identity_hash(); | 305 // loader is null with CDS |
306 assert(loader_data != NULL || UseSharedSpaces || DumpSharedSpaces, | |
307 "only allowed with shared spaces"); | |
308 unsigned int loader_hash = loader_data == NULL ? 0 : loader_data->identity_hash(); | |
312 return name_hash ^ loader_hash; | 309 return name_hash ^ loader_hash; |
313 } | 310 } |
314 | 311 |
315 int index_for(Symbol* name, Handle loader) { | 312 int index_for(Symbol* name, ClassLoaderData* loader_data) { |
316 return this->hash_to_index(compute_hash(name, loader)); | 313 return this->hash_to_index(compute_hash(name, loader_data)); |
317 } | 314 } |
318 }; | 315 }; |
319 | 316 |
320 #endif // SHARE_VM_UTILITIES_HASHTABLE_HPP | 317 #endif // SHARE_VM_UTILITIES_HASHTABLE_HPP |