< prev index next >

src/hotspot/share/prims/jvmtiTagMap.cpp

Print this page




 161     _size_index = size_index;
 162     _size = initial_size;
 163     _entry_count = 0;
 164     _trace_threshold = initial_trace_threshold;
 165     _load_factor = load_factor;
 166     _resize_threshold = (int)(_load_factor * _size);
 167     _resizing_enabled = true;
 168     size_t s = initial_size * sizeof(JvmtiTagHashmapEntry*);
 169     _table = (JvmtiTagHashmapEntry**)os::malloc(s, mtInternal);
 170     if (_table == NULL) {
 171       vm_exit_out_of_memory(s, OOM_MALLOC_ERROR,
 172         "unable to allocate initial hashtable for jvmti object tags");
 173     }
 174     for (int i=0; i<initial_size; i++) {
 175       _table[i] = NULL;
 176     }
 177   }
 178 
 179   // hash a given key (oop) with the specified size
 180   static unsigned int hash(oop key, int size) {


 181     // shift right to get better distribution (as these bits will be zero
 182     // with aligned addresses)
 183     unsigned int addr = (unsigned int)(cast_from_oop<intptr_t>(key));
 184 #ifdef _LP64
 185     return (addr >> 3) % size;
 186 #else
 187     return (addr >> 2) % size;
 188 #endif
 189   }
 190 
 191   // hash a given key (oop)
 192   unsigned int hash(oop key) {
 193     return hash(key, _size);
 194   }
 195 
 196   // resize the hashmap - allocates a large table and re-hashes
 197   // all entries into the new table.
 198   void resize() {
 199     int new_size_index = _size_index+1;
 200     int new_size = _sizes[new_size_index];




 161     _size_index = size_index;
 162     _size = initial_size;
 163     _entry_count = 0;
 164     _trace_threshold = initial_trace_threshold;
 165     _load_factor = load_factor;
 166     _resize_threshold = (int)(_load_factor * _size);
 167     _resizing_enabled = true;
 168     size_t s = initial_size * sizeof(JvmtiTagHashmapEntry*);
 169     _table = (JvmtiTagHashmapEntry**)os::malloc(s, mtInternal);
 170     if (_table == NULL) {
 171       vm_exit_out_of_memory(s, OOM_MALLOC_ERROR,
 172         "unable to allocate initial hashtable for jvmti object tags");
 173     }
 174     for (int i=0; i<initial_size; i++) {
 175       _table[i] = NULL;
 176     }
 177   }
 178 
 179   // hash a given key (oop) with the specified size
 180   static unsigned int hash(oop key, int size) {
 181     ZGC_ONLY(assert(ZAddressMetadataShift >= sizeof(unsigned int) * BitsPerByte, "cast removes the metadata bits");)
 182 
 183     // shift right to get better distribution (as these bits will be zero
 184     // with aligned addresses)
 185     unsigned int addr = (unsigned int)(cast_from_oop<intptr_t>(key));
 186 #ifdef _LP64
 187     return (addr >> 3) % size;
 188 #else
 189     return (addr >> 2) % size;
 190 #endif
 191   }
 192 
 193   // hash a given key (oop)
 194   unsigned int hash(oop key) {
 195     return hash(key, _size);
 196   }
 197 
 198   // resize the hashmap - allocates a large table and re-hashes
 199   // all entries into the new table.
 200   void resize() {
 201     int new_size_index = _size_index+1;
 202     int new_size = _sizes[new_size_index];


< prev index next >