1 /*
2 * Copyright (c) 2013, 2019, 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_SHENANDOAHCONCURRENTMARK_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP
27
28 #include "gc/shared/taskqueue.hpp"
29 #include "gc/shenandoah/shenandoahOopClosures.hpp"
30 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
31 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
32
33 class ShenandoahStrDedupQueue;
34
35 class ShenandoahConcurrentMark: public CHeapObj<mtGC> {
36 friend class ShenandoahTraversalGC;
37 private:
38 ShenandoahHeap* _heap;
39 ShenandoahObjToScanQueueSet* _task_queues;
40
41 public:
42 void initialize(uint workers);
43 void cancel();
44
45 // ---------- Marking loop and tasks
46 //
47 private:
48 template <class T>
49 inline void do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task);
50
51 template <class T>
52 inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array);
53
54 template <class T>
55 inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow);
56
57 inline void count_liveness(jushort* live_data, oop obj);
58
59 template <class T, bool CANCELLABLE>
60 void mark_loop_work(T* cl, jushort* live_data, uint worker_id, ShenandoahTaskTerminator *t);
61
62 template <bool CANCELLABLE>
63 void mark_loop_prework(uint worker_id, ShenandoahTaskTerminator *terminator, ReferenceProcessor *rp, bool strdedup);
64
65 public:
66 void mark_loop(uint worker_id, ShenandoahTaskTerminator* terminator, ReferenceProcessor *rp,
67 bool cancellable, bool strdedup) {
68 if (cancellable) {
69 mark_loop_prework<true>(worker_id, terminator, rp, strdedup);
70 } else {
71 mark_loop_prework<false>(worker_id, terminator, rp, strdedup);
72 }
73 }
74
75 template<class T, UpdateRefsMode UPDATE_REFS, StringDedupMode STRING_DEDUP>
76 static inline void mark_through_ref(T* p, ShenandoahHeap* heap, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context);
77
78 void mark_from_roots();
79 void finish_mark_from_roots(bool full_gc);
80
81 void mark_roots(ShenandoahPhaseTimings::Phase root_phase);
82 void update_roots(ShenandoahPhaseTimings::Phase root_phase);
83 void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase);
84
85 // ---------- Weak references
86 //
|
1 /*
2 * Copyright (c) 2013, 2020, 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_SHENANDOAHCONCURRENTMARK_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP
27
28 #include "gc/shared/taskqueue.hpp"
29 #include "gc/shared/taskTerminator.hpp"
30 #include "gc/shenandoah/shenandoahOopClosures.hpp"
31 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
32 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
33
34 class ShenandoahStrDedupQueue;
35
36 class ShenandoahConcurrentMark: public CHeapObj<mtGC> {
37 friend class ShenandoahTraversalGC;
38 private:
39 ShenandoahHeap* _heap;
40 ShenandoahObjToScanQueueSet* _task_queues;
41
42 public:
43 void initialize(uint workers);
44 void cancel();
45
46 // ---------- Marking loop and tasks
47 //
48 private:
49 template <class T>
50 inline void do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task);
51
52 template <class T>
53 inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array);
54
55 template <class T>
56 inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow);
57
58 inline void count_liveness(jushort* live_data, oop obj);
59
60 template <class T, bool CANCELLABLE>
61 void mark_loop_work(T* cl, jushort* live_data, uint worker_id, TaskTerminator *t);
62
63 template <bool CANCELLABLE>
64 void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ReferenceProcessor *rp, bool strdedup);
65
66 public:
67 void mark_loop(uint worker_id, TaskTerminator* terminator, ReferenceProcessor *rp,
68 bool cancellable, bool strdedup) {
69 if (cancellable) {
70 mark_loop_prework<true>(worker_id, terminator, rp, strdedup);
71 } else {
72 mark_loop_prework<false>(worker_id, terminator, rp, strdedup);
73 }
74 }
75
76 template<class T, UpdateRefsMode UPDATE_REFS, StringDedupMode STRING_DEDUP>
77 static inline void mark_through_ref(T* p, ShenandoahHeap* heap, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context);
78
79 void mark_from_roots();
80 void finish_mark_from_roots(bool full_gc);
81
82 void mark_roots(ShenandoahPhaseTimings::Phase root_phase);
83 void update_roots(ShenandoahPhaseTimings::Phase root_phase);
84 void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase);
85
86 // ---------- Weak references
87 //
|