< prev index next >

src/share/vm/utilities/hashtable.cpp

Print this page




 188   Atomic::add(-context->_num_removed, &_number_of_entries);
 189 }
 190 
 191 // Copy the table to the shared space.
 192 
 193 template <MEMFLAGS F> void BasicHashtable<F>::copy_table(char** top, char* end) {
 194 
 195   // Dump the hash table entries.
 196 
 197   intptr_t *plen = (intptr_t*)(*top);
 198   *top += sizeof(*plen);
 199 
 200   int i;
 201   for (i = 0; i < _table_size; ++i) {
 202     for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr();
 203                               *p != NULL;
 204                                p = (*p)->next_addr()) {
 205       if (*top + entry_size() > end) {
 206         report_out_of_shared_space(SharedMiscData);
 207       }
 208       *p = (BasicHashtableEntry<F>*)memcpy(*top, *p, entry_size());
 209       *top += entry_size();
 210     }
 211   }
 212   *plen = (char*)(*top) - (char*)plen - sizeof(*plen);
 213 
 214   // Set the shared bit.
 215 
 216   for (i = 0; i < _table_size; ++i) {
 217     for (BasicHashtableEntry<F>* p = bucket(i); p != NULL; p = p->next()) {
 218       p->set_shared();
 219     }
 220   }
 221 }
 222 
 223 template <class T, MEMFLAGS F> int RehashableHashtable<T, F>::literal_size(Symbol *symbol) {
 224   return symbol->size() * HeapWordSize;
 225 }
 226 
 227 template <class T, MEMFLAGS F> int RehashableHashtable<T, F>::literal_size(oop oop) {
 228   // NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,


 268   st->print_cr("Average bucket size     : %9.3f", summary.avg());
 269   st->print_cr("Variance of bucket size : %9.3f", summary.variance());
 270   st->print_cr("Std. dev. of bucket size: %9.3f", summary.sd());
 271   st->print_cr("Maximum bucket size     : %9d", (int)summary.maximum());
 272 }
 273 
 274 
 275 // Dump the hash table buckets.
 276 
 277 template <MEMFLAGS F> void BasicHashtable<F>::copy_buckets(char** top, char* end) {
 278   intptr_t len = _table_size * sizeof(HashtableBucket<F>);
 279   *(intptr_t*)(*top) = len;
 280   *top += sizeof(intptr_t);
 281 
 282   *(intptr_t*)(*top) = _number_of_entries;
 283   *top += sizeof(intptr_t);
 284 
 285   if (*top + len > end) {
 286     report_out_of_shared_space(SharedMiscData);
 287   }
 288   _buckets = (HashtableBucket<F>*)memcpy(*top, _buckets, len);
 289   *top += len;
 290 }
 291 
 292 
 293 #ifndef PRODUCT
 294 
 295 template <class T, MEMFLAGS F> void Hashtable<T, F>::print() {
 296   ResourceMark rm;
 297 
 298   for (int i = 0; i < BasicHashtable<F>::table_size(); i++) {
 299     HashtableEntry<T, F>* entry = bucket(i);
 300     while(entry != NULL) {
 301       tty->print("%d : ", i);
 302       entry->literal()->print();
 303       tty->cr();
 304       entry = entry->next();
 305     }
 306   }
 307 }
 308 




 188   Atomic::add(-context->_num_removed, &_number_of_entries);
 189 }
 190 
 191 // Copy the table to the shared space.
 192 
 193 template <MEMFLAGS F> void BasicHashtable<F>::copy_table(char** top, char* end) {
 194 
 195   // Dump the hash table entries.
 196 
 197   intptr_t *plen = (intptr_t*)(*top);
 198   *top += sizeof(*plen);
 199 
 200   int i;
 201   for (i = 0; i < _table_size; ++i) {
 202     for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr();
 203                               *p != NULL;
 204                                p = (*p)->next_addr()) {
 205       if (*top + entry_size() > end) {
 206         report_out_of_shared_space(SharedMiscData);
 207       }
 208       *p = (BasicHashtableEntry<F>*)memcpy(*top, (void*)*p, entry_size());
 209       *top += entry_size();
 210     }
 211   }
 212   *plen = (char*)(*top) - (char*)plen - sizeof(*plen);
 213 
 214   // Set the shared bit.
 215 
 216   for (i = 0; i < _table_size; ++i) {
 217     for (BasicHashtableEntry<F>* p = bucket(i); p != NULL; p = p->next()) {
 218       p->set_shared();
 219     }
 220   }
 221 }
 222 
 223 template <class T, MEMFLAGS F> int RehashableHashtable<T, F>::literal_size(Symbol *symbol) {
 224   return symbol->size() * HeapWordSize;
 225 }
 226 
 227 template <class T, MEMFLAGS F> int RehashableHashtable<T, F>::literal_size(oop oop) {
 228   // NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,


 268   st->print_cr("Average bucket size     : %9.3f", summary.avg());
 269   st->print_cr("Variance of bucket size : %9.3f", summary.variance());
 270   st->print_cr("Std. dev. of bucket size: %9.3f", summary.sd());
 271   st->print_cr("Maximum bucket size     : %9d", (int)summary.maximum());
 272 }
 273 
 274 
 275 // Dump the hash table buckets.
 276 
 277 template <MEMFLAGS F> void BasicHashtable<F>::copy_buckets(char** top, char* end) {
 278   intptr_t len = _table_size * sizeof(HashtableBucket<F>);
 279   *(intptr_t*)(*top) = len;
 280   *top += sizeof(intptr_t);
 281 
 282   *(intptr_t*)(*top) = _number_of_entries;
 283   *top += sizeof(intptr_t);
 284 
 285   if (*top + len > end) {
 286     report_out_of_shared_space(SharedMiscData);
 287   }
 288   _buckets = (HashtableBucket<F>*)memcpy(*top, (void*)_buckets, len);
 289   *top += len;
 290 }
 291 
 292 
 293 #ifndef PRODUCT
 294 
 295 template <class T, MEMFLAGS F> void Hashtable<T, F>::print() {
 296   ResourceMark rm;
 297 
 298   for (int i = 0; i < BasicHashtable<F>::table_size(); i++) {
 299     HashtableEntry<T, F>* entry = bucket(i);
 300     while(entry != NULL) {
 301       tty->print("%d : ", i);
 302       entry->literal()->print();
 303       tty->cr();
 304       entry = entry->next();
 305     }
 306   }
 307 }
 308 


< prev index next >