Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/symbolTable.cpp @ 10408:836a62f43af9
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 19 Jun 2013 10:45:56 +0200 |
parents | 8dbc025ff709 |
children | 01522ca68fc7 |
comparison
equal
deleted
inserted
replaced
10086:e0fb8a213650 | 10408:836a62f43af9 |
---|---|
33 #include "memory/gcLocker.inline.hpp" | 33 #include "memory/gcLocker.inline.hpp" |
34 #include "oops/oop.inline.hpp" | 34 #include "oops/oop.inline.hpp" |
35 #include "oops/oop.inline2.hpp" | 35 #include "oops/oop.inline2.hpp" |
36 #include "runtime/mutexLocker.hpp" | 36 #include "runtime/mutexLocker.hpp" |
37 #include "utilities/hashtable.inline.hpp" | 37 #include "utilities/hashtable.inline.hpp" |
38 #include "utilities/numberSeq.hpp" | |
39 | 38 |
40 // -------------------------------------------------------------------------- | 39 // -------------------------------------------------------------------------- |
41 | 40 |
42 SymbolTable* SymbolTable::_the_table = NULL; | 41 SymbolTable* SymbolTable::_the_table = NULL; |
43 // Static arena for symbols that are not deallocated | 42 // Static arena for symbols that are not deallocated |
449 } | 448 } |
450 } | 449 } |
451 } | 450 } |
452 | 451 |
453 void SymbolTable::dump(outputStream* st) { | 452 void SymbolTable::dump(outputStream* st) { |
454 NumberSeq summary; | 453 the_table()->dump_table(st, "SymbolTable"); |
455 for (int i = 0; i < the_table()->table_size(); ++i) { | |
456 int count = 0; | |
457 for (HashtableEntry<Symbol*, mtSymbol>* e = the_table()->bucket(i); | |
458 e != NULL; e = e->next()) { | |
459 count++; | |
460 } | |
461 summary.add((double)count); | |
462 } | |
463 st->print_cr("SymbolTable statistics:"); | |
464 st->print_cr("Number of buckets : %7d", summary.num()); | |
465 st->print_cr("Average bucket size : %7.0f", summary.avg()); | |
466 st->print_cr("Variance of bucket size : %7.0f", summary.variance()); | |
467 st->print_cr("Std. dev. of bucket size: %7.0f", summary.sd()); | |
468 st->print_cr("Maximum bucket size : %7.0f", summary.maximum()); | |
469 } | 454 } |
470 | 455 |
471 | 456 |
472 //--------------------------------------------------------------------------- | 457 //--------------------------------------------------------------------------- |
473 // Non-product code | 458 // Non-product code |
733 { | 718 { |
734 if (string == NULL) return NULL; | 719 if (string == NULL) return NULL; |
735 ResourceMark rm(THREAD); | 720 ResourceMark rm(THREAD); |
736 int length; | 721 int length; |
737 Handle h_string (THREAD, string); | 722 Handle h_string (THREAD, string); |
738 jchar* chars = java_lang_String::as_unicode_string(string, length); | 723 jchar* chars = java_lang_String::as_unicode_string(string, length, CHECK_NULL); |
739 oop result = intern(h_string, chars, length, CHECK_NULL); | 724 oop result = intern(h_string, chars, length, CHECK_NULL); |
740 return result; | 725 return result; |
741 } | 726 } |
742 | 727 |
743 | 728 |
750 Handle string; | 735 Handle string; |
751 oop result = intern(string, chars, length, CHECK_NULL); | 736 oop result = intern(string, chars, length, CHECK_NULL); |
752 return result; | 737 return result; |
753 } | 738 } |
754 | 739 |
755 void StringTable::unlink(BoolObjectClosure* is_alive) { | 740 void StringTable::unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { |
756 // Readers of the table are unlocked, so we should only be removing | 741 // Readers of the table are unlocked, so we should only be removing |
757 // entries at a safepoint. | 742 // entries at a safepoint. |
758 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | 743 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
759 for (int i = 0; i < the_table()->table_size(); ++i) { | 744 for (int i = 0; i < the_table()->table_size(); ++i) { |
760 HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i); | 745 HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i); |
761 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); | 746 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); |
762 while (entry != NULL) { | 747 while (entry != NULL) { |
763 // Shared entries are normally at the end of the bucket and if we run into | 748 assert(!entry->is_shared(), "CDS not used for the StringTable"); |
764 // a shared entry, then there is nothing more to remove. However, if we | 749 |
765 // have rehashed the table, then the shared entries are no longer at the | 750 if (is_alive->do_object_b(entry->literal())) { |
766 // end of the bucket. | 751 if (f != NULL) { |
767 if (entry->is_shared() && !use_alternate_hashcode()) { | 752 f->do_oop((oop*)entry->literal_addr()); |
768 break; | 753 } |
769 } | |
770 assert(entry->literal() != NULL, "just checking"); | |
771 if (entry->is_shared() || is_alive->do_object_b(entry->literal())) { | |
772 p = entry->next_addr(); | 754 p = entry->next_addr(); |
773 } else { | 755 } else { |
774 *p = entry->next(); | 756 *p = entry->next(); |
775 the_table()->free_entry(entry); | 757 the_table()->free_entry(entry); |
776 } | 758 } |
777 entry = (HashtableEntry<oop, mtSymbol>*)HashtableEntry<oop, mtSymbol>::make_ptr(*p); | 759 entry = *p; |
778 } | 760 } |
779 } | 761 } |
780 } | 762 } |
781 | 763 |
782 void StringTable::oops_do(OopClosure* f) { | 764 void StringTable::oops_do(OopClosure* f) { |
783 for (int i = 0; i < the_table()->table_size(); ++i) { | 765 for (int i = 0; i < the_table()->table_size(); ++i) { |
784 HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i); | |
785 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); | 766 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); |
786 while (entry != NULL) { | 767 while (entry != NULL) { |
768 assert(!entry->is_shared(), "CDS not used for the StringTable"); | |
769 | |
787 f->do_oop((oop*)entry->literal_addr()); | 770 f->do_oop((oop*)entry->literal_addr()); |
788 | 771 |
789 // Did the closure remove the literal from the table? | 772 entry = entry->next(); |
790 if (entry->literal() == NULL) { | |
791 assert(!entry->is_shared(), "immutable hashtable entry?"); | |
792 *p = entry->next(); | |
793 the_table()->free_entry(entry); | |
794 } else { | |
795 p = entry->next_addr(); | |
796 } | |
797 entry = (HashtableEntry<oop, mtSymbol>*)HashtableEntry<oop, mtSymbol>::make_ptr(*p); | |
798 } | 773 } |
799 } | 774 } |
800 } | 775 } |
801 | 776 |
802 void StringTable::verify() { | 777 void StringTable::verify() { |
812 } | 787 } |
813 } | 788 } |
814 } | 789 } |
815 | 790 |
816 void StringTable::dump(outputStream* st) { | 791 void StringTable::dump(outputStream* st) { |
817 NumberSeq summary; | 792 the_table()->dump_table(st, "StringTable"); |
818 for (int i = 0; i < the_table()->table_size(); ++i) { | |
819 HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i); | |
820 int count = 0; | |
821 for ( ; p != NULL; p = p->next()) { | |
822 count++; | |
823 } | |
824 summary.add((double)count); | |
825 } | |
826 st->print_cr("StringTable statistics:"); | |
827 st->print_cr("Number of buckets : %7d", summary.num()); | |
828 st->print_cr("Average bucket size : %7.0f", summary.avg()); | |
829 st->print_cr("Variance of bucket size : %7.0f", summary.variance()); | |
830 st->print_cr("Std. dev. of bucket size: %7.0f", summary.sd()); | |
831 st->print_cr("Maximum bucket size : %7.0f", summary.maximum()); | |
832 } | 793 } |
833 | 794 |
834 | 795 |
835 // Create a new table and using alternate hash code, populate the new table | 796 // Create a new table and using alternate hash code, populate the new table |
836 // with the existing strings. Set flag to use the alternate hash code afterwards. | 797 // with the existing strings. Set flag to use the alternate hash code afterwards. |