OLD | NEW |
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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 745 |
746 | 746 |
747 // Used to insert a deserialized internalized string into the string table. | 747 // Used to insert a deserialized internalized string into the string table. |
748 class StringTableInsertionKey : public HashTableKey { | 748 class StringTableInsertionKey : public HashTableKey { |
749 public: | 749 public: |
750 explicit StringTableInsertionKey(String* string) | 750 explicit StringTableInsertionKey(String* string) |
751 : string_(string), hash_(HashForObject(string)) { | 751 : string_(string), hash_(HashForObject(string)) { |
752 DCHECK(string->IsInternalizedString()); | 752 DCHECK(string->IsInternalizedString()); |
753 } | 753 } |
754 | 754 |
755 virtual bool IsMatch(Object* string) { | 755 virtual bool IsMatch(Object* string) OVERRIDE { |
756 // We know that all entries in a hash table had their hash keys created. | 756 // We know that all entries in a hash table had their hash keys created. |
757 // Use that knowledge to have fast failure. | 757 // Use that knowledge to have fast failure. |
758 if (hash_ != HashForObject(string)) return false; | 758 if (hash_ != HashForObject(string)) return false; |
759 // We want to compare the content of two internalized strings here. | 759 // We want to compare the content of two internalized strings here. |
760 return string_->SlowEquals(String::cast(string)); | 760 return string_->SlowEquals(String::cast(string)); |
761 } | 761 } |
762 | 762 |
763 virtual uint32_t Hash() OVERRIDE { return hash_; } | 763 virtual uint32_t Hash() OVERRIDE { return hash_; } |
764 | 764 |
765 virtual uint32_t HashForObject(Object* key) OVERRIDE { | 765 virtual uint32_t HashForObject(Object* key) OVERRIDE { |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2324 | 2324 |
2325 int SerializedCodeData::CheckSum(String* string) { | 2325 int SerializedCodeData::CheckSum(String* string) { |
2326 int checksum = Version::Hash(); | 2326 int checksum = Version::Hash(); |
2327 #ifdef DEBUG | 2327 #ifdef DEBUG |
2328 uint32_t seed = static_cast<uint32_t>(checksum); | 2328 uint32_t seed = static_cast<uint32_t>(checksum); |
2329 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); | 2329 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); |
2330 #endif // DEBUG | 2330 #endif // DEBUG |
2331 return checksum; | 2331 return checksum; |
2332 } | 2332 } |
2333 } } // namespace v8::internal | 2333 } } // namespace v8::internal |
OLD | NEW |