1 /* 2 * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved. 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_SHENANDOAHCONCURRENTMARK_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP 26 27 #include "utilities/taskqueue.hpp" 28 #include "gc_implementation/shenandoah/shenandoahOopClosures.hpp" 29 #include "gc_implementation/shenandoah/shenandoahTaskqueue.hpp" 30 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp" 31 32 class ShenandoahStrDedupQueue; 33 34 class ShenandoahConcurrentMark: public CHeapObj<mtGC> { 35 private: 36 ShenandoahHeap* _heap; 37 ShenandoahObjToScanQueueSet* _task_queues; 38 39 public: 40 void initialize(uint workers); 41 void cancel(); 42 43 // ---------- Marking loop and tasks 44 // 45 private: 46 template <class T> 47 inline void do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, ShenandoahMarkTask* task); 48 49 template <class T> 50 inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array); 51 52 template <class T> 53 inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow); 54 55 inline void count_liveness(ShenandoahLiveData* live_data, oop obj); 56 57 template <class T, bool CANCELLABLE> 58 void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, ShenandoahTaskTerminator *t); 59 60 template <bool CANCELLABLE> 61 void mark_loop_prework(uint worker_id, ShenandoahTaskTerminator *terminator, ReferenceProcessor *rp, bool strdedup); 62 63 public: 64 void mark_loop(uint worker_id, ShenandoahTaskTerminator* terminator, ReferenceProcessor *rp, 65 bool cancellable, bool strdedup) { 66 if (cancellable) { 67 mark_loop_prework<true>(worker_id, terminator, rp, strdedup); 68 } else { 69 mark_loop_prework<false>(worker_id, terminator, rp, strdedup); 70 } 71 } 72 73 template<class T, UpdateRefsMode UPDATE_REFS, StringDedupMode STRING_DEDUP> 74 static inline void mark_through_ref(T* p, ShenandoahHeap* heap, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context, ShenandoahStrDedupQueue* dq = NULL); 75 76 void mark_from_roots(); 77 void finish_mark_from_roots(bool full_gc); 78 79 void mark_roots(ShenandoahPhaseTimings::Phase root_phase); 80 void update_roots(ShenandoahPhaseTimings::Phase root_phase); 81 void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase); 82 83 // ---------- Weak references 84 // 85 private: 86 void weak_refs_work(bool full_gc); 87 void weak_refs_work_doit(bool full_gc); 88 89 public: 90 void weak_roots_work(bool full_gc); 91 void preclean_weak_refs(); 92 93 // ---------- Concurrent code cache 94 // 95 private: 96 ShenandoahSharedFlag _claimed_codecache; 97 98 public: 99 void concurrent_scan_code_roots(uint worker_id, ReferenceProcessor* rp); 100 bool claim_codecache(); 101 void clear_claim_codecache(); 102 103 // ---------- Helpers 104 // Used from closures, need to be public 105 // 106 public: 107 ShenandoahObjToScanQueue* get_queue(uint worker_id); 108 ShenandoahObjToScanQueueSet* task_queues() { return _task_queues; } 109 110 }; 111 112 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP