Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/symbolTable.cpp @ 6201:ace99a6ffc83
7181200: JVM new hashing code breaks SA in product mode
Summary: Made new_hash() overloaded rather than a virtual function so SA code doesn't need to be changed.
Reviewed-by: kvn, acorn, dholmes, fparain
author | coleenp |
---|---|
date | Wed, 04 Jul 2012 15:55:45 -0400 |
parents | d2a62e0f25eb |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
6200:65906dc96aa1 | 6201:ace99a6ffc83 |
---|---|
41 | 41 |
42 SymbolTable* SymbolTable::_the_table = NULL; | 42 SymbolTable* SymbolTable::_the_table = NULL; |
43 // Static arena for symbols that are not deallocated | 43 // Static arena for symbols that are not deallocated |
44 Arena* SymbolTable::_arena = NULL; | 44 Arena* SymbolTable::_arena = NULL; |
45 bool SymbolTable::_needs_rehashing = false; | 45 bool SymbolTable::_needs_rehashing = false; |
46 jint SymbolTable::_seed = 0; | |
47 | 46 |
48 Symbol* SymbolTable::allocate_symbol(const u1* name, int len, bool c_heap, TRAPS) { | 47 Symbol* SymbolTable::allocate_symbol(const u1* name, int len, bool c_heap, TRAPS) { |
49 assert (len <= Symbol::max_length(), "should be checked by caller"); | 48 assert (len <= Symbol::max_length(), "should be checked by caller"); |
50 | 49 |
51 Symbol* sym; | 50 Symbol* sym; |
128 gclog_or_tty->print(" [Symbols=%d size=" SIZE_FORMAT "K] ", total, | 127 gclog_or_tty->print(" [Symbols=%d size=" SIZE_FORMAT "K] ", total, |
129 (memory_total*HeapWordSize)/1024); | 128 (memory_total*HeapWordSize)/1024); |
130 } | 129 } |
131 } | 130 } |
132 | 131 |
133 unsigned int SymbolTable::new_hash(Symbol* sym) { | |
134 ResourceMark rm; | |
135 // Use alternate hashing algorithm on this symbol. | |
136 return AltHashing::murmur3_32(seed(), (const jbyte*)sym->as_C_string(), sym->utf8_length()); | |
137 } | |
138 | |
139 // Create a new table and using alternate hash code, populate the new table | 132 // Create a new table and using alternate hash code, populate the new table |
140 // with the existing strings. Set flag to use the alternate hash code afterwards. | 133 // with the existing strings. Set flag to use the alternate hash code afterwards. |
141 void SymbolTable::rehash_table() { | 134 void SymbolTable::rehash_table() { |
142 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | 135 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
143 // This should never happen with -Xshare:dump but it might in testing mode. | 136 // This should never happen with -Xshare:dump but it might in testing mode. |
144 if (DumpSharedSpaces) return; | 137 if (DumpSharedSpaces) return; |
145 // Create a new symbol table | 138 // Create a new symbol table |
146 SymbolTable* new_table = new SymbolTable(); | 139 SymbolTable* new_table = new SymbolTable(); |
147 | |
148 // Initialize the global seed for hashing. | |
149 _seed = AltHashing::compute_seed(); | |
150 assert(seed() != 0, "shouldn't be zero"); | |
151 | 140 |
152 the_table()->move_to(new_table); | 141 the_table()->move_to(new_table); |
153 | 142 |
154 // Delete the table and buckets (entries are reused in new table). | 143 // Delete the table and buckets (entries are reused in new table). |
155 delete _the_table; | 144 delete _the_table; |
618 | 607 |
619 // -------------------------------------------------------------------------- | 608 // -------------------------------------------------------------------------- |
620 StringTable* StringTable::_the_table = NULL; | 609 StringTable* StringTable::_the_table = NULL; |
621 | 610 |
622 bool StringTable::_needs_rehashing = false; | 611 bool StringTable::_needs_rehashing = false; |
623 jint StringTable::_seed = 0; | |
624 | 612 |
625 // Pick hashing algorithm | 613 // Pick hashing algorithm |
626 unsigned int StringTable::hash_string(const jchar* s, int len) { | 614 unsigned int StringTable::hash_string(const jchar* s, int len) { |
627 return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) : | 615 return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) : |
628 java_lang_String::to_hash(s, len); | 616 java_lang_String::to_hash(s, len); |
835 st->print_cr("Std. dev. of bucket size: %7.0f", summary.sd()); | 823 st->print_cr("Std. dev. of bucket size: %7.0f", summary.sd()); |
836 st->print_cr("Maximum bucket size : %7.0f", summary.maximum()); | 824 st->print_cr("Maximum bucket size : %7.0f", summary.maximum()); |
837 } | 825 } |
838 | 826 |
839 | 827 |
840 unsigned int StringTable::new_hash(oop string) { | |
841 ResourceMark rm; | |
842 int length; | |
843 jchar* chars = java_lang_String::as_unicode_string(string, length); | |
844 // Use alternate hashing algorithm on the string | |
845 return AltHashing::murmur3_32(seed(), chars, length); | |
846 } | |
847 | |
848 // Create a new table and using alternate hash code, populate the new table | 828 // Create a new table and using alternate hash code, populate the new table |
849 // with the existing strings. Set flag to use the alternate hash code afterwards. | 829 // with the existing strings. Set flag to use the alternate hash code afterwards. |
850 void StringTable::rehash_table() { | 830 void StringTable::rehash_table() { |
851 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | 831 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
852 // This should never happen with -Xshare:dump but it might in testing mode. | 832 // This should never happen with -Xshare:dump but it might in testing mode. |
853 if (DumpSharedSpaces) return; | 833 if (DumpSharedSpaces) return; |
854 StringTable* new_table = new StringTable(); | 834 StringTable* new_table = new StringTable(); |
855 | 835 |
856 // Initialize new global seed for hashing. | |
857 _seed = AltHashing::compute_seed(); | |
858 assert(seed() != 0, "shouldn't be zero"); | |
859 | |
860 // Rehash the table | 836 // Rehash the table |
861 the_table()->move_to(new_table); | 837 the_table()->move_to(new_table); |
862 | 838 |
863 // Delete the table and buckets (entries are reused in new table). | 839 // Delete the table and buckets (entries are reused in new table). |
864 delete _the_table; | 840 delete _the_table; |