522 if (!verbose) { 523 the_table()->dump_table(st, "SymbolTable"); 524 } else { 525 st->print_cr("VERSION: 1.0"); 526 for (int i = 0; i < the_table()->table_size(); ++i) { 527 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 528 for ( ; p != NULL; p = p->next()) { 529 Symbol* s = (Symbol*)(p->literal()); 530 const char* utf8_string = (const char*)s->bytes(); 531 int utf8_length = s->utf8_length(); 532 st->print("%d %d: ", utf8_length, s->refcount()); 533 HashtableTextDump::put_utf8(st, utf8_string, utf8_length); 534 st->cr(); 535 } 536 } 537 } 538 } 539 540 bool SymbolTable::copy_compact_table(char** top, char*end) { 541 #if INCLUDE_CDS 542 CompactHashtableWriter ch_table("symbol", the_table()->number_of_entries(), 543 &MetaspaceShared::stats()->symbol); 544 if (*top + ch_table.get_required_bytes() > end) { 545 // not enough space left 546 return false; 547 } 548 549 for (int i = 0; i < the_table()->table_size(); ++i) { 550 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 551 for ( ; p != NULL; p = p->next()) { 552 Symbol* s = (Symbol*)(p->literal()); 553 unsigned int fixed_hash = hash_symbol((char*)s->bytes(), s->utf8_length()); 554 assert(fixed_hash == p->hash(), "must not rehash during dumping"); 555 ch_table.add(fixed_hash, s); 556 } 557 } 558 559 char* old_top = *top; 560 ch_table.dump(top, end); 561 562 *top = (char*)align_pointer_up(*top, sizeof(void*)); 563 #endif 564 return true; 565 } 566 567 const char* SymbolTable::init_shared_table(const char* buffer) { 568 const char* end = _shared_table.init(buffer); 569 return (const char*)align_pointer_up(end, sizeof(void*)); 570 } 571 572 //--------------------------------------------------------------------------- 573 // Non-product code 574 575 #ifndef PRODUCT 576 577 void SymbolTable::print_histogram() { 578 MutexLocker ml(SymbolTable_lock); 579 const int results_length = 100; 580 int counts[results_length]; 581 int sizes[results_length]; 582 int i,j; 583 584 // initialize results to zero 585 for (j = 0; j < results_length; j++) { 586 counts[j] = 0; 587 sizes[j] = 0; 588 } | 522 if (!verbose) { 523 the_table()->dump_table(st, "SymbolTable"); 524 } else { 525 st->print_cr("VERSION: 1.0"); 526 for (int i = 0; i < the_table()->table_size(); ++i) { 527 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 528 for ( ; p != NULL; p = p->next()) { 529 Symbol* s = (Symbol*)(p->literal()); 530 const char* utf8_string = (const char*)s->bytes(); 531 int utf8_length = s->utf8_length(); 532 st->print("%d %d: ", utf8_length, s->refcount()); 533 HashtableTextDump::put_utf8(st, utf8_string, utf8_length); 534 st->cr(); 535 } 536 } 537 } 538 } 539 540 bool SymbolTable::copy_compact_table(char** top, char*end) { 541 #if INCLUDE_CDS 542 CompactHashtableWriter ch_table(CompactHashtable<Symbol*, char>::_symbol_table, 543 the_table()->number_of_entries(), 544 &MetaspaceShared::stats()->symbol); 545 if (*top + ch_table.get_required_bytes() > end) { 546 // not enough space left 547 return false; 548 } 549 550 for (int i = 0; i < the_table()->table_size(); ++i) { 551 HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i); 552 for ( ; p != NULL; p = p->next()) { 553 Symbol* s = (Symbol*)(p->literal()); 554 unsigned int fixed_hash = hash_symbol((char*)s->bytes(), s->utf8_length()); 555 assert(fixed_hash == p->hash(), "must not rehash during dumping"); 556 ch_table.add(fixed_hash, s); 557 } 558 } 559 560 ch_table.dump(top, end); 561 562 *top = (char*)align_pointer_up(*top, sizeof(void*)); 563 #endif 564 return true; 565 } 566 567 const char* SymbolTable::init_shared_table(const char* buffer) { 568 const char* end = _shared_table.init( 569 CompactHashtable<Symbol*, char>::_symbol_table, buffer); 570 return (const char*)align_pointer_up(end, sizeof(void*)); 571 } 572 573 //--------------------------------------------------------------------------- 574 // Non-product code 575 576 #ifndef PRODUCT 577 578 void SymbolTable::print_histogram() { 579 MutexLocker ml(SymbolTable_lock); 580 const int results_length = 100; 581 int counts[results_length]; 582 int sizes[results_length]; 583 int i,j; 584 585 // initialize results to zero 586 for (j = 0; j < results_length; j++) { 587 counts[j] = 0; 588 sizes[j] = 0; 589 } |