Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1233)

Unified Diff: src/objects-inl.h

Issue 765473006: Make TemplateLiteral hashing algorithm more memory efficient (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Change assertions in StringHasher extensions, add comment about hash key usage Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 03aea64736d818f456c748f76a31d583593dc664..bfec3a49550340d4dc6f8bd81b3bd80fff588bac 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -6722,6 +6722,30 @@ uint32_t StringHasher::GetHashCore(uint32_t running_hash) {
}
+uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash,
+ const uc16* chars, int length) {
+ DCHECK_NOT_NULL(chars);
+ DCHECK(length >= 0);
+ for (int i = 0; i < length; ++i) {
+ running_hash = AddCharacterCore(running_hash, *chars++);
+ }
+ return running_hash;
+}
+
+
+uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash,
+ const char* chars,
+ int length) {
+ DCHECK_NOT_NULL(chars);
+ DCHECK(length >= 0);
+ for (int i = 0; i < length; ++i) {
+ uint16_t c = static_cast<uint16_t>(*chars++);
+ running_hash = AddCharacterCore(running_hash, c);
+ }
+ return running_hash;
+}
+
+
void StringHasher::AddCharacter(uint16_t c) {
// Use the Jenkins one-at-a-time hash function to update the hash
// for the given character.
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698