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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 entry->size_ = size; | 43 entry->size_ = size; |
44 entry->was_marked_black_ = was_marked_black; | 44 entry->was_marked_black_ = was_marked_black; |
45 | 45 |
46 // Assert no overflow into live objects. | 46 // Assert no overflow into live objects. |
47 #ifdef DEBUG | 47 #ifdef DEBUG |
48 SemiSpace::AssertValidRange(target->GetIsolate()->heap()->new_space()->top(), | 48 SemiSpace::AssertValidRange(target->GetIsolate()->heap()->new_space()->top(), |
49 reinterpret_cast<Address>(rear_)); | 49 reinterpret_cast<Address>(rear_)); |
50 #endif | 50 #endif |
51 } | 51 } |
52 | 52 |
| 53 void PromotionQueue::remove(HeapObject** target, int32_t* size, |
| 54 bool* was_marked_black) { |
| 55 DCHECK(!is_empty()); |
| 56 if (front_ == rear_) { |
| 57 Entry e = emergency_stack_->RemoveLast(); |
| 58 *target = e.obj_; |
| 59 *size = e.size_; |
| 60 *was_marked_black = e.was_marked_black_; |
| 61 return; |
| 62 } |
| 63 |
| 64 struct Entry* entry = reinterpret_cast<struct Entry*>(--front_); |
| 65 *target = entry->obj_; |
| 66 *size = entry->size_; |
| 67 *was_marked_black = entry->was_marked_black_; |
| 68 |
| 69 // Assert no underflow. |
| 70 SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_), |
| 71 reinterpret_cast<Address>(front_)); |
| 72 } |
| 73 |
| 74 Page* PromotionQueue::GetHeadPage() { |
| 75 return Page::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_)); |
| 76 } |
| 77 |
| 78 void PromotionQueue::SetNewLimit(Address limit) { |
| 79 // If we are already using an emergency stack, we can ignore it. |
| 80 if (emergency_stack_) return; |
| 81 |
| 82 // If the limit is not on the same page, we can ignore it. |
| 83 if (Page::FromAllocationAreaAddress(limit) != GetHeadPage()) return; |
| 84 |
| 85 limit_ = reinterpret_cast<struct Entry*>(limit); |
| 86 |
| 87 if (limit_ <= rear_) { |
| 88 return; |
| 89 } |
| 90 |
| 91 RelocateQueueHead(); |
| 92 } |
| 93 |
| 94 bool PromotionQueue::IsBelowPromotionQueue(Address to_space_top) { |
| 95 // If an emergency stack is used, the to-space address cannot interfere |
| 96 // with the promotion queue. |
| 97 if (emergency_stack_) return true; |
| 98 |
| 99 // If the given to-space top pointer and the head of the promotion queue |
| 100 // are not on the same page, then the to-space objects are below the |
| 101 // promotion queue. |
| 102 if (GetHeadPage() != Page::FromAddress(to_space_top)) { |
| 103 return true; |
| 104 } |
| 105 // If the to space top pointer is smaller or equal than the promotion |
| 106 // queue head, then the to-space objects are below the promotion queue. |
| 107 return reinterpret_cast<struct Entry*>(to_space_top) <= rear_; |
| 108 } |
53 | 109 |
54 #define ROOT_ACCESSOR(type, name, camel_name) \ | 110 #define ROOT_ACCESSOR(type, name, camel_name) \ |
55 type* Heap::name() { return type::cast(roots_[k##camel_name##RootIndex]); } | 111 type* Heap::name() { return type::cast(roots_[k##camel_name##RootIndex]); } |
56 ROOT_LIST(ROOT_ACCESSOR) | 112 ROOT_LIST(ROOT_ACCESSOR) |
57 #undef ROOT_ACCESSOR | 113 #undef ROOT_ACCESSOR |
58 | 114 |
59 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ | 115 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
60 Map* Heap::name##_map() { return Map::cast(roots_[k##Name##MapRootIndex]); } | 116 Map* Heap::name##_map() { return Map::cast(roots_[k##Name##MapRootIndex]); } |
61 STRUCT_LIST(STRUCT_MAP_ACCESSOR) | 117 STRUCT_LIST(STRUCT_MAP_ACCESSOR) |
62 #undef STRUCT_MAP_ACCESSOR | 118 #undef STRUCT_MAP_ACCESSOR |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 837 |
782 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 838 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
783 for (Object** current = start; current < end; current++) { | 839 for (Object** current = start; current < end; current++) { |
784 CHECK((*current)->IsSmi()); | 840 CHECK((*current)->IsSmi()); |
785 } | 841 } |
786 } | 842 } |
787 } // namespace internal | 843 } // namespace internal |
788 } // namespace v8 | 844 } // namespace v8 |
789 | 845 |
790 #endif // V8_HEAP_HEAP_INL_H_ | 846 #endif // V8_HEAP_HEAP_INL_H_ |
OLD | NEW |