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

Side by Side 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 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 unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 6704 matching lines...) Expand 10 before | Expand all | Expand 10 after
6715 running_hash += (running_hash << 3); 6715 running_hash += (running_hash << 3);
6716 running_hash ^= (running_hash >> 11); 6716 running_hash ^= (running_hash >> 11);
6717 running_hash += (running_hash << 15); 6717 running_hash += (running_hash << 15);
6718 if ((running_hash & String::kHashBitMask) == 0) { 6718 if ((running_hash & String::kHashBitMask) == 0) {
6719 return kZeroHash; 6719 return kZeroHash;
6720 } 6720 }
6721 return running_hash; 6721 return running_hash;
6722 } 6722 }
6723 6723
6724 6724
6725 uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash,
6726 const uc16* chars, int length) {
6727 DCHECK_NOT_NULL(chars);
6728 DCHECK(length >= 0);
6729 for (int i = 0; i < length; ++i) {
6730 running_hash = AddCharacterCore(running_hash, *chars++);
6731 }
6732 return running_hash;
6733 }
6734
6735
6736 uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash,
6737 const char* chars,
6738 int length) {
6739 DCHECK_NOT_NULL(chars);
6740 DCHECK(length >= 0);
6741 for (int i = 0; i < length; ++i) {
6742 uint16_t c = static_cast<uint16_t>(*chars++);
6743 running_hash = AddCharacterCore(running_hash, c);
6744 }
6745 return running_hash;
6746 }
6747
6748
6725 void StringHasher::AddCharacter(uint16_t c) { 6749 void StringHasher::AddCharacter(uint16_t c) {
6726 // Use the Jenkins one-at-a-time hash function to update the hash 6750 // Use the Jenkins one-at-a-time hash function to update the hash
6727 // for the given character. 6751 // for the given character.
6728 raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); 6752 raw_running_hash_ = AddCharacterCore(raw_running_hash_, c);
6729 } 6753 }
6730 6754
6731 6755
6732 bool StringHasher::UpdateIndex(uint16_t c) { 6756 bool StringHasher::UpdateIndex(uint16_t c) {
6733 DCHECK(is_array_index_); 6757 DCHECK(is_array_index_);
6734 if (c < '0' || c > '9') { 6758 if (c < '0' || c > '9') {
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
7474 #undef READ_SHORT_FIELD 7498 #undef READ_SHORT_FIELD
7475 #undef WRITE_SHORT_FIELD 7499 #undef WRITE_SHORT_FIELD
7476 #undef READ_BYTE_FIELD 7500 #undef READ_BYTE_FIELD
7477 #undef WRITE_BYTE_FIELD 7501 #undef WRITE_BYTE_FIELD
7478 #undef NOBARRIER_READ_BYTE_FIELD 7502 #undef NOBARRIER_READ_BYTE_FIELD
7479 #undef NOBARRIER_WRITE_BYTE_FIELD 7503 #undef NOBARRIER_WRITE_BYTE_FIELD
7480 7504
7481 } } // namespace v8::internal 7505 } } // namespace v8::internal
7482 7506
7483 #endif // V8_OBJECTS_INL_H_ 7507 #endif // V8_OBJECTS_INL_H_
OLDNEW
« 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