< prev index next >

src/hotspot/share/utilities/hashtable.cpp

Print this page




 226          *p != NULL;
 227          p = (*p)->next_addr()) {
 228       *p = (BasicHashtableEntry<F>*)memcpy(top, (void*)*p, entry_size());
 229       top += entry_size();
 230     }
 231   }
 232   *plen = (char*)(top) - (char*)plen - sizeof(*plen);
 233   assert(top == end, "count_bytes_for_table is wrong");
 234   // Set the shared bit.
 235 
 236   for (i = 0; i < _table_size; ++i) {
 237     for (BasicHashtableEntry<F>* p = bucket(i); p != NULL; p = p->next()) {
 238       p->set_shared();
 239     }
 240   }
 241 }
 242 
 243 // For oops and Strings the size of the literal is interesting. For other types, nobody cares.
 244 static int literal_size(ConstantPool*) { return 0; }
 245 static int literal_size(Klass*)        { return 0; }
 246 #if INCLUDE_ALL_GCS
 247 static int literal_size(nmethod*)      { return 0; }
 248 #endif
 249 
 250 static int literal_size(Symbol *symbol) {
 251   return symbol->size() * HeapWordSize;
 252 }
 253 
 254 static int literal_size(oop obj) {
 255   // NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,
 256   // and the String.value array is shared by several Strings. However, starting from JDK8,
 257   // the String.value array is not shared anymore.
 258   if (obj == NULL) {
 259     return 0;
 260   } else if (obj->klass() == SystemDictionary::String_klass()) {
 261     return (obj->size() + java_lang_String::value(obj)->size()) * HeapWordSize;
 262   } else {
 263     return obj->size();
 264   }
 265 }
 266 
 267 static int literal_size(ClassLoaderWeakHandle v) {
 268   return literal_size(v.peek());


 431 
 432   // Log some statistics about the hashtable
 433   log_info(hashtables)("%s max bucket size %d bucket %d element count %d table size %d", table_name,
 434                        max_bucket_count, max_bucket_number, _number_of_entries, _table_size);
 435   if (_number_of_entries > 0 && log_is_enabled(Debug, hashtables)) {
 436     for (int index = 0; index < table_size(); index++) {
 437       int bucket_count = 0;
 438       for (T* probe = (T*)bucket(index); probe != NULL; probe = probe->next()) {
 439         log_debug(hashtables)("bucket %d hash " INTPTR_FORMAT, index, (intptr_t)probe->hash());
 440         bucket_count++;
 441       }
 442       if (bucket_count > 0) {
 443         log_debug(hashtables)("bucket %d count %d", index, bucket_count);
 444       }
 445     }
 446   }
 447 }
 448 #endif // PRODUCT
 449 
 450 // Explicitly instantiate these types
 451 #if INCLUDE_ALL_GCS
 452 template class Hashtable<nmethod*, mtGC>;
 453 template class HashtableEntry<nmethod*, mtGC>;
 454 template class BasicHashtable<mtGC>;
 455 #endif
 456 template class Hashtable<ConstantPool*, mtClass>;
 457 template class RehashableHashtable<Symbol*, mtSymbol>;
 458 template class RehashableHashtable<oop, mtSymbol>;
 459 template class Hashtable<Symbol*, mtSymbol>;
 460 template class Hashtable<Klass*, mtClass>;
 461 template class Hashtable<InstanceKlass*, mtClass>;
 462 template class Hashtable<ClassLoaderWeakHandle, mtClass>;
 463 template class Hashtable<Symbol*, mtModule>;
 464 template class Hashtable<oop, mtSymbol>;
 465 template class Hashtable<ClassLoaderWeakHandle, mtSymbol>;
 466 template class Hashtable<Symbol*, mtClass>;
 467 template class HashtableEntry<Symbol*, mtSymbol>;
 468 template class HashtableEntry<Symbol*, mtClass>;
 469 template class HashtableEntry<oop, mtSymbol>;
 470 template class HashtableEntry<ClassLoaderWeakHandle, mtSymbol>;
 471 template class HashtableBucket<mtClass>;
 472 template class BasicHashtableEntry<mtSymbol>;
 473 template class BasicHashtableEntry<mtCode>;
 474 template class BasicHashtable<mtClass>;
 475 template class BasicHashtable<mtClassShared>;


 226          *p != NULL;
 227          p = (*p)->next_addr()) {
 228       *p = (BasicHashtableEntry<F>*)memcpy(top, (void*)*p, entry_size());
 229       top += entry_size();
 230     }
 231   }
 232   *plen = (char*)(top) - (char*)plen - sizeof(*plen);
 233   assert(top == end, "count_bytes_for_table is wrong");
 234   // Set the shared bit.
 235 
 236   for (i = 0; i < _table_size; ++i) {
 237     for (BasicHashtableEntry<F>* p = bucket(i); p != NULL; p = p->next()) {
 238       p->set_shared();
 239     }
 240   }
 241 }
 242 
 243 // For oops and Strings the size of the literal is interesting. For other types, nobody cares.
 244 static int literal_size(ConstantPool*) { return 0; }
 245 static int literal_size(Klass*)        { return 0; }

 246 static int literal_size(nmethod*)      { return 0; }

 247 
 248 static int literal_size(Symbol *symbol) {
 249   return symbol->size() * HeapWordSize;
 250 }
 251 
 252 static int literal_size(oop obj) {
 253   // NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,
 254   // and the String.value array is shared by several Strings. However, starting from JDK8,
 255   // the String.value array is not shared anymore.
 256   if (obj == NULL) {
 257     return 0;
 258   } else if (obj->klass() == SystemDictionary::String_klass()) {
 259     return (obj->size() + java_lang_String::value(obj)->size()) * HeapWordSize;
 260   } else {
 261     return obj->size();
 262   }
 263 }
 264 
 265 static int literal_size(ClassLoaderWeakHandle v) {
 266   return literal_size(v.peek());


 429 
 430   // Log some statistics about the hashtable
 431   log_info(hashtables)("%s max bucket size %d bucket %d element count %d table size %d", table_name,
 432                        max_bucket_count, max_bucket_number, _number_of_entries, _table_size);
 433   if (_number_of_entries > 0 && log_is_enabled(Debug, hashtables)) {
 434     for (int index = 0; index < table_size(); index++) {
 435       int bucket_count = 0;
 436       for (T* probe = (T*)bucket(index); probe != NULL; probe = probe->next()) {
 437         log_debug(hashtables)("bucket %d hash " INTPTR_FORMAT, index, (intptr_t)probe->hash());
 438         bucket_count++;
 439       }
 440       if (bucket_count > 0) {
 441         log_debug(hashtables)("bucket %d count %d", index, bucket_count);
 442       }
 443     }
 444   }
 445 }
 446 #endif // PRODUCT
 447 
 448 // Explicitly instantiate these types

 449 template class Hashtable<nmethod*, mtGC>;
 450 template class HashtableEntry<nmethod*, mtGC>;
 451 template class BasicHashtable<mtGC>;

 452 template class Hashtable<ConstantPool*, mtClass>;
 453 template class RehashableHashtable<Symbol*, mtSymbol>;
 454 template class RehashableHashtable<oop, mtSymbol>;
 455 template class Hashtable<Symbol*, mtSymbol>;
 456 template class Hashtable<Klass*, mtClass>;
 457 template class Hashtable<InstanceKlass*, mtClass>;
 458 template class Hashtable<ClassLoaderWeakHandle, mtClass>;
 459 template class Hashtable<Symbol*, mtModule>;
 460 template class Hashtable<oop, mtSymbol>;
 461 template class Hashtable<ClassLoaderWeakHandle, mtSymbol>;
 462 template class Hashtable<Symbol*, mtClass>;
 463 template class HashtableEntry<Symbol*, mtSymbol>;
 464 template class HashtableEntry<Symbol*, mtClass>;
 465 template class HashtableEntry<oop, mtSymbol>;
 466 template class HashtableEntry<ClassLoaderWeakHandle, mtSymbol>;
 467 template class HashtableBucket<mtClass>;
 468 template class BasicHashtableEntry<mtSymbol>;
 469 template class BasicHashtableEntry<mtCode>;
 470 template class BasicHashtable<mtClass>;
 471 template class BasicHashtable<mtClassShared>;
< prev index next >