提交 73e608d2 编写于 作者: B brutisso

8004661: Comment and function name java_lang_String::toHash is wrong

Summary: renamed to hash_code
Reviewed-by: dholmes, coleenp, brutisso
Contributed-by: erik.helin@oracle.com
上级 7e1c6d64
...@@ -327,14 +327,14 @@ jchar* java_lang_String::as_unicode_string(oop java_string, int& length) { ...@@ -327,14 +327,14 @@ jchar* java_lang_String::as_unicode_string(oop java_string, int& length) {
return result; return result;
} }
unsigned int java_lang_String::to_hash(oop java_string) { unsigned int java_lang_String::hash_code(oop java_string) {
int length = java_lang_String::length(java_string); int length = java_lang_String::length(java_string);
// Zero length string will hash to zero with String.toHash() function. // Zero length string will hash to zero with String.hashCode() function.
if (length == 0) return 0; if (length == 0) return 0;
typeArrayOop value = java_lang_String::value(java_string); typeArrayOop value = java_lang_String::value(java_string);
int offset = java_lang_String::offset(java_string); int offset = java_lang_String::offset(java_string);
return java_lang_String::to_hash(value->char_at_addr(offset), length); return java_lang_String::hash_code(value->char_at_addr(offset), length);
} }
char* java_lang_String::as_quoted_ascii(oop java_string) { char* java_lang_String::as_quoted_ascii(oop java_string) {
......
...@@ -166,8 +166,8 @@ class java_lang_String : AllStatic { ...@@ -166,8 +166,8 @@ class java_lang_String : AllStatic {
// objects in the shared archive file. // objects in the shared archive file.
// hash P(31) from Kernighan & Ritchie // hash P(31) from Kernighan & Ritchie
// //
// For this reason, THIS ALGORITHM MUST MATCH String.toHash(). // For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
template <typename T> static unsigned int to_hash(T* s, int len) { template <typename T> static unsigned int hash_code(T* s, int len) {
unsigned int h = 0; unsigned int h = 0;
while (len-- > 0) { while (len-- > 0) {
h = 31*h + (unsigned int) *s; h = 31*h + (unsigned int) *s;
...@@ -175,10 +175,10 @@ class java_lang_String : AllStatic { ...@@ -175,10 +175,10 @@ class java_lang_String : AllStatic {
} }
return h; return h;
} }
static unsigned int to_hash(oop java_string); static unsigned int hash_code(oop java_string);
// This is the string hash code used by the StringTable, which may be // This is the string hash code used by the StringTable, which may be
// the same as String.toHash or an alternate hash code. // the same as String.hashCode or an alternate hash code.
static unsigned int hash_string(oop java_string); static unsigned int hash_string(oop java_string);
static bool equals(oop java_string, jchar* chars, int len); static bool equals(oop java_string, jchar* chars, int len);
......
...@@ -179,7 +179,7 @@ Symbol* SymbolTable::lookup(int index, const char* name, ...@@ -179,7 +179,7 @@ Symbol* SymbolTable::lookup(int index, const char* name,
unsigned int SymbolTable::hash_symbol(const char* s, int len) { unsigned int SymbolTable::hash_symbol(const char* s, int len) {
return use_alternate_hashcode() ? return use_alternate_hashcode() ?
AltHashing::murmur3_32(seed(), (const jbyte*)s, len) : AltHashing::murmur3_32(seed(), (const jbyte*)s, len) :
java_lang_String::to_hash(s, len); java_lang_String::hash_code(s, len);
} }
...@@ -617,7 +617,7 @@ bool StringTable::_needs_rehashing = false; ...@@ -617,7 +617,7 @@ bool StringTable::_needs_rehashing = false;
// Pick hashing algorithm // Pick hashing algorithm
unsigned int StringTable::hash_string(const jchar* s, int len) { unsigned int StringTable::hash_string(const jchar* s, int len) {
return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) : return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
java_lang_String::to_hash(s, len); java_lang_String::hash_code(s, len);
} }
oop StringTable::lookup(int index, jchar* name, oop StringTable::lookup(int index, jchar* name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册