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_SHENANDOAHCOLLECTORPOLICY_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP 26 27 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp" 28 #include "gc_implementation/shenandoah/shenandoahHeap.hpp" 29 #include "memory/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 38 class STWGCTimer; 39 class ConcurrentGCTimer; 40 class outputStream; 41 42 class ShenandoahCollectorPolicy: public CollectorPolicy { 43 private: 44 size_t _success_partial_gcs; 45 size_t _success_concurrent_gcs; 46 size_t _success_degenerated_gcs; 47 size_t _success_full_gcs; 48 size_t _alloc_failure_degenerated; 49 size_t _alloc_failure_degenerated_upgrade_to_full; 50 size_t _alloc_failure_full; 51 size_t _explicit_concurrent; 52 size_t _explicit_full; 53 size_t _degen_points[ShenandoahHeap::_DEGENERATED_LIMIT]; 54 55 ShenandoahSharedFlag _in_shutdown; 56 57 ShenandoahHeuristics* _heuristics; 58 ShenandoahTracer* _tracer; 59 60 size_t _cycle_counter; 61 62 63 public: 64 ShenandoahCollectorPolicy(); 65 66 virtual ShenandoahCollectorPolicy* as_pgc_policy(); 67 68 BarrierSet::Name barrier_set_name(); 69 70 HeapWord* mem_allocate_work(size_t size, 71 bool is_tlab, 72 bool* gc_overhead_limit_was_exceeded); 73 74 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab); 75 76 void initialize_alignments(); 77 78 void post_heap_initialize(); 79 80 void record_gc_start(); 81 void record_gc_end(); 82 83 // TODO: This is different from gc_end: that one encompasses one VM operation. 84 // These two encompass the entire cycle. 85 void record_cycle_start(); 86 void record_cycle_end(); 87 88 void record_phase_time(ShenandoahPhaseTimings::Phase phase, double secs); 89 90 void record_success_partial(); 91 void record_success_concurrent(); 92 void record_success_degenerated(); 93 void record_success_full(); 94 void record_alloc_failure_to_degenerated(ShenandoahHeap::ShenandoahDegenPoint point); 95 void record_alloc_failure_to_full(); 96 void record_degenerated_upgrade_to_full(); 97 void record_explicit_to_concurrent(); 98 void record_explicit_to_full(); 99 100 bool should_start_normal_gc(); 101 102 // Returns true when there should be a separate concurrent reference 103 // updating phase after evacuation. 104 bool should_start_update_refs(); 105 bool update_refs(); 106 107 bool should_degenerate_cycle(); 108 109 110 void record_peak_occupancy(); 111 112 void record_shutdown(); 113 bool is_at_shutdown(); 114 115 void choose_collection_set(ShenandoahCollectionSet* collection_set); 116 117 bool should_process_references(); 118 bool should_unload_classes(); 119 120 ShenandoahTracer* tracer() {return _tracer;} 121 122 size_t cycle_counter() const; 123 124 void print_gc_stats(outputStream* out) const; 125 }; 126 127 128 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP