-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Use a better hash seed when doing string hashing in the compiler #26685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,8 +391,7 @@ class ModuleFile::DeclTableInfo { | |
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
if (key.first == DeclBaseName::Kind::Normal) { | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key.second, 0); | ||
return llvm::djbHash(key.second, SWIFTMODULE_HASH_SEED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps factor this out into a ModuleFile::hashFunction(). I'm not sure whether this is much better, I'll leave it up to you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I considered that, but figured this was slightly more likely to keep people from doing the wrong thing in the future. I'm not 100% sure of that though. |
||
} else { | ||
return (hash_value_type)key.first; | ||
} | ||
|
@@ -454,8 +453,7 @@ class ModuleFile::ExtensionTableInfo { | |
} | ||
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key, 0); | ||
return llvm::djbHash(key, SWIFTMODULE_HASH_SEED); | ||
} | ||
|
||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { | ||
|
@@ -515,8 +513,7 @@ class ModuleFile::LocalDeclTableInfo { | |
} | ||
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key, 0); | ||
return llvm::djbHash(key, SWIFTMODULE_HASH_SEED); | ||
} | ||
|
||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { | ||
|
@@ -551,8 +548,7 @@ class ModuleFile::NestedTypeDeclsTableInfo { | |
} | ||
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key, 0); | ||
return llvm::djbHash(key, SWIFTMODULE_HASH_SEED); | ||
} | ||
|
||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { | ||
|
@@ -607,8 +603,7 @@ class ModuleFile::DeclMemberNamesTableInfo { | |
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
if (key.first == DeclBaseName::Kind::Normal) { | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key.second, 0); | ||
return llvm::djbHash(key.second, SWIFTMODULE_HASH_SEED); | ||
} else { | ||
return (hash_value_type)key.first; | ||
} | ||
|
@@ -782,8 +777,7 @@ class ModuleFile::ObjCMethodTableInfo { | |
} | ||
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key, 0); | ||
return llvm::djbHash(key, SWIFTMODULE_HASH_SEED); | ||
} | ||
|
||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { | ||
|
@@ -972,8 +966,7 @@ class ModuleFile::DeclCommentTableInfo { | |
|
||
hash_value_type ComputeHash(internal_key_type key) { | ||
assert(!key.empty()); | ||
// FIXME: DJB seed=0, audit whether the default seed could be used. | ||
return llvm::djbHash(key, 0); | ||
return llvm::djbHash(key, SWIFTDOC_HASH_SEED_5_1); | ||
} | ||
|
||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: Is the fact that the format depends on the hash seed a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's an OnDiskHashTable, so the hash used is inherently part of the format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!