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