681 // Attempts to steal an object from the task queues of other tasks |
681 // Attempts to steal an object from the task queues of other tasks |
682 bool try_stealing(uint worker_id, int* hash_seed, oop& obj) { |
682 bool try_stealing(uint worker_id, int* hash_seed, oop& obj) { |
683 return _task_queues->steal(worker_id, hash_seed, obj); |
683 return _task_queues->steal(worker_id, hash_seed, obj); |
684 } |
684 } |
685 |
685 |
686 ConcurrentMark(G1CollectedHeap* g1h, G1RegionToSpaceMapper* prev_bitmap_storage, G1RegionToSpaceMapper* next_bitmap_storage); |
686 ConcurrentMark(G1CollectedHeap* g1h, |
|
687 G1RegionToSpaceMapper* prev_bitmap_storage, |
|
688 G1RegionToSpaceMapper* next_bitmap_storage); |
687 ~ConcurrentMark(); |
689 ~ConcurrentMark(); |
688 |
690 |
689 ConcurrentMarkThread* cmThread() { return _cmThread; } |
691 ConcurrentMarkThread* cmThread() { return _cmThread; } |
690 |
692 |
691 CMBitMapRO* prevMarkBitMap() const { return _prevMarkBitMap; } |
693 CMBitMapRO* prevMarkBitMap() const { return _prevMarkBitMap; } |
710 // responsible for dealing with this issue (e.g., get the size from |
712 // responsible for dealing with this issue (e.g., get the size from |
711 // the from-space image when the to-space image might be |
713 // the from-space image when the to-space image might be |
712 // inconsistent) and always passing the size. hr is the region that |
714 // inconsistent) and always passing the size. hr is the region that |
713 // contains the object and it's passed optionally from callers who |
715 // contains the object and it's passed optionally from callers who |
714 // might already have it (no point in recalculating it). |
716 // might already have it (no point in recalculating it). |
715 inline void grayRoot(oop obj, size_t word_size, |
717 inline void grayRoot(oop obj, |
716 uint worker_id, HeapRegion* hr = NULL); |
718 size_t word_size, |
|
719 uint worker_id, |
|
720 HeapRegion* hr = NULL); |
717 |
721 |
718 // It iterates over the heap and for each object it comes across it |
722 // It iterates over the heap and for each object it comes across it |
719 // will dump the contents of its reference fields, as well as |
723 // will dump the contents of its reference fields, as well as |
720 // liveness information for the object and its referents. The dump |
724 // liveness information for the object and its referents. The dump |
721 // will be written to a file with the following name: |
725 // will be written to a file with the following name: |
732 // O : an object outside the G1 heap (typically: in the perm gen) |
736 // O : an object outside the G1 heap (typically: in the perm gen) |
733 // NOT : a reference field whose referent is not live |
737 // NOT : a reference field whose referent is not live |
734 // AND MARKED : indicates that an object is both explicitly and |
738 // AND MARKED : indicates that an object is both explicitly and |
735 // implicitly live (it should be one or the other, not both) |
739 // implicitly live (it should be one or the other, not both) |
736 void print_reachable(const char* str, |
740 void print_reachable(const char* str, |
737 VerifyOption vo, bool all) PRODUCT_RETURN; |
741 VerifyOption vo, |
|
742 bool all) PRODUCT_RETURN; |
738 |
743 |
739 // Clear the next marking bitmap (will be called concurrently). |
744 // Clear the next marking bitmap (will be called concurrently). |
740 void clearNextBitmap(); |
745 void clearNextBitmap(); |
741 |
746 |
742 // Return whether the next mark bitmap has no marks set. To be used for assertions |
747 // Return whether the next mark bitmap has no marks set. To be used for assertions |
769 |
774 |
770 // Mark in the previous bitmap. NB: this is usually read-only, so use |
775 // Mark in the previous bitmap. NB: this is usually read-only, so use |
771 // this carefully! |
776 // this carefully! |
772 inline void markPrev(oop p); |
777 inline void markPrev(oop p); |
773 |
778 |
774 // Clears marks for all objects in the given range, for the prev, |
779 // Clears marks for all objects in the given range, for the prev or |
775 // next, or both bitmaps. NB: the previous bitmap is usually |
780 // next bitmaps. NB: the previous bitmap is usually |
776 // read-only, so use this carefully! |
781 // read-only, so use this carefully! |
777 void clearRangePrevBitmap(MemRegion mr); |
782 void clearRangePrevBitmap(MemRegion mr); |
778 void clearRangeNextBitmap(MemRegion mr); |
783 void clearRangeNextBitmap(MemRegion mr); |
779 void clearRangeBothBitmaps(MemRegion mr); |
|
780 |
784 |
781 // Notify data structures that a GC has started. |
785 // Notify data structures that a GC has started. |
782 void note_start_of_gc() { |
786 void note_start_of_gc() { |
783 _markStack.note_start_of_gc(); |
787 _markStack.note_start_of_gc(); |
784 } |
788 } |
796 void verify_no_cset_oops(bool verify_stacks, |
800 void verify_no_cset_oops(bool verify_stacks, |
797 bool verify_enqueued_buffers, |
801 bool verify_enqueued_buffers, |
798 bool verify_thread_buffers, |
802 bool verify_thread_buffers, |
799 bool verify_fingers) PRODUCT_RETURN; |
803 bool verify_fingers) PRODUCT_RETURN; |
800 |
804 |
801 bool isMarked(oop p) const { |
|
802 assert(p != NULL && p->is_oop(), "expected an oop"); |
|
803 HeapWord* addr = (HeapWord*)p; |
|
804 assert(addr >= _nextMarkBitMap->startWord() || |
|
805 addr < _nextMarkBitMap->endWord(), "in a region"); |
|
806 |
|
807 return _nextMarkBitMap->isMarked(addr); |
|
808 } |
|
809 |
|
810 inline bool not_yet_marked(oop p) const; |
|
811 |
|
812 // XXX Debug code |
|
813 bool containing_card_is_marked(void* p); |
|
814 bool containing_cards_are_marked(void* start, void* last); |
|
815 |
|
816 bool isPrevMarked(oop p) const { |
805 bool isPrevMarked(oop p) const { |
817 assert(p != NULL && p->is_oop(), "expected an oop"); |
806 assert(p != NULL && p->is_oop(), "expected an oop"); |
818 HeapWord* addr = (HeapWord*)p; |
807 HeapWord* addr = (HeapWord*)p; |
819 assert(addr >= _prevMarkBitMap->startWord() || |
808 assert(addr >= _prevMarkBitMap->startWord() || |
820 addr < _prevMarkBitMap->endWord(), "in a region"); |
809 addr < _prevMarkBitMap->endWord(), "in a region"); |
896 |
885 |
897 // Counts the size of the given memory region in the the given |
886 // Counts the size of the given memory region in the the given |
898 // marked_bytes array slot for the given HeapRegion. |
887 // marked_bytes array slot for the given HeapRegion. |
899 // Sets the bits in the given card bitmap that are associated with the |
888 // Sets the bits in the given card bitmap that are associated with the |
900 // cards that are spanned by the memory region. |
889 // cards that are spanned by the memory region. |
901 inline void count_region(MemRegion mr, HeapRegion* hr, |
890 inline void count_region(MemRegion mr, |
|
891 HeapRegion* hr, |
902 size_t* marked_bytes_array, |
892 size_t* marked_bytes_array, |
903 BitMap* task_card_bm); |
893 BitMap* task_card_bm); |
904 |
894 |
905 // Counts the given memory region in the task/worker counting |
895 // Counts the given memory region in the task/worker counting |
906 // data structures for the given worker id. |
896 // data structures for the given worker id. |
907 inline void count_region(MemRegion mr, HeapRegion* hr, uint worker_id); |
897 inline void count_region(MemRegion mr, HeapRegion* hr, uint worker_id); |
908 |
898 |
909 // Counts the given memory region in the task/worker counting |
|
910 // data structures for the given worker id. |
|
911 inline void count_region(MemRegion mr, uint worker_id); |
|
912 |
|
913 // Counts the given object in the given task/worker counting |
899 // Counts the given object in the given task/worker counting |
914 // data structures. |
900 // data structures. |
915 inline void count_object(oop obj, HeapRegion* hr, |
901 inline void count_object(oop obj, |
|
902 HeapRegion* hr, |
916 size_t* marked_bytes_array, |
903 size_t* marked_bytes_array, |
917 BitMap* task_card_bm); |
904 BitMap* task_card_bm); |
918 |
905 |
919 // Counts the given object in the task/worker counting data |
|
920 // structures for the given worker id. |
|
921 inline void count_object(oop obj, HeapRegion* hr, uint worker_id); |
|
922 |
|
923 // Attempts to mark the given object and, if successful, counts |
906 // Attempts to mark the given object and, if successful, counts |
924 // the object in the given task/worker counting structures. |
907 // the object in the given task/worker counting structures. |
925 inline bool par_mark_and_count(oop obj, HeapRegion* hr, |
908 inline bool par_mark_and_count(oop obj, |
|
909 HeapRegion* hr, |
926 size_t* marked_bytes_array, |
910 size_t* marked_bytes_array, |
927 BitMap* task_card_bm); |
911 BitMap* task_card_bm); |
928 |
912 |
929 // Attempts to mark the given object and, if successful, counts |
913 // Attempts to mark the given object and, if successful, counts |
930 // the object in the task/worker counting structures for the |
914 // the object in the task/worker counting structures for the |
931 // given worker id. |
915 // given worker id. |
932 inline bool par_mark_and_count(oop obj, size_t word_size, |
916 inline bool par_mark_and_count(oop obj, |
933 HeapRegion* hr, uint worker_id); |
917 size_t word_size, |
934 |
918 HeapRegion* hr, |
935 // Attempts to mark the given object and, if successful, counts |
919 uint worker_id); |
936 // the object in the task/worker counting structures for the |
|
937 // given worker id. |
|
938 inline bool par_mark_and_count(oop obj, HeapRegion* hr, uint worker_id); |
|
939 |
|
940 // Similar to the above routine but we don't know the heap region that |
|
941 // contains the object to be marked/counted, which this routine looks up. |
|
942 inline bool par_mark_and_count(oop obj, uint worker_id); |
|
943 |
|
944 // Similar to the above routine but there are times when we cannot |
|
945 // safely calculate the size of obj due to races and we, therefore, |
|
946 // pass the size in as a parameter. It is the caller's reponsibility |
|
947 // to ensure that the size passed in for obj is valid. |
|
948 inline bool par_mark_and_count(oop obj, size_t word_size, uint worker_id); |
|
949 |
|
950 // Unconditionally mark the given object, and unconditinally count |
|
951 // the object in the counting structures for worker id 0. |
|
952 // Should *not* be called from parallel code. |
|
953 inline bool mark_and_count(oop obj, HeapRegion* hr); |
|
954 |
|
955 // Similar to the above routine but we don't know the heap region that |
|
956 // contains the object to be marked/counted, which this routine looks up. |
|
957 // Should *not* be called from parallel code. |
|
958 inline bool mark_and_count(oop obj); |
|
959 |
920 |
960 // Returns true if initialization was successfully completed. |
921 // Returns true if initialization was successfully completed. |
961 bool completed_initialization() const { |
922 bool completed_initialization() const { |
962 return _completed_initialization; |
923 return _completed_initialization; |
963 } |
924 } |