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_heapdumps, 104 full_gc_prepare, 105 full_gc_mark, 106 full_gc_mark_drain_queues, 107 full_gc_mark_weakrefs, 108 full_gc_mark_class_unloading, 109 full_gc_calculate_addresses, 110 full_gc_adjust_pointers, 111 full_gc_copy_objects, 112 113 _num_phases 114 }; 115 116 private: 117 struct TimingData { 118 NumberSeq _ms; 119 double _start; 120 size_t _count; 121 }; 122 123 private: 124 TimingData _timing_data[_num_phases]; 125 const char* _phase_names[_num_phases]; 126 127 size_t _user_requested_gcs; 128 size_t _allocation_failure_gcs; 129 130 ShenandoahHeap* _pgc; 131 ShenandoahHeuristics* _heuristics; 132 ShenandoahTracer* _tracer; 133 STWGCTimer* _stw_timer; 134 ConcurrentGCTimer* _conc_timer; 135 136 bool _conc_gc_aborted; 137 138 size_t _cycle_counter; 139 140 ShenandoahPhaseTimes* _phase_times; 141 142 public: 143 ShenandoahCollectorPolicy(); 144 145 ShenandoahPhaseTimes* phase_times(); 146 147 virtual ShenandoahCollectorPolicy* as_pgc_policy(); 148 149 BarrierSet::Name barrier_set_name(); 150 151 HeapWord* mem_allocate_work(size_t size, 152 bool is_tlab, 153 bool* gc_overhead_limit_was_exceeded); 154 155 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab); 156 157 void initialize_alignments(); 158 159 void post_heap_initialize(); 160 161 void record_phase_start(TimingPhase phase); 162 void record_phase_end(TimingPhase phase); 163 164 void record_workers_start(TimingPhase phase); 165 void record_workers_end(TimingPhase phase); 166 167 void report_concgc_cancelled(); 168 169 void record_user_requested_gc(); 170 void record_allocation_failure_gc(); 171 172 void record_bytes_allocated(size_t bytes); 173 void record_bytes_reclaimed(size_t bytes); 174 void record_bytes_start_CM(size_t bytes); 175 void record_bytes_end_CM(size_t bytes); 176 bool should_start_concurrent_mark(size_t used, size_t capacity); 177 178 void choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections=NULL); 179 void choose_free_set(ShenandoahFreeSet* free_set); 180 181 bool process_references(); 182 bool unload_classes(); 183 184 void print_tracing_info(outputStream* out); 185 186 GCTimer* conc_timer(){return _conc_timer;} 187 GCTimer* stw_timer() {return _stw_timer;} 188 ShenandoahTracer* tracer() {return _tracer;} 189 190 void set_conc_gc_aborted() { _conc_gc_aborted = true;} 191 void clear_conc_gc_aborted() {_conc_gc_aborted = false;} 192 193 void increase_cycle_counter(); 194 size_t cycle_counter() const; 195 196 private: 197 void print_summary_sd(outputStream* out, const char* str, const NumberSeq* seq); 198 }; 199 200 201 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAH_COLLECTOR_POLICY_HPP