1.1 --- a/src/share/vm/utilities/hashtable.cpp Tue Jul 03 17:35:00 2012 -0700 1.2 +++ b/src/share/vm/utilities/hashtable.cpp Wed Jul 04 15:55:45 2012 -0400 1.3 @@ -23,6 +23,8 @@ 1.4 */ 1.5 1.6 #include "precompiled.hpp" 1.7 +#include "classfile/altHashing.hpp" 1.8 +#include "classfile/javaClasses.hpp" 1.9 #include "memory/allocation.inline.hpp" 1.10 #include "memory/filemap.hpp" 1.11 #include "memory/resourceArea.hpp" 1.12 @@ -90,12 +92,33 @@ 1.13 return false; 1.14 } 1.15 1.16 +template <class T, MEMFLAGS F> jint Hashtable<T, F>::_seed = 0; 1.17 + 1.18 +template <class T, MEMFLAGS F> unsigned int Hashtable<T, F>::new_hash(Symbol* sym) { 1.19 + ResourceMark rm; 1.20 + // Use alternate hashing algorithm on this symbol. 1.21 + return AltHashing::murmur3_32(seed(), (const jbyte*)sym->as_C_string(), sym->utf8_length()); 1.22 +} 1.23 + 1.24 +template <class T, MEMFLAGS F> unsigned int Hashtable<T, F>::new_hash(oop string) { 1.25 + ResourceMark rm; 1.26 + int length; 1.27 + jchar* chars = java_lang_String::as_unicode_string(string, length); 1.28 + // Use alternate hashing algorithm on the string 1.29 + return AltHashing::murmur3_32(seed(), chars, length); 1.30 +} 1.31 + 1.32 // Create a new table and using alternate hash code, populate the new table 1.33 // with the existing elements. This can be used to change the hash code 1.34 // and could in the future change the size of the table. 1.35 1.36 template <class T, MEMFLAGS F> void Hashtable<T, F>::move_to(Hashtable<T, F>* new_table) { 1.37 - int saved_entry_count = BasicHashtable<F>::number_of_entries(); 1.38 + 1.39 + // Initialize the global seed for hashing. 1.40 + _seed = AltHashing::compute_seed(); 1.41 + assert(seed() != 0, "shouldn't be zero"); 1.42 + 1.43 + int saved_entry_count = this->number_of_entries(); 1.44 1.45 // Iterate through the table and create a new entry for the new table 1.46 for (int i = 0; i < new_table->table_size(); ++i) {