OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 array_[bottom_] = object; | 233 array_[bottom_] = object; |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 HeapObject** array() { return array_; } | 237 HeapObject** array() { return array_; } |
238 int bottom() { return bottom_; } | 238 int bottom() { return bottom_; } |
239 int top() { return top_; } | 239 int top() { return top_; } |
240 int mask() { return mask_; } | 240 int mask() { return mask_; } |
241 void set_top(int top) { top_ = top; } | 241 void set_top(int top) { top_ = top; } |
242 | 242 |
243 int space_left() { | |
244 // If we already overflowed we may as well just say there is lots of | |
245 // space left. | |
246 if (overflowed_) return mask_ + 1; | |
247 if (IsEmpty()) return mask_ + 1; | |
248 if (IsFull()) return 0; | |
249 return (bottom_ - top_) & mask_; | |
250 } | |
251 | |
252 #ifdef DEBUG | |
253 const char* Status() { | |
254 if (overflowed_) return "Overflowed"; | |
255 if (IsEmpty()) return "Empty"; | |
256 if (IsFull()) return "Full"; | |
257 int oct = (((top_ - bottom_) & mask_) * 8) / (mask_ + 1); | |
258 switch (oct) { | |
259 case 0: return "Almost empty"; | |
260 case 1: return "1/8 full"; | |
261 case 2: return "2/8 full"; | |
262 case 3: return "3/8 full"; | |
263 case 4: return "4/8 full"; | |
264 case 5: return "5/8 full"; | |
265 case 6: return "6/8 full"; | |
266 case 7: return "7/8 full"; | |
267 } | |
268 return "??"; | |
269 } | |
270 #endif | |
271 | |
272 private: | 243 private: |
273 HeapObject** array_; | 244 HeapObject** array_; |
274 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is | 245 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is |
275 // empty when top_ == bottom_. It is full when top_ + 1 == bottom | 246 // empty when top_ == bottom_. It is full when top_ + 1 == bottom |
276 // (mod mask + 1). | 247 // (mod mask + 1). |
277 int top_; | 248 int top_; |
278 int bottom_; | 249 int bottom_; |
279 int mask_; | 250 int mask_; |
280 bool overflowed_; | 251 bool overflowed_; |
281 | 252 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 inline void set_encountered_weak_maps(Object* weak_map) { | 559 inline void set_encountered_weak_maps(Object* weak_map) { |
589 encountered_weak_maps_ = weak_map; | 560 encountered_weak_maps_ = weak_map; |
590 } | 561 } |
591 | 562 |
592 void InvalidateCode(Code* code); | 563 void InvalidateCode(Code* code); |
593 | 564 |
594 void ClearMarkbits(); | 565 void ClearMarkbits(); |
595 | 566 |
596 bool is_compacting() const { return compacting_; } | 567 bool is_compacting() const { return compacting_; } |
597 | 568 |
598 // Find the large objects that are not completely scanned, but have been | |
599 // postponed to later. | |
600 static void ProcessLargePostponedArrays(Heap* heap, MarkingDeque* deque); | |
601 | |
602 private: | 569 private: |
603 MarkCompactCollector(); | 570 MarkCompactCollector(); |
604 ~MarkCompactCollector(); | 571 ~MarkCompactCollector(); |
605 | 572 |
606 bool MarkInvalidatedCode(); | 573 bool MarkInvalidatedCode(); |
607 void RemoveDeadInvalidatedCode(); | 574 void RemoveDeadInvalidatedCode(); |
608 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 575 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
609 | 576 |
610 | 577 |
611 #ifdef DEBUG | 578 #ifdef DEBUG |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 761 |
795 friend class Heap; | 762 friend class Heap; |
796 }; | 763 }; |
797 | 764 |
798 | 765 |
799 const char* AllocationSpaceName(AllocationSpace space); | 766 const char* AllocationSpaceName(AllocationSpace space); |
800 | 767 |
801 } } // namespace v8::internal | 768 } } // namespace v8::internal |
802 | 769 |
803 #endif // V8_MARK_COMPACT_H_ | 770 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |