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 #ifndef V8_HEAP_HEAP_INL_H_ | 5 #ifndef V8_HEAP_HEAP_INL_H_ |
6 #define V8_HEAP_HEAP_INL_H_ | 6 #define V8_HEAP_HEAP_INL_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 void Heap::ExternalStringTable::ShrinkNewStrings(int position) { | 616 void Heap::ExternalStringTable::ShrinkNewStrings(int position) { |
617 new_space_strings_.Rewind(position); | 617 new_space_strings_.Rewind(position); |
618 #ifdef VERIFY_HEAP | 618 #ifdef VERIFY_HEAP |
619 if (FLAG_verify_heap) { | 619 if (FLAG_verify_heap) { |
620 Verify(); | 620 Verify(); |
621 } | 621 } |
622 #endif | 622 #endif |
623 } | 623 } |
624 | 624 |
| 625 // static |
| 626 int DescriptorLookupCache::Hash(Object* source, Name* name) { |
| 627 DCHECK(name->IsUniqueName()); |
| 628 // Uses only lower 32 bits if pointers are larger. |
| 629 uint32_t source_hash = |
| 630 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) >> |
| 631 kPointerSizeLog2; |
| 632 uint32_t name_hash = name->hash_field(); |
| 633 return (source_hash ^ name_hash) % kLength; |
| 634 } |
625 | 635 |
626 int DescriptorLookupCache::Lookup(Map* source, Name* name) { | 636 int DescriptorLookupCache::Lookup(Map* source, Name* name) { |
627 if (!name->IsUniqueName()) return kAbsent; | |
628 int index = Hash(source, name); | 637 int index = Hash(source, name); |
629 Key& key = keys_[index]; | 638 Key& key = keys_[index]; |
630 if ((key.source == source) && (key.name == name)) return results_[index]; | 639 if ((key.source == source) && (key.name == name)) return results_[index]; |
631 return kAbsent; | 640 return kAbsent; |
632 } | 641 } |
633 | 642 |
634 | 643 |
635 void DescriptorLookupCache::Update(Map* source, Name* name, int result) { | 644 void DescriptorLookupCache::Update(Map* source, Name* name, int result) { |
636 DCHECK(result != kAbsent); | 645 DCHECK(result != kAbsent); |
637 if (name->IsUniqueName()) { | 646 int index = Hash(source, name); |
638 int index = Hash(source, name); | 647 Key& key = keys_[index]; |
639 Key& key = keys_[index]; | 648 key.source = source; |
640 key.source = source; | 649 key.name = name; |
641 key.name = name; | 650 results_[index] = result; |
642 results_[index] = result; | |
643 } | |
644 } | 651 } |
645 | 652 |
646 | 653 |
647 void Heap::ClearInstanceofCache() { | 654 void Heap::ClearInstanceofCache() { |
648 set_instanceof_cache_function(Smi::FromInt(0)); | 655 set_instanceof_cache_function(Smi::FromInt(0)); |
649 } | 656 } |
650 | 657 |
651 | 658 |
652 Object* Heap::ToBoolean(bool condition) { | 659 Object* Heap::ToBoolean(bool condition) { |
653 return condition ? true_value() : false_value(); | 660 return condition ? true_value() : false_value(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 | 734 |
728 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 735 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
729 for (Object** current = start; current < end; current++) { | 736 for (Object** current = start; current < end; current++) { |
730 CHECK((*current)->IsSmi()); | 737 CHECK((*current)->IsSmi()); |
731 } | 738 } |
732 } | 739 } |
733 } // namespace internal | 740 } // namespace internal |
734 } // namespace v8 | 741 } // namespace v8 |
735 | 742 |
736 #endif // V8_HEAP_HEAP_INL_H_ | 743 #endif // V8_HEAP_HEAP_INL_H_ |
OLD | NEW |