| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 void MigrateObject(Address dst, | 486 void MigrateObject(Address dst, |
| 487 Address src, | 487 Address src, |
| 488 int size, | 488 int size, |
| 489 AllocationSpace to_old_space); | 489 AllocationSpace to_old_space); |
| 490 | 490 |
| 491 bool TryPromoteObject(HeapObject* object, int object_size); | 491 bool TryPromoteObject(HeapObject* object, int object_size); |
| 492 | 492 |
| 493 inline Object* encountered_weak_maps() { return encountered_weak_maps_; } |
| 494 inline void set_encountered_weak_maps(Object* weak_map) { |
| 495 encountered_weak_maps_ = weak_map; |
| 496 } |
| 497 |
| 493 private: | 498 private: |
| 494 MarkCompactCollector(); | 499 MarkCompactCollector(); |
| 495 ~MarkCompactCollector(); | 500 ~MarkCompactCollector(); |
| 496 | 501 |
| 497 #ifdef DEBUG | 502 #ifdef DEBUG |
| 498 enum CollectorState { | 503 enum CollectorState { |
| 499 IDLE, | 504 IDLE, |
| 500 PREPARE_GC, | 505 PREPARE_GC, |
| 501 MARK_LIVE_OBJECTS, | 506 MARK_LIVE_OBJECTS, |
| 502 SWEEP_SPACES, | 507 SWEEP_SPACES, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 // Map transitions from a live map to a dead map must be killed. | 624 // Map transitions from a live map to a dead map must be killed. |
| 620 // We replace them with a null descriptor, with the same key. | 625 // We replace them with a null descriptor, with the same key. |
| 621 void ClearNonLiveTransitions(); | 626 void ClearNonLiveTransitions(); |
| 622 | 627 |
| 623 // Marking detaches initial maps from SharedFunctionInfo objects | 628 // Marking detaches initial maps from SharedFunctionInfo objects |
| 624 // to make this reference weak. We need to reattach initial maps | 629 // to make this reference weak. We need to reattach initial maps |
| 625 // back after collection. This is either done during | 630 // back after collection. This is either done during |
| 626 // ClearNonLiveTransitions pass or by calling this function. | 631 // ClearNonLiveTransitions pass or by calling this function. |
| 627 void ReattachInitialMaps(); | 632 void ReattachInitialMaps(); |
| 628 | 633 |
| 634 // Mark all values associated with reachable keys in weak maps encountered |
| 635 // so far. This might push new object or even new weak maps onto the |
| 636 // marking stack. |
| 637 void ProcessWeakMaps(); |
| 638 |
| 639 // After all reachable objects have been marked those weak map entries |
| 640 // with an unreachable key are removed from all encountered weak maps. |
| 641 // The linked list of all encountered weak maps is destroyed. |
| 642 void ClearWeakMaps(); |
| 643 |
| 629 // ----------------------------------------------------------------------- | 644 // ----------------------------------------------------------------------- |
| 630 // Phase 2: Sweeping to clear mark bits and free non-live objects for | 645 // Phase 2: Sweeping to clear mark bits and free non-live objects for |
| 631 // a non-compacting collection. | 646 // a non-compacting collection. |
| 632 // | 647 // |
| 633 // Before: Live objects are marked and non-live objects are unmarked. | 648 // Before: Live objects are marked and non-live objects are unmarked. |
| 634 // | 649 // |
| 635 // After: Live objects are unmarked, non-live regions have been added to | 650 // After: Live objects are unmarked, non-live regions have been added to |
| 636 // their space's free list. Active eden semispace is compacted by | 651 // their space's free list. Active eden semispace is compacted by |
| 637 // evacuation. | 652 // evacuation. |
| 638 // | 653 // |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 friend class MarkObjectVisitor; | 713 friend class MarkObjectVisitor; |
| 699 static void VisitObject(HeapObject* obj); | 714 static void VisitObject(HeapObject* obj); |
| 700 | 715 |
| 701 friend class UnmarkObjectVisitor; | 716 friend class UnmarkObjectVisitor; |
| 702 static void UnmarkObject(HeapObject* obj); | 717 static void UnmarkObject(HeapObject* obj); |
| 703 #endif | 718 #endif |
| 704 | 719 |
| 705 Heap* heap_; | 720 Heap* heap_; |
| 706 MarkingDeque marking_deque_; | 721 MarkingDeque marking_deque_; |
| 707 CodeFlusher* code_flusher_; | 722 CodeFlusher* code_flusher_; |
| 723 Object* encountered_weak_maps_; |
| 708 | 724 |
| 709 List<Page*> evacuation_candidates_; | 725 List<Page*> evacuation_candidates_; |
| 710 | 726 |
| 711 friend class Heap; | 727 friend class Heap; |
| 712 }; | 728 }; |
| 713 | 729 |
| 714 | 730 |
| 715 } } // namespace v8::internal | 731 } } // namespace v8::internal |
| 716 | 732 |
| 717 #endif // V8_MARK_COMPACT_H_ | 733 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |