| 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_MARK_COMPACT_H_ | 5 #ifndef V8_HEAP_MARK_COMPACT_H_ |
| 6 #define V8_HEAP_MARK_COMPACT_H_ | 6 #define V8_HEAP_MARK_COMPACT_H_ |
| 7 | 7 |
| 8 #include "src/base/bits.h" |
| 8 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 | 13 |
| 13 // Callback function, returns whether an object is alive. The heap size | 14 // Callback function, returns whether an object is alive. The heap size |
| 14 // of the object is returned in size. It optionally updates the offset | 15 // of the object is returned in size. It optionally updates the offset |
| 15 // to the first live object in the page (only used for old and map objects). | 16 // to the first live object in the page (only used for old and map objects). |
| 16 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); | 17 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); |
| 17 | 18 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Marking deque for tracing live objects. | 139 // Marking deque for tracing live objects. |
| 139 class MarkingDeque { | 140 class MarkingDeque { |
| 140 public: | 141 public: |
| 141 MarkingDeque() | 142 MarkingDeque() |
| 142 : array_(NULL), top_(0), bottom_(0), mask_(0), overflowed_(false) {} | 143 : array_(NULL), top_(0), bottom_(0), mask_(0), overflowed_(false) {} |
| 143 | 144 |
| 144 void Initialize(Address low, Address high) { | 145 void Initialize(Address low, Address high) { |
| 145 HeapObject** obj_low = reinterpret_cast<HeapObject**>(low); | 146 HeapObject** obj_low = reinterpret_cast<HeapObject**>(low); |
| 146 HeapObject** obj_high = reinterpret_cast<HeapObject**>(high); | 147 HeapObject** obj_high = reinterpret_cast<HeapObject**>(high); |
| 147 array_ = obj_low; | 148 array_ = obj_low; |
| 148 mask_ = RoundDownToPowerOf2(static_cast<int>(obj_high - obj_low)) - 1; | 149 mask_ = base::bits::RoundDownToPowerOfTwo32( |
| 150 static_cast<uint32_t>(obj_high - obj_low)) - |
| 151 1; |
| 149 top_ = bottom_ = 0; | 152 top_ = bottom_ = 0; |
| 150 overflowed_ = false; | 153 overflowed_ = false; |
| 151 } | 154 } |
| 152 | 155 |
| 153 inline bool IsFull() { return ((top_ + 1) & mask_) == bottom_; } | 156 inline bool IsFull() { return ((top_ + 1) & mask_) == bottom_; } |
| 154 | 157 |
| 155 inline bool IsEmpty() { return top_ == bottom_; } | 158 inline bool IsEmpty() { return top_ == bottom_; } |
| 156 | 159 |
| 157 bool overflowed() const { return overflowed_; } | 160 bool overflowed() const { return overflowed_; } |
| 158 | 161 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 private: | 947 private: |
| 945 MarkCompactCollector* collector_; | 948 MarkCompactCollector* collector_; |
| 946 }; | 949 }; |
| 947 | 950 |
| 948 | 951 |
| 949 const char* AllocationSpaceName(AllocationSpace space); | 952 const char* AllocationSpaceName(AllocationSpace space); |
| 950 } | 953 } |
| 951 } // namespace v8::internal | 954 } // namespace v8::internal |
| 952 | 955 |
| 953 #endif // V8_HEAP_MARK_COMPACT_H_ | 956 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |