1 /* 2 * Copyright (c) 2013, 2015, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAH_COLLECTOR_POLICY_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAH_COLLECTOR_POLICY_HPP 26 27 #include "gc/shenandoah/shenandoahHeapRegion.hpp" 28 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp" 29 #include "gc/shared/gcTrace.hpp" 30 #include "gc/shared/gcTimer.hpp" 31 #include "gc/shared/collectorPolicy.hpp" 32 #include "runtime/arguments.hpp" 33 #include "utilities/numberSeq.hpp" 34 35 36 class ShenandoahHeap; 37 class ShenandoahHeuristics; 38 39 class ShenandoahCollectorPolicy: public CollectorPolicy { 40 41 public: 42 enum TimingPhase { 43 init_mark, 44 final_mark, 45 accumulate_stats, 46 make_parsable, 47 clear_liveness, 48 scan_roots, 49 rescan_roots, 50 drain_satb, 51 drain_queues, 52 weakrefs, 53 prepare_evac, 54 init_evac, 55 56 final_evac, 57 final_uprefs, 58 update_roots, 59 recycle_regions, 60 reset_bitmaps, 61 resize_tlabs, 62 full_gc, 63 conc_mark, 64 conc_evac, 65 conc_uprefs, 66 67 _num_phases 68 }; 69 70 private: 71 struct TimingData { 72 NumberSeq _ms; 73 double _start; 74 size_t _count; 75 }; 76 77 private: 78 TimingData _timing_data[_num_phases]; 79 const char* _phase_names[_num_phases]; 80 81 size_t _user_requested_gcs; 82 size_t _allocation_failure_gcs; 83 84 ShenandoahHeap* _pgc; 85 ShenandoahHeuristics* _heuristics; 86 ShenandoahTracer* _tracer; 87 STWGCTimer* _stw_timer; 88 ConcurrentGCTimer* _conc_timer; 89 90 bool _conc_gc_aborted; 91 92 public: 93 ShenandoahCollectorPolicy(); 94 95 virtual ShenandoahCollectorPolicy* as_pgc_policy(); 96 97 BarrierSet::Name barrier_set_name(); 98 99 HeapWord* mem_allocate_work(size_t size, 100 bool is_tlab, 101 bool* gc_overhead_limit_was_exceeded); 102 103 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab); 104 105 void initialize_alignments(); 106 107 void post_heap_initialize(); 108 109 void record_phase_start(TimingPhase phase); 110 void record_phase_end(TimingPhase phase); 111 void report_concgc_cancelled(); 112 113 void record_user_requested_gc(); 114 void record_allocation_failure_gc(); 115 116 void record_bytes_allocated(size_t bytes); 117 void record_bytes_reclaimed(size_t bytes); 118 void record_bytes_start_CM(size_t bytes); 119 void record_bytes_end_CM(size_t bytes); 120 bool should_start_concurrent_mark(size_t used, size_t capacity); 121 void choose_collection_and_free_sets(ShenandoahHeapRegionSet* region_set, 122 ShenandoahHeapRegionSet* collection_set, 123 ShenandoahHeapRegionSet* free_set); 124 125 bool update_refs_early(); 126 127 void print_tracing_info(); 128 129 GCTimer* conc_timer(){return _conc_timer;} 130 GCTimer* stw_timer() {return _stw_timer;} 131 ShenandoahTracer* tracer() {return _tracer;} 132 133 void set_conc_gc_aborted() { _conc_gc_aborted = true;} 134 void clear_conc_gc_aborted() {_conc_gc_aborted = false;} 135 136 private: 137 void print_summary_sd(const char* str, uint indent, const NumberSeq* seq); 138 }; 139 140 141 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAH_COLLECTOR_POLICY_HPP