754
755 // Scan all the root regions and mark everything reachable from
756 // them.
757 void scanRootRegions();
758
759 // Scan a single root region and mark everything reachable from it.
760 void scanRootRegion(HeapRegion* hr, uint worker_id);
761
762 // Do concurrent phase of marking, to a tentative transitive closure.
763 void markFromRoots();
764
765 void checkpointRootsFinal(bool clear_all_soft_refs);
766 void checkpointRootsFinalWork();
767 void cleanup();
768 void completeCleanup();
769
770 // Mark in the previous bitmap. NB: this is usually read-only, so use
771 // this carefully!
772 inline void markPrev(oop p);
773
774 // Clears marks for all objects in the given range, for the prev,
775 // next, or both bitmaps. NB: the previous bitmap is usually
776 // read-only, so use this carefully!
777 void clearRangePrevBitmap(MemRegion mr);
778 void clearRangeNextBitmap(MemRegion mr);
779 void clearRangeBothBitmaps(MemRegion mr);
780
781 // Notify data structures that a GC has started.
782 void note_start_of_gc() {
783 _markStack.note_start_of_gc();
784 }
785
786 // Notify data structures that a GC is finished.
787 void note_end_of_gc() {
788 _markStack.note_end_of_gc();
789 }
790
791 // Verify that there are no CSet oops on the stacks (taskqueues /
792 // global mark stack), enqueued SATB buffers, per-thread SATB
793 // buffers, and fingers (global / per-task). The boolean parameters
794 // decide which of the above data structures to verify. If marking
795 // is not in progress, it's a no-op.
796 void verify_no_cset_oops(bool verify_stacks,
797 bool verify_enqueued_buffers,
798 bool verify_thread_buffers,
799 bool verify_fingers) PRODUCT_RETURN;
800
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 {
817 assert(p != NULL && p->is_oop(), "expected an oop");
818 HeapWord* addr = (HeapWord*)p;
819 assert(addr >= _prevMarkBitMap->startWord() ||
820 addr < _prevMarkBitMap->endWord(), "in a region");
821
822 return _prevMarkBitMap->isMarked(addr);
823 }
824
825 inline bool do_yield_check(uint worker_i = 0);
826
827 // Called to abort the marking cycle after a Full GC takes place.
828 void abort();
829
830 bool has_aborted() { return _has_aborted; }
831
832 const GCId& concurrent_gc_id();
833
834 // This prints the global/local fingers. It is used for debugging.
835 NOT_PRODUCT(void print_finger();)
889 assert(marked_bytes_array != NULL, "uninitialized");
890 return marked_bytes_array;
891 }
892
893 // Returns the index in the liveness accounting card table bitmap
894 // for the given address
895 inline BitMap::idx_t card_bitmap_index_for(HeapWord* addr);
896
897 // Counts the size of the given memory region in the the given
898 // marked_bytes array slot for the given HeapRegion.
899 // Sets the bits in the given card bitmap that are associated with the
900 // cards that are spanned by the memory region.
901 inline void count_region(MemRegion mr, HeapRegion* hr,
902 size_t* marked_bytes_array,
903 BitMap* task_card_bm);
904
905 // Counts the given memory region in the task/worker counting
906 // data structures for the given worker id.
907 inline void count_region(MemRegion mr, HeapRegion* hr, uint worker_id);
908
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
914 // data structures.
915 inline void count_object(oop obj, HeapRegion* hr,
916 size_t* marked_bytes_array,
917 BitMap* task_card_bm);
918
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
924 // the object in the given task/worker counting structures.
925 inline bool par_mark_and_count(oop obj, HeapRegion* hr,
926 size_t* marked_bytes_array,
927 BitMap* task_card_bm);
928
929 // Attempts to mark the given object and, if successful, counts
930 // the object in the task/worker counting structures for the
931 // given worker id.
932 inline bool par_mark_and_count(oop obj, size_t word_size,
933 HeapRegion* hr, uint worker_id);
934
935 // Attempts to mark the given object and, if successful, counts
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 responsibility
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 unconditionally 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
960 // Returns true if initialization was successfully completed.
961 bool completed_initialization() const {
962 return _completed_initialization;
963 }
964
965 protected:
966 // Clear all the per-task bitmaps and arrays used to store the
967 // counting data.
968 void clear_all_count_data();
969
970 // Aggregates the counting data for each worker/task
971 // that was constructed while marking. Also sets
972 // the amount of marked bytes for each region and
973 // the top at concurrent mark count.
974 void aggregate_count_data();
975
976 // Verification routine
977 void verify_count_data();
978 };
|
754
755 // Scan all the root regions and mark everything reachable from
756 // them.
757 void scanRootRegions();
758
759 // Scan a single root region and mark everything reachable from it.
760 void scanRootRegion(HeapRegion* hr, uint worker_id);
761
762 // Do concurrent phase of marking, to a tentative transitive closure.
763 void markFromRoots();
764
765 void checkpointRootsFinal(bool clear_all_soft_refs);
766 void checkpointRootsFinalWork();
767 void cleanup();
768 void completeCleanup();
769
770 // Mark in the previous bitmap. NB: this is usually read-only, so use
771 // this carefully!
772 inline void markPrev(oop p);
773
774 // Clears marks for all objects in the given range, for the prev or
775 // next bitmaps. NB: the previous bitmap is usually
776 // read-only, so use this carefully!
777 void clearRangePrevBitmap(MemRegion mr);
778 void clearRangeNextBitmap(MemRegion mr);
779
780 // Notify data structures that a GC has started.
781 void note_start_of_gc() {
782 _markStack.note_start_of_gc();
783 }
784
785 // Notify data structures that a GC is finished.
786 void note_end_of_gc() {
787 _markStack.note_end_of_gc();
788 }
789
790 // Verify that there are no CSet oops on the stacks (taskqueues /
791 // global mark stack), enqueued SATB buffers, per-thread SATB
792 // buffers, and fingers (global / per-task). The boolean parameters
793 // decide which of the above data structures to verify. If marking
794 // is not in progress, it's a no-op.
795 void verify_no_cset_oops(bool verify_stacks,
796 bool verify_enqueued_buffers,
797 bool verify_thread_buffers,
798 bool verify_fingers) PRODUCT_RETURN;
799
800 bool isPrevMarked(oop p) const {
801 assert(p != NULL && p->is_oop(), "expected an oop");
802 HeapWord* addr = (HeapWord*)p;
803 assert(addr >= _prevMarkBitMap->startWord() ||
804 addr < _prevMarkBitMap->endWord(), "in a region");
805
806 return _prevMarkBitMap->isMarked(addr);
807 }
808
809 inline bool do_yield_check(uint worker_i = 0);
810
811 // Called to abort the marking cycle after a Full GC takes place.
812 void abort();
813
814 bool has_aborted() { return _has_aborted; }
815
816 const GCId& concurrent_gc_id();
817
818 // This prints the global/local fingers. It is used for debugging.
819 NOT_PRODUCT(void print_finger();)
873 assert(marked_bytes_array != NULL, "uninitialized");
874 return marked_bytes_array;
875 }
876
877 // Returns the index in the liveness accounting card table bitmap
878 // for the given address
879 inline BitMap::idx_t card_bitmap_index_for(HeapWord* addr);
880
881 // Counts the size of the given memory region in the the given
882 // marked_bytes array slot for the given HeapRegion.
883 // Sets the bits in the given card bitmap that are associated with the
884 // cards that are spanned by the memory region.
885 inline void count_region(MemRegion mr, HeapRegion* hr,
886 size_t* marked_bytes_array,
887 BitMap* task_card_bm);
888
889 // Counts the given memory region in the task/worker counting
890 // data structures for the given worker id.
891 inline void count_region(MemRegion mr, HeapRegion* hr, uint worker_id);
892
893 // Counts the given object in the given task/worker counting
894 // data structures.
895 inline void count_object(oop obj, HeapRegion* hr,
896 size_t* marked_bytes_array,
897 BitMap* task_card_bm);
898
899 // Attempts to mark the given object and, if successful, counts
900 // the object in the given task/worker counting structures.
901 inline bool par_mark_and_count(oop obj,
902 HeapRegion* hr,
903 size_t* marked_bytes_array,
904 BitMap* task_card_bm);
905
906 // Attempts to mark the given object and, if successful, counts
907 // the object in the task/worker counting structures for the
908 // given worker id.
909 inline bool par_mark_and_count(oop obj,
910 size_t word_size,
911 HeapRegion* hr,
912 uint worker_id);
913
914 // Returns true if initialization was successfully completed.
915 bool completed_initialization() const {
916 return _completed_initialization;
917 }
918
919 protected:
920 // Clear all the per-task bitmaps and arrays used to store the
921 // counting data.
922 void clear_all_count_data();
923
924 // Aggregates the counting data for each worker/task
925 // that was constructed while marking. Also sets
926 // the amount of marked bytes for each region and
927 // the top at concurrent mark count.
928 void aggregate_count_data();
929
930 // Verification routine
931 void verify_count_data();
932 };
|