| 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 652 |
| 653 void Heap::ExternalStringTable::ShrinkNewStrings(int position) { | 653 void Heap::ExternalStringTable::ShrinkNewStrings(int position) { |
| 654 new_space_strings_.Rewind(position); | 654 new_space_strings_.Rewind(position); |
| 655 #ifdef VERIFY_HEAP | 655 #ifdef VERIFY_HEAP |
| 656 if (FLAG_verify_heap) { | 656 if (FLAG_verify_heap) { |
| 657 Verify(); | 657 Verify(); |
| 658 } | 658 } |
| 659 #endif | 659 #endif |
| 660 } | 660 } |
| 661 | 661 |
| 662 // static | |
| 663 int DescriptorLookupCache::Hash(Object* source, Name* name) { | |
| 664 DCHECK(name->IsUniqueName()); | |
| 665 // Uses only lower 32 bits if pointers are larger. | |
| 666 uint32_t source_hash = | |
| 667 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) >> | |
| 668 kPointerSizeLog2; | |
| 669 uint32_t name_hash = name->hash_field(); | |
| 670 return (source_hash ^ name_hash) % kLength; | |
| 671 } | |
| 672 | |
| 673 int DescriptorLookupCache::Lookup(Map* source, Name* name) { | |
| 674 int index = Hash(source, name); | |
| 675 Key& key = keys_[index]; | |
| 676 if ((key.source == source) && (key.name == name)) return results_[index]; | |
| 677 return kAbsent; | |
| 678 } | |
| 679 | |
| 680 | |
| 681 void DescriptorLookupCache::Update(Map* source, Name* name, int result) { | |
| 682 DCHECK(result != kAbsent); | |
| 683 int index = Hash(source, name); | |
| 684 Key& key = keys_[index]; | |
| 685 key.source = source; | |
| 686 key.name = name; | |
| 687 results_[index] = result; | |
| 688 } | |
| 689 | |
| 690 | |
| 691 void Heap::ClearInstanceofCache() { | 662 void Heap::ClearInstanceofCache() { |
| 692 set_instanceof_cache_function(Smi::FromInt(0)); | 663 set_instanceof_cache_function(Smi::FromInt(0)); |
| 693 } | 664 } |
| 694 | 665 |
| 695 Oddball* Heap::ToBoolean(bool condition) { | 666 Oddball* Heap::ToBoolean(bool condition) { |
| 696 return condition ? true_value() : false_value(); | 667 return condition ? true_value() : false_value(); |
| 697 } | 668 } |
| 698 | 669 |
| 699 | 670 |
| 700 void Heap::CompletelyClearInstanceofCache() { | 671 void Heap::CompletelyClearInstanceofCache() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 752 |
| 782 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 753 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
| 783 for (Object** current = start; current < end; current++) { | 754 for (Object** current = start; current < end; current++) { |
| 784 CHECK((*current)->IsSmi()); | 755 CHECK((*current)->IsSmi()); |
| 785 } | 756 } |
| 786 } | 757 } |
| 787 } // namespace internal | 758 } // namespace internal |
| 788 } // namespace v8 | 759 } // namespace v8 |
| 789 | 760 |
| 790 #endif // V8_HEAP_HEAP_INL_H_ | 761 #endif // V8_HEAP_HEAP_INL_H_ |
| OLD | NEW |