1 /*
2 * Copyright (c) 2021, 2022, 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_SHENANDOAHMARK_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
27
28 #include "gc/shared/stringdedup/stringDedup.hpp"
29 #include "gc/shared/taskTerminator.hpp"
30 #include "gc/shenandoah/shenandoahGenerationType.hpp"
31 #include "gc/shenandoah/shenandoahHeap.hpp"
32 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
33
34 enum StringDedupMode {
35 NO_DEDUP, // Do not do anything for String deduplication
36 ENQUEUE_DEDUP, // Enqueue candidate Strings for deduplication, if meet age threshold
37 ALWAYS_DEDUP // Enqueue Strings for deduplication
38 };
39
40 class ShenandoahMarkingContext;
41 class ShenandoahReferenceProcessor;
42
43 // Base class for mark
44 // Mark class does not maintain states. Instead, mark states are
45 // maintained by task queues, mark bitmap and SATB buffers (concurrent mark)
46 class ShenandoahMark: public StackObj {
47 protected:
48 ShenandoahObjToScanQueueSet* const _task_queues;
49
50 protected:
51 ShenandoahMark();
52
53 public:
54 template<class T, ShenandoahGenerationType GENERATION>
55 static inline void mark_through_ref(T* p, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context, bool weak);
56
57 static void clear();
58
59 // Loom support
60 void start_mark();
61 void end_mark();
62
63 // Helpers
64 inline ShenandoahObjToScanQueueSet* task_queues() const;
65 inline ShenandoahObjToScanQueue* get_queue(uint index) const;
66
67 // ---------- Marking loop and tasks
68 private:
69 template <class T, ShenandoahGenerationType GENERATION, StringDedupMode STRING_DEDUP>
70 inline void do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, StringDedup::Requests* const req, ShenandoahMarkTask* task);
71
72 template <class T>
73 inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array, bool weak);
74
75 template <class T>
76 inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow, bool weak);
77
78 template <ShenandoahGenerationType GENERATION>
79 inline void count_liveness(ShenandoahLiveData* live_data, oop obj);
80
81 template <class T, ShenandoahGenerationType GENERATION, bool CANCELLABLE, StringDedupMode STRING_DEDUP>
82 void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, TaskTerminator *t, StringDedup::Requests* const req);
83
84 template <ShenandoahGenerationType GENERATION, bool CANCELLABLE, StringDedupMode STRING_DEDUP>
85 void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ShenandoahReferenceProcessor *rp, StringDedup::Requests* const req);
86
87 template <StringDedupMode STRING_DEDUP>
88 inline void dedup_string(oop obj, StringDedup::Requests* const req);
89 protected:
90 template<bool CANCELLABLE, StringDedupMode STRING_DEDUP>
91 void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,
92 ShenandoahGenerationType generation, StringDedup::Requests* const req);
93 void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,
94 ShenandoahGenerationType generation, bool cancellable, StringDedupMode dedup_mode, StringDedup::Requests* const req);
95 };
96
97 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
|
1 /*
2 * Copyright (c) 2021, 2022, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
28
29 #include "gc/shared/ageTable.hpp"
30 #include "gc/shared/stringdedup/stringDedup.hpp"
31 #include "gc/shared/taskTerminator.hpp"
32 #include "gc/shenandoah/shenandoahGenerationType.hpp"
33 #include "gc/shenandoah/shenandoahHeap.hpp"
34 #include "gc/shenandoah/shenandoahGeneration.hpp"
35 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
36
37 enum StringDedupMode {
38 NO_DEDUP, // Do not do anything for String deduplication
39 ENQUEUE_DEDUP, // Enqueue candidate Strings for deduplication, if meet age threshold
40 ALWAYS_DEDUP // Enqueue Strings for deduplication
41 };
42
43 class ShenandoahMarkingContext;
44 class ShenandoahReferenceProcessor;
45
46 // Base class for mark
47 // Mark class does not maintain states. Instead, mark states are
48 // maintained by task queues, mark bitmap and SATB buffers (concurrent mark)
49 class ShenandoahMark: public StackObj {
50 protected:
51 ShenandoahGeneration* const _generation;
52 ShenandoahObjToScanQueueSet* const _task_queues;
53 ShenandoahObjToScanQueueSet* const _old_gen_task_queues;
54
55 protected:
56 ShenandoahMark(ShenandoahGeneration* generation);
57
58 public:
59 template<class T, ShenandoahGenerationType GENERATION>
60 static inline void mark_through_ref(T* p, ShenandoahObjToScanQueue* q, ShenandoahObjToScanQueue* old_q, ShenandoahMarkingContext* const mark_context, bool weak);
61
62 // Loom support
63 void start_mark();
64 void end_mark();
65
66 // Helpers
67 inline ShenandoahObjToScanQueueSet* task_queues() const;
68 ShenandoahObjToScanQueueSet* old_task_queues() {
69 return _old_gen_task_queues;
70 }
71
72 inline ShenandoahObjToScanQueue* get_queue(uint index) const;
73 inline ShenandoahObjToScanQueue* get_old_queue(uint index) const;
74
75 inline ShenandoahGeneration* generation() { return _generation; };
76
77 private:
78 // ---------- Marking loop and tasks
79
80 template <class T, ShenandoahGenerationType GENERATION, StringDedupMode STRING_DEDUP>
81 inline void do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, StringDedup::Requests* const req, ShenandoahMarkTask* task, uint worker_id);
82
83 template <class T>
84 inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array, bool weak);
85
86 template <class T>
87 inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow, bool weak);
88
89 template <ShenandoahGenerationType GENERATION>
90 inline void count_liveness(ShenandoahLiveData* live_data, oop obj, uint worker_id);
91
92 template <class T, ShenandoahGenerationType GENERATION, bool CANCELLABLE, StringDedupMode STRING_DEDUP>
93 void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, TaskTerminator *t, StringDedup::Requests* const req);
94
95 template <ShenandoahGenerationType GENERATION, bool CANCELLABLE, StringDedupMode STRING_DEDUP>
96 void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ShenandoahReferenceProcessor *rp, StringDedup::Requests* const req, bool update_refs);
97
98 template <ShenandoahGenerationType GENERATION>
99 static bool in_generation(ShenandoahHeap* const heap, oop obj);
100
101 template <class T>
102 static void mark_non_generational_ref(T *p, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context, bool weak);
103
104 static void mark_ref(ShenandoahObjToScanQueue* q,
105 ShenandoahMarkingContext* const mark_context,
106 bool weak, oop obj);
107
108 template <StringDedupMode STRING_DEDUP>
109 inline void dedup_string(oop obj, StringDedup::Requests* const req);
110 protected:
111 template<bool CANCELLABLE, StringDedupMode STRING_DEDUP>
112 void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,
113 ShenandoahGenerationType generation, StringDedup::Requests* const req);
114
115 void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor *rp,
116 ShenandoahGenerationType generation, bool cancellable, StringDedupMode dedup_mode, StringDedup::Requests* const req);
117 };
118
119 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARK_HPP
|