| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 inline void set_encountered_weak_maps(Object* weak_map) { | 560 inline void set_encountered_weak_maps(Object* weak_map) { |
| 590 encountered_weak_maps_ = weak_map; | 561 encountered_weak_maps_ = weak_map; |
| 591 } | 562 } |
| 592 | 563 |
| 593 void InvalidateCode(Code* code); | 564 void InvalidateCode(Code* code); |
| 594 | 565 |
| 595 void ClearMarkbits(); | 566 void ClearMarkbits(); |
| 596 | 567 |
| 597 bool is_compacting() const { return compacting_; } | 568 bool is_compacting() const { return compacting_; } |
| 598 | 569 |
| 599 // Find the large objects that are not completely scanned, but have been | |
| 600 // postponed to later. | |
| 601 static void ProcessLargePostponedArrays(Heap* heap, MarkingDeque* deque); | |
| 602 | |
| 603 private: | 570 private: |
| 604 MarkCompactCollector(); | 571 MarkCompactCollector(); |
| 605 ~MarkCompactCollector(); | 572 ~MarkCompactCollector(); |
| 606 | 573 |
| 607 bool MarkInvalidatedCode(); | 574 bool MarkInvalidatedCode(); |
| 608 void RemoveDeadInvalidatedCode(); | 575 void RemoveDeadInvalidatedCode(); |
| 609 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 576 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 610 | 577 |
| 611 | 578 |
| 612 #ifdef DEBUG | 579 #ifdef DEBUG |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 762 |
| 796 friend class Heap; | 763 friend class Heap; |
| 797 }; | 764 }; |
| 798 | 765 |
| 799 | 766 |
| 800 const char* AllocationSpaceName(AllocationSpace space); | 767 const char* AllocationSpaceName(AllocationSpace space); |
| 801 | 768 |
| 802 } } // namespace v8::internal | 769 } } // namespace v8::internal |
| 803 | 770 |
| 804 #endif // V8_MARK_COMPACT_H_ | 771 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |