< prev index next >

src/hotspot/share/utilities/hashtable.cpp

Print this page


  70     }
  71     entry = (BasicHashtableEntry<F>*)_first_free_entry;
  72     _first_free_entry += _entry_size;
  73   }
  74 
  75   assert(_entry_size % HeapWordSize == 0, "");
  76   entry->set_hash(hashValue);
  77   return entry;
  78 }
  79 
  80 
  81 template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::new_entry(unsigned int hashValue, T obj) {
  82   HashtableEntry<T, F>* entry;
  83 
  84   entry = (HashtableEntry<T, F>*)BasicHashtable<F>::new_entry(hashValue);
  85   entry->set_literal(obj);
  86   return entry;
  87 }
  88 
  89 // Version of hashtable entry allocation that allocates in the C heap directly.
  90 // The allocator in blocks is preferable but doesn't have free semantics.


  91 template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::allocate_new_entry(unsigned int hashValue, T obj) {
  92   HashtableEntry<T, F>* entry = (HashtableEntry<T, F>*) NEW_C_HEAP_ARRAY(char, this->entry_size(), F);
  93 
  94   entry->set_hash(hashValue);
  95   entry->set_literal(obj);
  96   entry->set_next(NULL);
  97   return entry;
  98 }
  99 
 100 template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
 101   if (NULL != _buckets) {
 102     FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
 103     _buckets = NULL;
 104   }
 105 }
 106 
 107 template <MEMFLAGS F> void BasicHashtable<F>::BucketUnlinkContext::free_entry(BasicHashtableEntry<F>* entry) {
 108   entry->set_next(_removed_head);
 109   _removed_head = entry;
 110   if (_removed_tail == NULL) {




  70     }
  71     entry = (BasicHashtableEntry<F>*)_first_free_entry;
  72     _first_free_entry += _entry_size;
  73   }
  74 
  75   assert(_entry_size % HeapWordSize == 0, "");
  76   entry->set_hash(hashValue);
  77   return entry;
  78 }
  79 
  80 
  81 template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::new_entry(unsigned int hashValue, T obj) {
  82   HashtableEntry<T, F>* entry;
  83 
  84   entry = (HashtableEntry<T, F>*)BasicHashtable<F>::new_entry(hashValue);
  85   entry->set_literal(obj);
  86   return entry;
  87 }
  88 
  89 // Version of hashtable entry allocation that allocates in the C heap directly.
  90 // The block allocator in BasicHashtable has less fragmentation, but the memory is not freed until
  91 // the whole table is freed. Use allocate_new_entry() if you want to individually free the memory
  92 // used by each entry
  93 template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::allocate_new_entry(unsigned int hashValue, T obj) {
  94   HashtableEntry<T, F>* entry = (HashtableEntry<T, F>*) NEW_C_HEAP_ARRAY(char, this->entry_size(), F);
  95 
  96   entry->set_hash(hashValue);
  97   entry->set_literal(obj);
  98   entry->set_next(NULL);
  99   return entry;
 100 }
 101 
 102 template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
 103   if (NULL != _buckets) {
 104     FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
 105     _buckets = NULL;
 106   }
 107 }
 108 
 109 template <MEMFLAGS F> void BasicHashtable<F>::BucketUnlinkContext::free_entry(BasicHashtableEntry<F>* entry) {
 110   entry->set_next(_removed_head);
 111   _removed_head = entry;
 112   if (_removed_tail == NULL) {


< prev index next >