| 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 |
| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 inline void set_encountered_weak_maps(Object* weak_map) { | 588 inline void set_encountered_weak_maps(Object* weak_map) { |
| 560 encountered_weak_maps_ = weak_map; | 589 encountered_weak_maps_ = weak_map; |
| 561 } | 590 } |
| 562 | 591 |
| 563 void InvalidateCode(Code* code); | 592 void InvalidateCode(Code* code); |
| 564 | 593 |
| 565 void ClearMarkbits(); | 594 void ClearMarkbits(); |
| 566 | 595 |
| 567 bool is_compacting() const { return compacting_; } | 596 bool is_compacting() const { return compacting_; } |
| 568 | 597 |
| 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 |
| 569 private: | 602 private: |
| 570 MarkCompactCollector(); | 603 MarkCompactCollector(); |
| 571 ~MarkCompactCollector(); | 604 ~MarkCompactCollector(); |
| 572 | 605 |
| 573 bool MarkInvalidatedCode(); | 606 bool MarkInvalidatedCode(); |
| 574 void RemoveDeadInvalidatedCode(); | 607 void RemoveDeadInvalidatedCode(); |
| 575 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 608 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 576 | 609 |
| 577 | 610 |
| 578 #ifdef DEBUG | 611 #ifdef DEBUG |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |