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/shared/gcTrace.hpp" 28 #include "gc/shared/gcTimer.hpp" 29 #include "gc/shared/collectorPolicy.hpp" 30 #include "runtime/arguments.hpp" 31 #include "utilities/numberSeq.hpp" 32 33 class ShenandoahCollectionSet; 34 class ShenandoahFreeSet; 35 class ShenandoahHeap; 36 class ShenandoahHeuristics; 37 class ShenandoahPhaseTimes; 38 39 class ShenandoahCollectorPolicy: public CollectorPolicy { 40 41 public: 42 enum TimingPhase { 43 init_mark_gross, 44 init_mark, 45 accumulate_stats, 46 make_parsable, 47 clear_liveness, 48 scan_roots, 49 scan_thread_roots, 50 scan_code_roots, 51 scan_string_table_roots, 52 scan_universe_roots, 53 scan_jni_roots, 54 scan_jni_weak_roots, 55 scan_synchronizer_roots, 56 scan_flat_profiler_roots, 57 scan_management_roots, 58 scan_system_dictionary_roots, 59 scan_cldg_roots, 60 scan_jvmti_roots, 61 62 resize_tlabs, 63 64 final_mark_gross, 65 final_mark, 66 update_roots, 67 update_thread_roots, 68 update_code_roots, 69 update_string_table_roots, 70 update_universe_roots, 71 update_jni_roots, 72 update_jni_weak_roots, 73 update_synchronizer_roots, 74 update_flat_profiler_roots, 75 update_management_roots, 76 update_system_dictionary_roots, 77 update_cldg_roots, 78 update_jvmti_roots, 79 drain_satb, 80 weakrefs, 81 class_unloading, 82 prepare_evac, 83 recycle_regions, 84 init_evac, 85 evac_thread_roots, 86 evac_code_roots, 87 evac_string_table_roots, 88 evac_universe_roots, 89 evac_jni_roots, 90 evac_jni_weak_roots, 91 evac_synchronizer_roots, 92 evac_flat_profiler_roots, 93 evac_management_roots, 94 evac_system_dictionary_roots, 95 evac_cldg_roots, 96 evac_jvmti_roots, 97 98 conc_mark, 99 conc_evac, 100 reset_bitmaps, 101 102 full_gc, 103 full_gc_mark, 104 full_gc_mark_drain_queues, 105 full_gc_mark_weakrefs, 106 full_gc_mark_class_unloading, 107 full_gc_calculate_addresses, 108 full_gc_adjust_pointers, 109 full_gc_copy_objects, 110 111 _num_phases 112 }; 113 114 private: 115 struct TimingData { 116 NumberSeq _ms; 117 double _start; 118 size_t _count; 119 }; 120 121 private: 122 TimingData _timing_data[_num_phases]; 123 const char* _phase_names[_num_phases]; 124 125 size_t _user_requested_gcs; 126 size_t _allocation_failure_gcs; 127 128 ShenandoahHeap* _pgc; 129 ShenandoahHeuristics* _heuristics; 130 ShenandoahTracer* _tracer; 131 STWGCTimer* _stw_timer; 132 ConcurrentGCTimer* _conc_timer; 133 134 bool _conc_gc_aborted; 135 136 size_t _cycle_counter; 137 138 ShenandoahPhaseTimes* _phase_times; 139 140 public: 141 ShenandoahCollectorPolicy(); 142 143 ShenandoahPhaseTimes* phase_times(); 144 145 virtual ShenandoahCollectorPolicy* as_pgc_policy(); 146 147 BarrierSet::Name barrier_set_name(); 148 149 HeapWord* mem_allocate_work(size_t size, 150 bool is_tlab, 151 bool* gc_overhead_limit_was_exceeded); 152 153 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab); 154 155 void initialize_alignments(); 156 157 void post_heap_initialize(); 158 159 void record_phase_start(TimingPhase phase); 160 void record_phase_end(TimingPhase phase); 161 162 void record_workers_start(TimingPhase phase); 163 void record_workers_end(TimingPhase phase); 164 165 void report_concgc_cancelled(); 166 167 void record_user_requested_gc(); 168 void record_allocation_failure_gc(); 169 170 void record_bytes_allocated(size_t bytes); 171 void record_bytes_reclaimed(size_t bytes); 172 void record_bytes_start_CM(size_t bytes); 173 void record_bytes_end_CM(size_t bytes); 174 bool should_start_concurrent_mark(size_t used, size_t capacity); 175 176 void choose_collection_set(ShenandoahCollectionSet* collection_set); 177 void choose_free_set(ShenandoahFreeSet* free_set); 178 179 bool process_references(); 180 bool unload_classes(); 181 182 void print_tracing_info(outputStream* out); 183 184 GCTimer* conc_timer(){return _conc_timer;} 185 GCTimer* stw_timer() {return _stw_timer;} 186 ShenandoahTracer* tracer() {return _tracer;} 187 188 void set_conc_gc_aborted() { _conc_gc_aborted = true;} 189 void clear_conc_gc_aborted() {_conc_gc_aborted = false;} 190 191 void increase_cycle_counter(); 192 size_t cycle_counter() const; 193 194 private: 195 void print_summary_sd(outputStream* out, const char* str, const NumberSeq* seq); 196 }; 197 198 199 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAH_COLLECTOR_POLICY_HPP