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...) 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 |
243 private: | 272 private: |
244 HeapObject** array_; | 273 HeapObject** array_; |
245 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is | 274 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is |
246 // empty when top_ == bottom_. It is full when top_ + 1 == bottom | 275 // empty when top_ == bottom_. It is full when top_ + 1 == bottom |
247 // (mod mask + 1). | 276 // (mod mask + 1). |
248 int top_; | 277 int top_; |
249 int bottom_; | 278 int bottom_; |
250 int mask_; | 279 int mask_; |
251 bool overflowed_; | 280 bool overflowed_; |
252 | 281 |
(...skipping 422 matching lines...) Loading... |
675 // Mark objects reachable (transitively) from objects in the marking stack | 704 // Mark objects reachable (transitively) from objects in the marking stack |
676 // or overflowed in the heap. | 705 // or overflowed in the heap. |
677 void ProcessMarkingDeque(); | 706 void ProcessMarkingDeque(); |
678 | 707 |
679 // Mark objects reachable (transitively) from objects in the marking | 708 // Mark objects reachable (transitively) from objects in the marking |
680 // stack. This function empties the marking stack, but may leave | 709 // stack. This function empties the marking stack, but may leave |
681 // overflowed objects in the heap, in which case the marking stack's | 710 // overflowed objects in the heap, in which case the marking stack's |
682 // overflow flag will be set. | 711 // overflow flag will be set. |
683 void EmptyMarkingDeque(); | 712 void EmptyMarkingDeque(); |
684 | 713 |
| 714 // Find the large objects that are not completely scanned, but have been |
| 715 // postponed to later. |
| 716 void FillMarkingDequeFromLargePostponedArrays(); |
| 717 |
685 // Refill the marking stack with overflowed objects from the heap. This | 718 // Refill the marking stack with overflowed objects from the heap. This |
686 // function either leaves the marking stack full or clears the overflow | 719 // function either leaves the marking stack full or clears the overflow |
687 // flag on the marking stack. | 720 // flag on the marking stack. |
688 void RefillMarkingDeque(); | 721 void RefillMarkingDeque(); |
689 | 722 |
690 // After reachable maps have been marked process per context object | 723 // After reachable maps have been marked process per context object |
691 // literal map caches removing unmarked entries. | 724 // literal map caches removing unmarked entries. |
692 void ProcessMapCaches(); | 725 void ProcessMapCaches(); |
693 | 726 |
694 // Callback function for telling whether the object *p is an unmarked | 727 // Callback function for telling whether the object *p is an unmarked |
(...skipping 66 matching lines...) Loading... |
761 | 794 |
762 friend class Heap; | 795 friend class Heap; |
763 }; | 796 }; |
764 | 797 |
765 | 798 |
766 const char* AllocationSpaceName(AllocationSpace space); | 799 const char* AllocationSpaceName(AllocationSpace space); |
767 | 800 |
768 } } // namespace v8::internal | 801 } } // namespace v8::internal |
769 | 802 |
770 #endif // V8_MARK_COMPACT_H_ | 803 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |