src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


 654   // Create jstat counters for the policy.
 655   virtual void initialize_gc_policy_counters();
 656 
 657   virtual HeapWord* mem_allocate_work(size_t size,
 658                                       bool is_tlab,
 659                                       bool* gc_overhead_limit_was_exceeded);
 660 
 661   // This method controls how a collector handles one or more
 662   // of its generations being fully allocated.
 663   virtual HeapWord* satisfy_failed_allocation(size_t size,
 664                                               bool is_tlab);
 665 
 666   BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
 667 
 668   GenRemSet::Name  rem_set_name()     { return GenRemSet::CardTable; }
 669 
 670   bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0);
 671 
 672   // Record the start and end of an evacuation pause.
 673   void record_collection_pause_start(double start_time_sec);
 674   void record_collection_pause_end(double pause_time_ms);
 675 
 676   // Record the start and end of a full collection.
 677   void record_full_collection_start();
 678   void record_full_collection_end();
 679 
 680   // Must currently be called while the world is stopped.
 681   void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms);
 682 
 683   // Record start and end of remark.
 684   void record_concurrent_mark_remark_start();
 685   void record_concurrent_mark_remark_end();
 686 
 687   // Record start, end, and completion of cleanup.
 688   void record_concurrent_mark_cleanup_start();
 689   void record_concurrent_mark_cleanup_end(int no_of_gc_threads);
 690   void record_concurrent_mark_cleanup_completed();
 691 
 692   // Records the information about the heap size for reporting in
 693   // print_detailed_heap_transition
 694   void record_heap_size_info_at_start(bool full);


 703   // Record how much space we copied during a GC. This is typically
 704   // called when a GC alloc region is being retired.
 705   void record_bytes_copied_during_gc(size_t bytes) {
 706     _bytes_copied_during_gc += bytes;
 707   }
 708 
 709   // The amount of space we copied during a GC.
 710   size_t bytes_copied_during_gc() {
 711     return _bytes_copied_during_gc;
 712   }
 713 
 714   // Determine whether there are candidate regions so that the
 715   // next GC should be mixed. The two action strings are used
 716   // in the ergo output when the method returns true or false.
 717   bool next_gc_should_be_mixed(const char* true_action_str,
 718                                const char* false_action_str);
 719 
 720   // Choose a new collection set.  Marks the chosen regions as being
 721   // "in_collection_set", and links them together.  The head and number of
 722   // the collection set are available via access methods.
 723   void finalize_cset(double target_pause_time_ms);
 724 
 725   // The head of the list (via "next_in_collection_set()") representing the
 726   // current collection set.
 727   HeapRegion* collection_set() { return _collection_set; }
 728 
 729   void clear_collection_set() { _collection_set = NULL; }
 730 
 731   // Add old region "hr" to the CSet.
 732   void add_old_region_to_cset(HeapRegion* hr);
 733 
 734   // Incremental CSet Support
 735 
 736   // The head of the incrementally built collection set.
 737   HeapRegion* inc_cset_head() { return _inc_cset_head; }
 738 
 739   // The tail of the incrementally built collection set.
 740   HeapRegion* inc_set_tail() { return _inc_cset_tail; }
 741 
 742   // Initialize incremental collection set info.
 743   void start_incremental_cset_building();


 862   // The value of _heap_bytes_before_gc is also used to calculate
 863   // the cost of copying.
 864 
 865   size_t _eden_used_bytes_before_gc;         // Eden occupancy before GC
 866   size_t _survivor_used_bytes_before_gc;     // Survivor occupancy before GC
 867   size_t _heap_used_bytes_before_gc;         // Heap occupancy before GC
 868   size_t _metaspace_used_bytes_before_gc;    // Metaspace occupancy before GC
 869 
 870   size_t _eden_capacity_bytes_before_gc;     // Eden capacity before GC
 871   size_t _heap_capacity_bytes_before_gc;     // Heap capacity before GC
 872 
 873   // The amount of survivor regions after a collection.
 874   uint _recorded_survivor_regions;
 875   // List of survivor regions.
 876   HeapRegion* _recorded_survivor_head;
 877   HeapRegion* _recorded_survivor_tail;
 878 
 879   ageTable _survivors_age_table;
 880 
 881 public:

 882 
 883   inline GCAllocPurpose
 884     evacuation_destination(HeapRegion* src_region, uint age, size_t word_sz) {
 885       if (age < _tenuring_threshold && src_region->is_young()) {
 886         return GCAllocForSurvived;
 887       } else {
 888         return GCAllocForTenured;
 889       }
 890   }
 891 
 892   inline bool track_object_age(GCAllocPurpose purpose) {
 893     return purpose == GCAllocForSurvived;
 894   }
 895 
 896   static const uint REGIONS_UNLIMITED = (uint) -1;
 897 
 898   uint max_regions(int purpose);
 899 
 900   // The limit on regions for a particular purpose is reached.
 901   void note_alloc_region_limit_reached(int purpose) {




 654   // Create jstat counters for the policy.
 655   virtual void initialize_gc_policy_counters();
 656 
 657   virtual HeapWord* mem_allocate_work(size_t size,
 658                                       bool is_tlab,
 659                                       bool* gc_overhead_limit_was_exceeded);
 660 
 661   // This method controls how a collector handles one or more
 662   // of its generations being fully allocated.
 663   virtual HeapWord* satisfy_failed_allocation(size_t size,
 664                                               bool is_tlab);
 665 
 666   BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
 667 
 668   GenRemSet::Name  rem_set_name()     { return GenRemSet::CardTable; }
 669 
 670   bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0);
 671 
 672   // Record the start and end of an evacuation pause.
 673   void record_collection_pause_start(double start_time_sec);
 674   void record_collection_pause_end(double pause_time_ms, EvacuationInfo& evacuation_info);
 675 
 676   // Record the start and end of a full collection.
 677   void record_full_collection_start();
 678   void record_full_collection_end();
 679 
 680   // Must currently be called while the world is stopped.
 681   void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms);
 682 
 683   // Record start and end of remark.
 684   void record_concurrent_mark_remark_start();
 685   void record_concurrent_mark_remark_end();
 686 
 687   // Record start, end, and completion of cleanup.
 688   void record_concurrent_mark_cleanup_start();
 689   void record_concurrent_mark_cleanup_end(int no_of_gc_threads);
 690   void record_concurrent_mark_cleanup_completed();
 691 
 692   // Records the information about the heap size for reporting in
 693   // print_detailed_heap_transition
 694   void record_heap_size_info_at_start(bool full);


 703   // Record how much space we copied during a GC. This is typically
 704   // called when a GC alloc region is being retired.
 705   void record_bytes_copied_during_gc(size_t bytes) {
 706     _bytes_copied_during_gc += bytes;
 707   }
 708 
 709   // The amount of space we copied during a GC.
 710   size_t bytes_copied_during_gc() {
 711     return _bytes_copied_during_gc;
 712   }
 713 
 714   // Determine whether there are candidate regions so that the
 715   // next GC should be mixed. The two action strings are used
 716   // in the ergo output when the method returns true or false.
 717   bool next_gc_should_be_mixed(const char* true_action_str,
 718                                const char* false_action_str);
 719 
 720   // Choose a new collection set.  Marks the chosen regions as being
 721   // "in_collection_set", and links them together.  The head and number of
 722   // the collection set are available via access methods.
 723   void finalize_cset(double target_pause_time_ms, EvacuationInfo& evacuation_info);
 724 
 725   // The head of the list (via "next_in_collection_set()") representing the
 726   // current collection set.
 727   HeapRegion* collection_set() { return _collection_set; }
 728 
 729   void clear_collection_set() { _collection_set = NULL; }
 730 
 731   // Add old region "hr" to the CSet.
 732   void add_old_region_to_cset(HeapRegion* hr);
 733 
 734   // Incremental CSet Support
 735 
 736   // The head of the incrementally built collection set.
 737   HeapRegion* inc_cset_head() { return _inc_cset_head; }
 738 
 739   // The tail of the incrementally built collection set.
 740   HeapRegion* inc_set_tail() { return _inc_cset_tail; }
 741 
 742   // Initialize incremental collection set info.
 743   void start_incremental_cset_building();


 862   // The value of _heap_bytes_before_gc is also used to calculate
 863   // the cost of copying.
 864 
 865   size_t _eden_used_bytes_before_gc;         // Eden occupancy before GC
 866   size_t _survivor_used_bytes_before_gc;     // Survivor occupancy before GC
 867   size_t _heap_used_bytes_before_gc;         // Heap occupancy before GC
 868   size_t _metaspace_used_bytes_before_gc;    // Metaspace occupancy before GC
 869 
 870   size_t _eden_capacity_bytes_before_gc;     // Eden capacity before GC
 871   size_t _heap_capacity_bytes_before_gc;     // Heap capacity before GC
 872 
 873   // The amount of survivor regions after a collection.
 874   uint _recorded_survivor_regions;
 875   // List of survivor regions.
 876   HeapRegion* _recorded_survivor_head;
 877   HeapRegion* _recorded_survivor_tail;
 878 
 879   ageTable _survivors_age_table;
 880 
 881 public:
 882   uint tenuring_threshold() const { return _tenuring_threshold; }
 883 
 884   inline GCAllocPurpose
 885     evacuation_destination(HeapRegion* src_region, uint age, size_t word_sz) {
 886       if (age < _tenuring_threshold && src_region->is_young()) {
 887         return GCAllocForSurvived;
 888       } else {
 889         return GCAllocForTenured;
 890       }
 891   }
 892 
 893   inline bool track_object_age(GCAllocPurpose purpose) {
 894     return purpose == GCAllocForSurvived;
 895   }
 896 
 897   static const uint REGIONS_UNLIMITED = (uint) -1;
 898 
 899   uint max_regions(int purpose);
 900 
 901   // The limit on regions for a particular purpose is reached.
 902   void note_alloc_region_limit_reached(int purpose) {