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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 private: | 396 private: |
397 static const int kChainLengthThreshold = 15; | 397 static const int kChainLengthThreshold = 15; |
398 | 398 |
399 intptr_t idx_; | 399 intptr_t idx_; |
400 intptr_t chain_length_; | 400 intptr_t chain_length_; |
401 SlotsBuffer* next_; | 401 SlotsBuffer* next_; |
402 ObjectSlot slots_[kNumberOfElements]; | 402 ObjectSlot slots_[kNumberOfElements]; |
403 }; | 403 }; |
404 | 404 |
405 | 405 |
406 // ------------------------------------------------------------------------- | |
407 // Marker shared between incremental and non-incremental marking | |
408 template<class BaseMarker> class Marker { | |
409 public: | |
410 Marker(BaseMarker* base_marker, MarkCompactCollector* mark_compact_collector) | |
411 : base_marker_(base_marker), | |
412 mark_compact_collector_(mark_compact_collector) {} | |
413 | |
414 // Mark pointers in a Map and its DescriptorArray together, possibly | |
415 // treating transitions or back pointers weak. | |
416 void MarkMapContents(Map* map); | |
417 void MarkTransitionArray(TransitionArray* transitions); | |
418 | |
419 private: | |
420 BaseMarker* base_marker() { | |
421 return base_marker_; | |
422 } | |
423 | |
424 MarkCompactCollector* mark_compact_collector() { | |
425 return mark_compact_collector_; | |
426 } | |
427 | |
428 BaseMarker* base_marker_; | |
429 MarkCompactCollector* mark_compact_collector_; | |
430 }; | |
431 | |
432 | |
433 // Defined in isolate.h. | 406 // Defined in isolate.h. |
434 class ThreadLocalTop; | 407 class ThreadLocalTop; |
435 | 408 |
436 | 409 |
437 // ------------------------------------------------------------------------- | 410 // ------------------------------------------------------------------------- |
438 // Mark-Compact collector | 411 // Mark-Compact collector |
439 class MarkCompactCollector { | 412 class MarkCompactCollector { |
440 public: | 413 public: |
441 // Type of functions to compute forwarding addresses of objects in | 414 // Type of functions to compute forwarding addresses of objects in |
442 // compacted spaces. Given an object and its size, return a (non-failure) | 415 // compacted spaces. Given an object and its size, return a (non-failure) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 // MarkCompactCollector::Prepare() and is otherwise in its | 622 // MarkCompactCollector::Prepare() and is otherwise in its |
650 // normal state. | 623 // normal state. |
651 // | 624 // |
652 // After: Live objects are marked and non-live objects are unmarked. | 625 // After: Live objects are marked and non-live objects are unmarked. |
653 | 626 |
654 friend class RootMarkingVisitor; | 627 friend class RootMarkingVisitor; |
655 friend class MarkingVisitor; | 628 friend class MarkingVisitor; |
656 friend class MarkCompactMarkingVisitor; | 629 friend class MarkCompactMarkingVisitor; |
657 friend class CodeMarkingVisitor; | 630 friend class CodeMarkingVisitor; |
658 friend class SharedFunctionInfoMarkingVisitor; | 631 friend class SharedFunctionInfoMarkingVisitor; |
659 friend class Marker<IncrementalMarking>; | |
660 friend class Marker<MarkCompactCollector>; | |
661 | 632 |
662 // Mark non-optimize code for functions inlined into the given optimized | 633 // Mark non-optimize code for functions inlined into the given optimized |
663 // code. This will prevent it from being flushed. | 634 // code. This will prevent it from being flushed. |
664 void MarkInlinedFunctionsCode(Code* code); | 635 void MarkInlinedFunctionsCode(Code* code); |
665 | 636 |
666 // Mark code objects that are active on the stack to prevent them | 637 // Mark code objects that are active on the stack to prevent them |
667 // from being flushed. | 638 // from being flushed. |
668 void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top); | 639 void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top); |
669 | 640 |
670 void PrepareForCodeFlushing(); | 641 void PrepareForCodeFlushing(); |
671 | 642 |
672 // Marking operations for objects reachable from roots. | 643 // Marking operations for objects reachable from roots. |
673 void MarkLiveObjects(); | 644 void MarkLiveObjects(); |
674 | 645 |
675 void AfterMarking(); | 646 void AfterMarking(); |
676 | 647 |
677 // Marks the object black and pushes it on the marking stack. | 648 // Marks the object black and pushes it on the marking stack. |
678 // Returns true if object needed marking and false otherwise. | |
679 // This is for non-incremental marking only. | |
680 INLINE(bool MarkObjectAndPush(HeapObject* obj)); | |
681 | |
682 // Marks the object black and pushes it on the marking stack. | |
683 // This is for non-incremental marking only. | 649 // This is for non-incremental marking only. |
684 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit)); | 650 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit)); |
685 | 651 |
686 // Marks the object black without pushing it on the marking stack. | |
687 // Returns true if object needed marking and false otherwise. | |
688 // This is for non-incremental marking only. | |
689 INLINE(bool MarkObjectWithoutPush(HeapObject* obj)); | |
690 | |
691 // Marks the object black assuming that it is not yet marked. | 652 // Marks the object black assuming that it is not yet marked. |
692 // This is for non-incremental marking only. | 653 // This is for non-incremental marking only. |
693 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); | 654 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); |
694 | 655 |
695 void ProcessNewlyMarkedObject(HeapObject* obj); | |
696 | |
697 // Mark the heap roots and all objects reachable from them. | 656 // Mark the heap roots and all objects reachable from them. |
698 void MarkRoots(RootMarkingVisitor* visitor); | 657 void MarkRoots(RootMarkingVisitor* visitor); |
699 | 658 |
700 // Mark the symbol table specially. References to symbols from the | 659 // Mark the symbol table specially. References to symbols from the |
701 // symbol table are weak. | 660 // symbol table are weak. |
702 void MarkSymbolTable(); | 661 void MarkSymbolTable(); |
703 | 662 |
704 // Mark objects in object groups that have at least one object in the | 663 // Mark objects in object groups that have at least one object in the |
705 // group marked. | 664 // group marked. |
706 void MarkObjectGroups(); | 665 void MarkObjectGroups(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 static void VisitObject(HeapObject* obj); | 748 static void VisitObject(HeapObject* obj); |
790 | 749 |
791 friend class UnmarkObjectVisitor; | 750 friend class UnmarkObjectVisitor; |
792 static void UnmarkObject(HeapObject* obj); | 751 static void UnmarkObject(HeapObject* obj); |
793 #endif | 752 #endif |
794 | 753 |
795 Heap* heap_; | 754 Heap* heap_; |
796 MarkingDeque marking_deque_; | 755 MarkingDeque marking_deque_; |
797 CodeFlusher* code_flusher_; | 756 CodeFlusher* code_flusher_; |
798 Object* encountered_weak_maps_; | 757 Object* encountered_weak_maps_; |
799 Marker<MarkCompactCollector> marker_; | |
800 | 758 |
801 List<Page*> evacuation_candidates_; | 759 List<Page*> evacuation_candidates_; |
802 List<Code*> invalidated_code_; | 760 List<Code*> invalidated_code_; |
803 | 761 |
804 friend class Heap; | 762 friend class Heap; |
805 }; | 763 }; |
806 | 764 |
807 | 765 |
808 const char* AllocationSpaceName(AllocationSpace space); | 766 const char* AllocationSpaceName(AllocationSpace space); |
809 | 767 |
810 } } // namespace v8::internal | 768 } } // namespace v8::internal |
811 | 769 |
812 #endif // V8_MARK_COMPACT_H_ | 770 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |