527 CompactHashtableWriter ch_table(CompactHashtable<Symbol*, char>::_symbol_table, 528 the_table()->number_of_entries(), 529 &MetaspaceShared::stats()->symbol); 530 if (*top + ch_table.get_required_bytes() > end) { 531 // not enough space left 532 return false; 533 } 534 535 for (int i = 0; i < the_table()->table_size(); ++i) { 536 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 537 for ( ; p != NULL; p = p->next()) { 538 Symbol* s = (Symbol*)(p->literal()); 539 unsigned int fixed_hash = hash_symbol((char*)s->bytes(), s->utf8_length()); 540 assert(fixed_hash == p->hash(), "must not rehash during dumping"); 541 ch_table.add(fixed_hash, s); 542 } 543 } 544 545 ch_table.dump(top, end); 546 547 *top = (char*)align_pointer_up(*top, sizeof(void*)); 548 #endif 549 return true; 550 } 551 552 const char* SymbolTable::init_shared_table(const char* buffer) { 553 const char* end = _shared_table.init( 554 CompactHashtable<Symbol*, char>::_symbol_table, buffer); 555 return (const char*)align_pointer_up(end, sizeof(void*)); 556 } 557 558 //--------------------------------------------------------------------------- 559 // Non-product code 560 561 #ifndef PRODUCT 562 563 void SymbolTable::print_histogram() { 564 MutexLocker ml(SymbolTable_lock); 565 const int results_length = 100; 566 int counts[results_length]; 567 int sizes[results_length]; 568 int i,j; 569 570 // initialize results to zero 571 for (j = 0; j < results_length; j++) { 572 counts[j] = 0; 573 sizes[j] = 0; 574 } 575 583 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 584 for ( ; p != NULL; p = p->next()) { 585 int size = p->literal()->size(); 586 int len = p->literal()->utf8_length(); 587 if (len < results_length) { 588 counts[len]++; 589 sizes[len] += size; 590 } else { 591 out_of_range_count++; 592 out_of_range_size += size; 593 } 594 total_count++; 595 total_size += size; 596 total_length += len; 597 max_length = MAX2(max_length, len); 598 } 599 } 600 tty->print_cr("Symbol Table Histogram:"); 601 tty->print_cr(" Total number of symbols %7d", total_count); 602 tty->print_cr(" Total size in memory %7dK", 603 (total_size*HeapWordSize)/1024); 604 tty->print_cr(" Total counted %7d", _symbols_counted); 605 tty->print_cr(" Total removed %7d", _symbols_removed); 606 if (_symbols_counted > 0) { 607 tty->print_cr(" Percent removed %3.2f", 608 ((float)_symbols_removed/(float)_symbols_counted)* 100); 609 } 610 tty->print_cr(" Reference counts %7d", Symbol::_total_count); 611 tty->print_cr(" Symbol arena used " SIZE_FORMAT_W(7) "K", arena()->used()/1024); 612 tty->print_cr(" Symbol arena size " SIZE_FORMAT_W(7) "K", arena()->size_in_bytes()/1024); 613 tty->print_cr(" Total symbol length %7d", total_length); 614 tty->print_cr(" Maximum symbol length %7d", max_length); 615 tty->print_cr(" Average symbol length %7.2f", ((float) total_length / (float) total_count)); 616 tty->print_cr(" Symbol length histogram:"); 617 tty->print_cr(" %6s %10s %10s", "Length", "#Symbols", "Size"); 618 for (i = 0; i < results_length; i++) { 619 if (counts[i] > 0) { 620 tty->print_cr(" %6d %10d %10dK", i, counts[i], (sizes[i]*HeapWordSize)/1024); 621 } 622 } 623 tty->print_cr(" >=%6d %10d %10dK\n", results_length, 624 out_of_range_count, (out_of_range_size*HeapWordSize)/1024); 625 } 626 627 void SymbolTable::print() { 628 for (int i = 0; i < the_table()->table_size(); ++i) { 629 HashtableEntry<Symbol*, mtSymbol>** p = the_table()->bucket_addr(i); 630 HashtableEntry<Symbol*, mtSymbol>* entry = the_table()->bucket(i); 631 if (entry != NULL) { 632 while (entry != NULL) { 633 tty->print(PTR_FORMAT " ", p2i(entry->literal())); 634 entry->literal()->print(); 635 tty->print(" %d", entry->literal()->refcount()); 636 p = entry->next_addr(); 637 entry = (HashtableEntry<Symbol*, mtSymbol>*)HashtableEntry<Symbol*, mtSymbol>::make_ptr(*p); 638 } 639 tty->cr(); 640 } 641 } 642 } 643 #endif // PRODUCT 644 | 527 CompactHashtableWriter ch_table(CompactHashtable<Symbol*, char>::_symbol_table, 528 the_table()->number_of_entries(), 529 &MetaspaceShared::stats()->symbol); 530 if (*top + ch_table.get_required_bytes() > end) { 531 // not enough space left 532 return false; 533 } 534 535 for (int i = 0; i < the_table()->table_size(); ++i) { 536 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 537 for ( ; p != NULL; p = p->next()) { 538 Symbol* s = (Symbol*)(p->literal()); 539 unsigned int fixed_hash = hash_symbol((char*)s->bytes(), s->utf8_length()); 540 assert(fixed_hash == p->hash(), "must not rehash during dumping"); 541 ch_table.add(fixed_hash, s); 542 } 543 } 544 545 ch_table.dump(top, end); 546 547 *top = (char*)align_ptr_up(*top, sizeof(void*)); 548 #endif 549 return true; 550 } 551 552 const char* SymbolTable::init_shared_table(const char* buffer) { 553 const char* end = _shared_table.init( 554 CompactHashtable<Symbol*, char>::_symbol_table, buffer); 555 return (const char*)align_ptr_up(end, sizeof(void*)); 556 } 557 558 //--------------------------------------------------------------------------- 559 // Non-product code 560 561 #ifndef PRODUCT 562 563 void SymbolTable::print_histogram() { 564 MutexLocker ml(SymbolTable_lock); 565 const int results_length = 100; 566 int counts[results_length]; 567 int sizes[results_length]; 568 int i,j; 569 570 // initialize results to zero 571 for (j = 0; j < results_length; j++) { 572 counts[j] = 0; 573 sizes[j] = 0; 574 } 575 583 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 584 for ( ; p != NULL; p = p->next()) { 585 int size = p->literal()->size(); 586 int len = p->literal()->utf8_length(); 587 if (len < results_length) { 588 counts[len]++; 589 sizes[len] += size; 590 } else { 591 out_of_range_count++; 592 out_of_range_size += size; 593 } 594 total_count++; 595 total_size += size; 596 total_length += len; 597 max_length = MAX2(max_length, len); 598 } 599 } 600 tty->print_cr("Symbol Table Histogram:"); 601 tty->print_cr(" Total number of symbols %7d", total_count); 602 tty->print_cr(" Total size in memory %7dK", 603 (total_size*wordSize)/1024); 604 tty->print_cr(" Total counted %7d", _symbols_counted); 605 tty->print_cr(" Total removed %7d", _symbols_removed); 606 if (_symbols_counted > 0) { 607 tty->print_cr(" Percent removed %3.2f", 608 ((float)_symbols_removed/(float)_symbols_counted)* 100); 609 } 610 tty->print_cr(" Reference counts %7d", Symbol::_total_count); 611 tty->print_cr(" Symbol arena used " SIZE_FORMAT_W(7) "K", arena()->used()/1024); 612 tty->print_cr(" Symbol arena size " SIZE_FORMAT_W(7) "K", arena()->size_in_bytes()/1024); 613 tty->print_cr(" Total symbol length %7d", total_length); 614 tty->print_cr(" Maximum symbol length %7d", max_length); 615 tty->print_cr(" Average symbol length %7.2f", ((float) total_length / (float) total_count)); 616 tty->print_cr(" Symbol length histogram:"); 617 tty->print_cr(" %6s %10s %10s", "Length", "#Symbols", "Size"); 618 for (i = 0; i < results_length; i++) { 619 if (counts[i] > 0) { 620 tty->print_cr(" %6d %10d %10dK", i, counts[i], (sizes[i]*wordSize)/1024); 621 } 622 } 623 tty->print_cr(" >=%6d %10d %10dK\n", results_length, 624 out_of_range_count, (out_of_range_size*wordSize)/1024); 625 } 626 627 void SymbolTable::print() { 628 for (int i = 0; i < the_table()->table_size(); ++i) { 629 HashtableEntry<Symbol*, mtSymbol>** p = the_table()->bucket_addr(i); 630 HashtableEntry<Symbol*, mtSymbol>* entry = the_table()->bucket(i); 631 if (entry != NULL) { 632 while (entry != NULL) { 633 tty->print(PTR_FORMAT " ", p2i(entry->literal())); 634 entry->literal()->print(); 635 tty->print(" %d", entry->literal()->refcount()); 636 p = entry->next_addr(); 637 entry = (HashtableEntry<Symbol*, mtSymbol>*)HashtableEntry<Symbol*, mtSymbol>::make_ptr(*p); 638 } 639 tty->cr(); 640 } 641 } 642 } 643 #endif // PRODUCT 644 |