606 bool _cms_start_registered; |
606 bool _cms_start_registered; |
607 |
607 |
608 GCHeapSummary _last_heap_summary; |
608 GCHeapSummary _last_heap_summary; |
609 MetaspaceSummary _last_metaspace_summary; |
609 MetaspaceSummary _last_metaspace_summary; |
610 |
610 |
611 void register_foreground_gc_start(GCCause::Cause cause); |
|
612 void register_gc_start(GCCause::Cause cause); |
611 void register_gc_start(GCCause::Cause cause); |
613 void register_gc_end(); |
612 void register_gc_end(); |
614 void save_heap_summary(); |
613 void save_heap_summary(); |
615 void report_heap_summary(GCWhen::Type when); |
614 void report_heap_summary(GCWhen::Type when); |
616 |
615 |
758 NOT_PRODUCT(int _overflow_counter;) |
755 NOT_PRODUCT(int _overflow_counter;) |
759 NOT_PRODUCT(bool simulate_overflow();) // Sequential |
756 NOT_PRODUCT(bool simulate_overflow();) // Sequential |
760 NOT_PRODUCT(bool par_simulate_overflow();) // MT version |
757 NOT_PRODUCT(bool par_simulate_overflow();) // MT version |
761 |
758 |
762 // CMS work methods |
759 // CMS work methods |
763 void checkpointRootsInitialWork(bool asynch); // Initial checkpoint work |
760 void checkpointRootsInitialWork(); // Initial checkpoint work |
764 |
761 |
765 // A return value of false indicates failure due to stack overflow |
762 // A return value of false indicates failure due to stack overflow |
766 bool markFromRootsWork(bool asynch); // Concurrent marking work |
763 bool markFromRootsWork(); // Concurrent marking work |
767 |
764 |
768 public: // FIX ME!!! only for testing |
765 public: // FIX ME!!! only for testing |
769 bool do_marking_st(bool asynch); // Single-threaded marking |
766 bool do_marking_st(); // Single-threaded marking |
770 bool do_marking_mt(bool asynch); // Multi-threaded marking |
767 bool do_marking_mt(); // Multi-threaded marking |
771 |
768 |
772 private: |
769 private: |
773 |
770 |
774 // Concurrent precleaning work |
771 // Concurrent precleaning work |
775 size_t preclean_mod_union_table(ConcurrentMarkSweepGeneration* gen, |
772 size_t preclean_mod_union_table(ConcurrentMarkSweepGeneration* gen, |
786 void merge_survivor_plab_arrays(ContiguousSpace* surv, int no_of_gc_threads); |
783 void merge_survivor_plab_arrays(ContiguousSpace* surv, int no_of_gc_threads); |
787 // Resets (i.e. clears) the per-thread plab sample vectors |
784 // Resets (i.e. clears) the per-thread plab sample vectors |
788 void reset_survivor_plab_arrays(); |
785 void reset_survivor_plab_arrays(); |
789 |
786 |
790 // Final (second) checkpoint work |
787 // Final (second) checkpoint work |
791 void checkpointRootsFinalWork(bool asynch, bool clear_all_soft_refs, |
788 void checkpointRootsFinalWork(); |
792 bool init_mark_was_synchronous); |
|
793 // Work routine for parallel version of remark |
789 // Work routine for parallel version of remark |
794 void do_remark_parallel(); |
790 void do_remark_parallel(); |
795 // Work routine for non-parallel version of remark |
791 // Work routine for non-parallel version of remark |
796 void do_remark_non_parallel(); |
792 void do_remark_non_parallel(); |
797 // Reference processing work routine (during second checkpoint) |
793 // Reference processing work routine (during second checkpoint) |
798 void refProcessingWork(bool asynch, bool clear_all_soft_refs); |
794 void refProcessingWork(); |
799 |
795 |
800 // Concurrent sweeping work |
796 // Concurrent sweeping work |
801 void sweepWork(ConcurrentMarkSweepGeneration* gen, bool asynch); |
797 void sweepWork(ConcurrentMarkSweepGeneration* gen); |
802 |
798 |
803 // (Concurrent) resetting of support data structures |
799 // (Concurrent) resetting of support data structures |
804 void reset(bool asynch); |
800 void reset(bool concurrent); |
805 |
801 |
806 // Clear _expansion_cause fields of constituent generations |
802 // Clear _expansion_cause fields of constituent generations |
807 void clear_expansion_cause(); |
803 void clear_expansion_cause(); |
808 |
804 |
809 // An auxiliary method used to record the ends of |
805 // An auxiliary method used to record the ends of |
810 // used regions of each generation to limit the extent of sweep |
806 // used regions of each generation to limit the extent of sweep |
811 void save_sweep_limits(); |
807 void save_sweep_limits(); |
812 |
808 |
813 // A work method used by foreground collection to determine |
|
814 // what type of collection (compacting or not, continuing or fresh) |
|
815 // it should do. |
|
816 void decide_foreground_collection_type(bool clear_all_soft_refs, |
|
817 bool* should_compact, bool* should_start_over); |
|
818 |
|
819 // A work method used by the foreground collector to do |
809 // A work method used by the foreground collector to do |
820 // a mark-sweep-compact. |
810 // a mark-sweep-compact. |
821 void do_compaction_work(bool clear_all_soft_refs); |
811 void do_compaction_work(bool clear_all_soft_refs); |
822 |
|
823 // A work method used by the foreground collector to do |
|
824 // a mark-sweep, after taking over from a possibly on-going |
|
825 // concurrent mark-sweep collection. |
|
826 void do_mark_sweep_work(bool clear_all_soft_refs, |
|
827 CollectorState first_state, bool should_start_over); |
|
828 |
812 |
829 // Work methods for reporting concurrent mode interruption or failure |
813 // Work methods for reporting concurrent mode interruption or failure |
830 bool is_external_interruption(); |
814 bool is_external_interruption(); |
831 void report_concurrent_mode_interruption(); |
815 void report_concurrent_mode_interruption(); |
832 |
816 |
866 ConcurrentMarkSweepGeneration* cmsGen() { return _cmsGen; } |
850 ConcurrentMarkSweepGeneration* cmsGen() { return _cmsGen; } |
867 |
851 |
868 // Locking checks |
852 // Locking checks |
869 NOT_PRODUCT(static bool have_cms_token();) |
853 NOT_PRODUCT(static bool have_cms_token();) |
870 |
854 |
871 // XXXPERM bool should_collect(bool full, size_t size, bool tlab); |
|
872 bool shouldConcurrentCollect(); |
855 bool shouldConcurrentCollect(); |
873 |
856 |
874 void collect(bool full, |
857 void collect(bool full, |
875 bool clear_all_soft_refs, |
858 bool clear_all_soft_refs, |
876 size_t size, |
859 size_t size, |
877 bool tlab); |
860 bool tlab); |
878 void collect_in_background(bool clear_all_soft_refs, GCCause::Cause cause); |
861 void collect_in_background(GCCause::Cause cause); |
879 void collect_in_foreground(bool clear_all_soft_refs, GCCause::Cause cause); |
|
880 |
862 |
881 // In support of ExplicitGCInvokesConcurrent |
863 // In support of ExplicitGCInvokesConcurrent |
882 static void request_full_gc(unsigned int full_gc_count, GCCause::Cause cause); |
864 static void request_full_gc(unsigned int full_gc_count, GCCause::Cause cause); |
883 // Should we unload classes in a particular concurrent cycle? |
865 // Should we unload classes in a particular concurrent cycle? |
884 bool should_unload_classes() const { |
866 bool should_unload_classes() const { |
926 |
908 |
927 CMSBitMap* markBitMap() { return &_markBitMap; } |
909 CMSBitMap* markBitMap() { return &_markBitMap; } |
928 void directAllocated(HeapWord* start, size_t size); |
910 void directAllocated(HeapWord* start, size_t size); |
929 |
911 |
930 // Main CMS steps and related support |
912 // Main CMS steps and related support |
931 void checkpointRootsInitial(bool asynch); |
913 void checkpointRootsInitial(); |
932 bool markFromRoots(bool asynch); // a return value of false indicates failure |
914 bool markFromRoots(); // a return value of false indicates failure |
933 // due to stack overflow |
915 // due to stack overflow |
934 void preclean(); |
916 void preclean(); |
935 void checkpointRootsFinal(bool asynch, bool clear_all_soft_refs, |
917 void checkpointRootsFinal(); |
936 bool init_mark_was_synchronous); |
918 void sweep(); |
937 void sweep(bool asynch); |
|
938 |
919 |
939 // Check that the currently executing thread is the expected |
920 // Check that the currently executing thread is the expected |
940 // one (foreground collector or background collector). |
921 // one (foreground collector or background collector). |
941 static void check_correct_thread_executing() PRODUCT_RETURN; |
922 static void check_correct_thread_executing() PRODUCT_RETURN; |
942 // XXXPERM void print_statistics() PRODUCT_RETURN; |
|
943 |
923 |
944 bool is_cms_reachable(HeapWord* addr); |
924 bool is_cms_reachable(HeapWord* addr); |
945 |
925 |
946 // Performance Counter Support |
926 // Performance Counter Support |
947 CollectorCounters* counters() { return _gc_counters; } |
927 CollectorCounters* counters() { return _gc_counters; } |
1058 CMSExpansionCause::Cause _expansion_cause; |
1038 CMSExpansionCause::Cause _expansion_cause; |
1059 |
1039 |
1060 // In support of MinChunkSize being larger than min object size |
1040 // In support of MinChunkSize being larger than min object size |
1061 const double _dilatation_factor; |
1041 const double _dilatation_factor; |
1062 |
1042 |
1063 enum CollectionTypes { |
1043 bool _debug_concurrent_cycle; |
1064 Concurrent_collection_type = 0, |
|
1065 MS_foreground_collection_type = 1, |
|
1066 MSC_foreground_collection_type = 2, |
|
1067 Unknown_collection_type = 3 |
|
1068 }; |
|
1069 |
|
1070 CollectionTypes _debug_collection_type; |
|
1071 |
1044 |
1072 // True if a compacting collection was done. |
1045 // True if a compacting collection was done. |
1073 bool _did_compact; |
1046 bool _did_compact; |
1074 bool did_compact() { return _did_compact; } |
1047 bool did_compact() { return _did_compact; } |
1075 |
1048 |
1150 // Does a "full" (forced) collection invoked on this generation collect |
1123 // Does a "full" (forced) collection invoked on this generation collect |
1151 // all younger generations as well? Note that the second conjunct is a |
1124 // all younger generations as well? Note that the second conjunct is a |
1152 // hack to allow the collection of the younger gen first if the flag is |
1125 // hack to allow the collection of the younger gen first if the flag is |
1153 // set. |
1126 // set. |
1154 virtual bool full_collects_younger_generations() const { |
1127 virtual bool full_collects_younger_generations() const { |
1155 return UseCMSCompactAtFullCollection && !ScavengeBeforeFullGC; |
1128 return !ScavengeBeforeFullGC; |
1156 } |
1129 } |
1157 |
1130 |
1158 void space_iterate(SpaceClosure* blk, bool usedOnly = false); |
1131 void space_iterate(SpaceClosure* blk, bool usedOnly = false); |
1159 |
1132 |
1160 // Support for compaction |
1133 // Support for compaction |
1342 MemRegion _span; |
1315 MemRegion _span; |
1343 CMSBitMap* _bit_map; |
1316 CMSBitMap* _bit_map; |
1344 CMSBitMap* _mut; |
1317 CMSBitMap* _mut; |
1345 OopTaskQueue* _work_queue; |
1318 OopTaskQueue* _work_queue; |
1346 CMSMarkStack* _overflow_stack; |
1319 CMSMarkStack* _overflow_stack; |
1347 bool _yield; |
|
1348 int _skip_bits; |
1320 int _skip_bits; |
1349 HeapWord* _finger; |
1321 HeapWord* _finger; |
1350 HeapWord* _threshold; |
1322 HeapWord* _threshold; |
1351 CMSConcMarkingTask* _task; |
1323 CMSConcMarkingTask* _task; |
1352 public: |
1324 public: |
1353 Par_MarkFromRootsClosure(CMSConcMarkingTask* task, CMSCollector* collector, |
1325 Par_MarkFromRootsClosure(CMSConcMarkingTask* task, CMSCollector* collector, |
1354 MemRegion span, |
1326 MemRegion span, |
1355 CMSBitMap* bit_map, |
1327 CMSBitMap* bit_map, |
1356 OopTaskQueue* work_queue, |
1328 OopTaskQueue* work_queue, |
1357 CMSMarkStack* overflow_stack, |
1329 CMSMarkStack* overflow_stack); |
1358 bool should_yield); |
|
1359 bool do_bit(size_t offset); |
1330 bool do_bit(size_t offset); |
1360 inline void do_yield_check(); |
1331 inline void do_yield_check(); |
1361 |
1332 |
1362 private: |
1333 private: |
1363 void scan_oops_in_oop(HeapWord* ptr); |
1334 void scan_oops_in_oop(HeapWord* ptr); |