equal
deleted
inserted
replaced
60 // String objects in the heap. Setting the hash value is not required. |
60 // String objects in the heap. Setting the hash value is not required. |
61 // However, setting the value in advance prevents the value from being |
61 // However, setting the value in advance prevents the value from being |
62 // written later, increasing the likelihood that the shared page contain |
62 // written later, increasing the likelihood that the shared page contain |
63 // the hash can be shared. |
63 // the hash can be shared. |
64 // |
64 // |
65 // NOTE THAT the algorithm in StringTable::hash_string() MUST MATCH the |
65 // NOTE THAT we have to call java_lang_String::to_hash() to match the |
66 // algorithm in java.lang.String.hashCode(). |
66 // algorithm in java.lang.String.toHash(). |
67 |
67 |
68 class StringHashCodeClosure: public OopClosure { |
68 class StringHashCodeClosure: public OopClosure { |
69 private: |
69 private: |
70 Thread* THREAD; |
70 Thread* THREAD; |
71 int hash_offset; |
71 int hash_offset; |
78 void do_oop(oop* p) { |
78 void do_oop(oop* p) { |
79 if (p != NULL) { |
79 if (p != NULL) { |
80 oop obj = *p; |
80 oop obj = *p; |
81 if (obj->klass() == SystemDictionary::String_klass() && |
81 if (obj->klass() == SystemDictionary::String_klass() && |
82 java_lang_String::has_hash_field()) { |
82 java_lang_String::has_hash_field()) { |
83 int hash = java_lang_String::hash_string(obj); |
83 int hash = java_lang_String::to_hash(obj); |
84 obj->int_field_put(hash_offset, hash); |
84 obj->int_field_put(hash_offset, hash); |
85 } |
85 } |
86 } |
86 } |
87 } |
87 } |
88 void do_oop(narrowOop* p) { ShouldNotReachHere(); } |
88 void do_oop(narrowOop* p) { ShouldNotReachHere(); } |