1 /* 2 * Copyright (c) 2021, Red Hat, Inc. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP 27 28 #include "gc/shared/gcCause.hpp" 29 #include "gc/shenandoah/shenandoahConcurrentMark.hpp" 30 #include "gc/shenandoah/shenandoahGC.hpp" 31 #include "gc/shenandoah/shenandoahHeap.hpp" 32 33 class ShenandoahGeneration; 34 35 class VM_ShenandoahInitMark; 36 class VM_ShenandoahFinalMarkStartEvac; 37 class VM_ShenandoahInitUpdateRefs; 38 class VM_ShenandoahFinalUpdateRefs; 39 40 class ShenandoahConcurrentGC : public ShenandoahGC { 41 friend class VM_ShenandoahInitMark; 42 friend class VM_ShenandoahFinalMarkStartEvac; 43 friend class VM_ShenandoahInitUpdateRefs; 44 friend class VM_ShenandoahFinalUpdateRefs; 45 friend class VM_ShenandoahFinalRoots; 46 47 protected: 48 ShenandoahConcurrentMark _mark; 49 50 private: 51 ShenandoahDegenPoint _degen_point; 52 bool _abbreviated; 53 const bool _do_old_gc_bootstrap; 54 55 protected: 56 ShenandoahGeneration* const _generation; 57 58 public: 59 ShenandoahConcurrentGC(ShenandoahGeneration* generation, bool do_old_gc_bootstrap); 60 bool collect(GCCause::Cause cause); 61 ShenandoahDegenPoint degen_point() const; 62 bool abbreviated() const { return _abbreviated; } 63 64 private: 65 // Entry points to STW GC operations, these cause a related safepoint, that then 66 // call the entry method below 67 void vmop_entry_init_mark(); 68 69 protected: 70 void vmop_entry_final_mark(); 71 void vmop_entry_final_roots(bool incr_region_ages); 72 73 private: 74 void vmop_entry_init_updaterefs(); 75 void vmop_entry_final_updaterefs(); 76 77 // Entry methods to normally STW GC operations. These set up logging, monitoring 78 // and workers for net VM operation 79 void entry_init_mark(); 80 void entry_final_mark(); 81 void entry_init_updaterefs(); 82 void entry_final_updaterefs(); 83 void entry_final_roots(); 84 85 // Entry methods to normally concurrent GC operations. These set up logging, monitoring 86 // for concurrent operation. 87 void entry_reset(); 88 void entry_mark_roots(); 89 void entry_scan_remembered_set(); 90 91 protected: 92 void entry_mark(); 93 void entry_thread_roots(); 94 void entry_weak_refs(); 95 void entry_weak_roots(); 96 void entry_class_unloading(); 97 void entry_strong_roots(); 98 void entry_cleanup_early(); 99 virtual void op_final_mark(); 100 101 private: 102 void entry_evacuate(); 103 void entry_update_thread_roots(); 104 void entry_updaterefs(); 105 void entry_cleanup_complete(); 106 void entry_global_coalesce_and_fill(); 107 108 // Actual work for the phases 109 void op_reset(); 110 void op_init_mark(); 111 void op_mark_roots(); 112 void op_mark(); 113 void op_thread_roots(); 114 void op_weak_refs(); 115 void op_weak_roots(); 116 void op_class_unloading(); 117 void op_strong_roots(); 118 void op_cleanup_early(); 119 void op_evacuate(); 120 void op_init_updaterefs(); 121 void op_updaterefs(); 122 void op_update_thread_roots(); 123 void op_final_updaterefs(); 124 void op_final_roots(); 125 void op_cleanup_complete(); 126 void op_global_coalesce_and_fill(); 127 128 void start_mark(); 129 130 // Messages for GC trace events, they have to be immortal for 131 // passing around the logging/tracing systems 132 void init_mark_event_message(char* buf, size_t len) const; 133 void final_mark_event_message(char* buf, size_t len) const; 134 void conc_mark_event_message(char* buf, size_t len) const; 135 136 protected: 137 // Check GC cancellation and abort concurrent GC 138 bool check_cancellation_and_abort(ShenandoahDegenPoint point); 139 }; 140 141 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP