1 /*
2 * Copyright (c) 2015, 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_INLINE_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARK_INLINE_HPP
27
28 #include "gc/shenandoah/shenandoahMark.hpp"
29
30 #include "gc/shared/continuationGCSupport.inline.hpp"
31 #include "gc/shenandoah/shenandoahAsserts.hpp"
32 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
33 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
34 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
35 #include "gc/shenandoah/shenandoahStringDedup.inline.hpp"
36 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
37 #include "gc/shenandoah/shenandoahUtils.hpp"
38 #include "memory/iterator.inline.hpp"
39 #include "oops/compressedOops.inline.hpp"
40 #include "oops/oop.inline.hpp"
41 #include "runtime/prefetch.inline.hpp"
42 #include "utilities/devirtualizer.inline.hpp"
43 #include "utilities/powerOfTwo.hpp"
44
45 template <StringDedupMode STRING_DEDUP>
46 void ShenandoahMark::dedup_string(oop obj, StringDedup::Requests* const req) {
47 if (STRING_DEDUP == ENQUEUE_DEDUP) {
48 if (ShenandoahStringDedup::is_candidate(obj)) {
49 req->add(obj);
50 }
51 } else if (STRING_DEDUP == ALWAYS_DEDUP) {
52 if (ShenandoahStringDedup::is_string_candidate(obj) &&
53 !ShenandoahStringDedup::dedup_requested(obj)) {
54 req->add(obj);
55 }
56 }
57 }
58
59 template <class T, StringDedupMode STRING_DEDUP>
60 void ShenandoahMark::do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, StringDedup::Requests* const req, ShenandoahMarkTask* task) {
61 oop obj = task->obj();
62
63 shenandoah_assert_not_forwarded(nullptr, obj);
64 shenandoah_assert_marked(nullptr, obj);
65 shenandoah_assert_not_in_cset_except(nullptr, obj, ShenandoahHeap::heap()->cancelled_gc());
66
67 // Are we in weak subgraph scan?
68 bool weak = task->is_weak();
69 cl->set_weak(weak);
70
71 if (task->is_not_chunked()) {
72 if (obj->is_instance()) {
73 // Case 1: Normal oop, process as usual.
74 if (ContinuationGCSupport::relativize_stack_chunk(obj)) {
75 // Loom doesn't support mixing of weak marking and strong marking of
76 // stack chunks.
77 cl->set_weak(false);
78 }
79
80 obj->oop_iterate(cl);
81 dedup_string<STRING_DEDUP>(obj, req);
82 } else if (obj->is_objArray()) {
83 // Case 2: Object array instance and no chunk is set. Must be the first
84 // time we visit it, start the chunked processing.
85 do_chunked_array_start<T>(q, cl, obj, weak);
86 } else {
87 // Case 3: Primitive array. Do nothing, no oops there. We use the same
88 // performance tweak TypeArrayKlass::oop_oop_iterate_impl is using:
89 // We skip iterating over the klass pointer since we know that
90 // Universe::TypeArrayKlass never moves.
91 assert (obj->is_typeArray(), "should be type array");
92 }
93 // Count liveness the last: push the outstanding work to the queues first
94 // Avoid double-counting objects that are visited twice due to upgrade
95 // from final- to strong mark.
96 if (task->count_liveness()) {
97 count_liveness(live_data, obj);
98 }
99 } else {
100 // Case 4: Array chunk, has sensible chunk id. Process it.
101 do_chunked_array<T>(q, cl, obj, task->chunk(), task->pow(), weak);
102 }
103 }
104
105 inline void ShenandoahMark::count_liveness(ShenandoahLiveData* live_data, oop obj) {
106 ShenandoahHeap* const heap = ShenandoahHeap::heap();
107 size_t region_idx = heap->heap_region_index_containing(obj);
108 ShenandoahHeapRegion* region = heap->get_region(region_idx);
109 size_t size = obj->size();
110
111 if (!region->is_humongous_start()) {
112 assert(!region->is_humongous(), "Cannot have continuations here");
113 ShenandoahLiveData cur = live_data[region_idx];
114 size_t new_val = size + cur;
115 if (new_val >= SHENANDOAH_LIVEDATA_MAX) {
116 // overflow, flush to region data
117 region->increase_live_data_gc_words(new_val);
118 live_data[region_idx] = 0;
119 } else {
120 // still good, remember in locals
121 live_data[region_idx] = (ShenandoahLiveData) new_val;
122 }
123 } else {
124 shenandoah_assert_in_correct_region(nullptr, obj);
125 size_t num_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
126
127 for (size_t i = region_idx; i < region_idx + num_regions; i++) {
128 ShenandoahHeapRegion* chain_reg = heap->get_region(i);
129 assert(chain_reg->is_humongous(), "Expecting a humongous region");
130 chain_reg->increase_live_data_gc_words(chain_reg->used() >> LogHeapWordSize);
131 }
132 }
133 }
134
135 template <class T>
136 inline void ShenandoahMark::do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop obj, bool weak) {
137 assert(obj->is_objArray(), "expect object array");
138 objArrayOop array = objArrayOop(obj);
139 int len = array->length();
140
141 // Mark objArray klass metadata
142 if (Devirtualizer::do_metadata(cl)) {
143 Devirtualizer::do_klass(cl, array->klass());
144 }
145
146 if (len <= (int) ObjArrayMarkingStride*2) {
147 // A few slices only, process directly
148 array->oop_iterate_range(cl, 0, len);
149 } else {
212 pow--;
213 chunk *= 2;
214 bool pushed = q->push(ShenandoahMarkTask(array, true, weak, chunk - 1, pow));
215 assert(pushed, "overflow queue should always succeed pushing");
216 }
217
218 int chunk_size = 1 << pow;
219
220 int from = (chunk - 1) * chunk_size;
221 int to = chunk * chunk_size;
222
223 #ifdef ASSERT
224 int len = array->length();
225 assert (0 <= from && from < len, "from is sane: %d/%d", from, len);
226 assert (0 < to && to <= len, "to is sane: %d/%d", to, len);
227 #endif
228
229 array->oop_iterate_range(cl, from, to);
230 }
231
232 class ShenandoahSATBBufferClosure : public SATBBufferClosure {
233 private:
234 ShenandoahObjToScanQueue* _queue;
235 ShenandoahHeap* _heap;
236 ShenandoahMarkingContext* const _mark_context;
237 public:
238 ShenandoahSATBBufferClosure(ShenandoahObjToScanQueue* q) :
239 _queue(q),
240 _heap(ShenandoahHeap::heap()),
241 _mark_context(_heap->marking_context())
242 {
243 }
244
245 void do_buffer(void **buffer, size_t size) {
246 assert(size == 0 || !_heap->has_forwarded_objects(), "Forwarded objects are not expected here");
247 for (size_t i = 0; i < size; ++i) {
248 oop *p = (oop *) &buffer[i];
249 ShenandoahMark::mark_through_ref<oop>(p, _queue, _mark_context, false);
250 }
251 }
252 };
253
254 template<class T>
255 inline void ShenandoahMark::mark_through_ref(T* p, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context, bool weak) {
256 T o = RawAccess<>::oop_load(p);
257 if (!CompressedOops::is_null(o)) {
258 oop obj = CompressedOops::decode_not_null(o);
259
260 shenandoah_assert_not_forwarded(p, obj);
261 shenandoah_assert_not_in_cset_except(p, obj, ShenandoahHeap::heap()->cancelled_gc());
262
263 bool skip_live = false;
264 bool marked;
265 if (weak) {
266 marked = mark_context->mark_weak(obj);
267 } else {
268 marked = mark_context->mark_strong(obj, /* was_upgraded = */ skip_live);
269 }
270 if (marked) {
271 bool pushed = q->push(ShenandoahMarkTask(obj, skip_live, weak));
272 assert(pushed, "overflow queue should always succeed pushing");
273 }
274
275 shenandoah_assert_marked(p, obj);
276 }
277 }
278
279 ShenandoahObjToScanQueueSet* ShenandoahMark::task_queues() const {
280 return _task_queues;
281 }
282
283 ShenandoahObjToScanQueue* ShenandoahMark::get_queue(uint index) const {
284 return _task_queues->queue(index);
285 }
286 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARK_INLINE_HPP
|
1 /*
2 * Copyright (c) 2015, 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_INLINE_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARK_INLINE_HPP
28
29 #include "gc/shenandoah/shenandoahMark.hpp"
30
31 #include "gc/shared/continuationGCSupport.inline.hpp"
32 #include "gc/shenandoah/shenandoahAgeCensus.hpp"
33 #include "gc/shenandoah/shenandoahAsserts.hpp"
34 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
35 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
36 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
37 #include "gc/shenandoah/shenandoahOldGeneration.hpp"
38 #include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
39 #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp"
40 #include "gc/shenandoah/shenandoahStringDedup.inline.hpp"
41 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
42 #include "gc/shenandoah/shenandoahUtils.hpp"
43 #include "memory/iterator.inline.hpp"
44 #include "oops/compressedOops.inline.hpp"
45 #include "oops/oop.inline.hpp"
46 #include "runtime/prefetch.inline.hpp"
47 #include "utilities/devirtualizer.inline.hpp"
48 #include "utilities/powerOfTwo.hpp"
49
50 template <StringDedupMode STRING_DEDUP>
51 void ShenandoahMark::dedup_string(oop obj, StringDedup::Requests* const req) {
52 if (STRING_DEDUP == ENQUEUE_DEDUP) {
53 if (ShenandoahStringDedup::is_candidate(obj)) {
54 req->add(obj);
55 }
56 } else if (STRING_DEDUP == ALWAYS_DEDUP) {
57 if (ShenandoahStringDedup::is_string_candidate(obj) &&
58 !ShenandoahStringDedup::dedup_requested(obj)) {
59 req->add(obj);
60 }
61 }
62 }
63
64 template <class T, ShenandoahGenerationType GENERATION, StringDedupMode STRING_DEDUP>
65 void ShenandoahMark::do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, StringDedup::Requests* const req, ShenandoahMarkTask* task, uint worker_id) {
66 oop obj = task->obj();
67
68 // TODO: This will push array chunks into the mark queue with no regard for
69 // generations. I don't think it will break anything, but the young generation
70 // scan might end up processing some old generation array chunks.
71
72 shenandoah_assert_not_forwarded(nullptr, obj);
73 shenandoah_assert_marked(nullptr, obj);
74 shenandoah_assert_not_in_cset_except(nullptr, obj, ShenandoahHeap::heap()->cancelled_gc());
75
76 // Are we in weak subgraph scan?
77 bool weak = task->is_weak();
78 cl->set_weak(weak);
79
80 if (task->is_not_chunked()) {
81 if (obj->is_instance()) {
82 // Case 1: Normal oop, process as usual.
83 if (ContinuationGCSupport::relativize_stack_chunk(obj)) {
84 // Loom doesn't support mixing of weak marking and strong marking of
85 // stack chunks.
86 cl->set_weak(false);
87 }
88
89 obj->oop_iterate(cl);
90 dedup_string<STRING_DEDUP>(obj, req);
91 } else if (obj->is_objArray()) {
92 // Case 2: Object array instance and no chunk is set. Must be the first
93 // time we visit it, start the chunked processing.
94 do_chunked_array_start<T>(q, cl, obj, weak);
95 } else {
96 // Case 3: Primitive array. Do nothing, no oops there. We use the same
97 // performance tweak TypeArrayKlass::oop_oop_iterate_impl is using:
98 // We skip iterating over the klass pointer since we know that
99 // Universe::TypeArrayKlass never moves.
100 assert (obj->is_typeArray(), "should be type array");
101 }
102 // Count liveness the last: push the outstanding work to the queues first
103 // Avoid double-counting objects that are visited twice due to upgrade
104 // from final- to strong mark.
105 if (task->count_liveness()) {
106 count_liveness<GENERATION>(live_data, obj, worker_id);
107 }
108 } else {
109 // Case 4: Array chunk, has sensible chunk id. Process it.
110 do_chunked_array<T>(q, cl, obj, task->chunk(), task->pow(), weak);
111 }
112 }
113
114 template <ShenandoahGenerationType GENERATION>
115 inline void ShenandoahMark::count_liveness(ShenandoahLiveData* live_data, oop obj, uint worker_id) {
116 const ShenandoahHeap* const heap = ShenandoahHeap::heap();
117 const size_t region_idx = heap->heap_region_index_containing(obj);
118 ShenandoahHeapRegion* const region = heap->get_region(region_idx);
119 const size_t size = obj->size();
120
121 // Age census for objects in the young generation
122 if (GENERATION == YOUNG || (GENERATION == GLOBAL && region->is_young())) {
123 assert(heap->mode()->is_generational(), "Only if generational");
124 if (ShenandoahGenerationalAdaptiveTenuring && !ShenandoahGenerationalCensusAtEvac) {
125 assert(region->is_young(), "Only for young objects");
126 uint age = ShenandoahHeap::get_object_age(obj);
127 ShenandoahAgeCensus* const census = ShenandoahGenerationalHeap::heap()->age_census();
128 CENSUS_NOISE(census->add(age, region->age(), region->youth(), size, worker_id);)
129 NO_CENSUS_NOISE(census->add(age, region->age(), size, worker_id);)
130 }
131 }
132
133 if (!region->is_humongous_start()) {
134 assert(!region->is_humongous(), "Cannot have continuations here");
135 assert(region->is_affiliated(), "Do not count live data within Free Regular Region " SIZE_FORMAT, region_idx);
136 ShenandoahLiveData cur = live_data[region_idx];
137 size_t new_val = size + cur;
138 if (new_val >= SHENANDOAH_LIVEDATA_MAX) {
139 // overflow, flush to region data
140 region->increase_live_data_gc_words(new_val);
141 live_data[region_idx] = 0;
142 } else {
143 // still good, remember in locals
144 live_data[region_idx] = (ShenandoahLiveData) new_val;
145 }
146 } else {
147 shenandoah_assert_in_correct_region(nullptr, obj);
148 size_t num_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
149
150 assert(region->is_affiliated(), "Do not count live data within FREE Humongous Start Region " SIZE_FORMAT, region_idx);
151 for (size_t i = region_idx; i < region_idx + num_regions; i++) {
152 ShenandoahHeapRegion* chain_reg = heap->get_region(i);
153 assert(chain_reg->is_humongous(), "Expecting a humongous region");
154 assert(chain_reg->is_affiliated(), "Do not count live data within FREE Humongous Continuation Region " SIZE_FORMAT, i);
155 chain_reg->increase_live_data_gc_words(chain_reg->used() >> LogHeapWordSize);
156 }
157 }
158 }
159
160 template <class T>
161 inline void ShenandoahMark::do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop obj, bool weak) {
162 assert(obj->is_objArray(), "expect object array");
163 objArrayOop array = objArrayOop(obj);
164 int len = array->length();
165
166 // Mark objArray klass metadata
167 if (Devirtualizer::do_metadata(cl)) {
168 Devirtualizer::do_klass(cl, array->klass());
169 }
170
171 if (len <= (int) ObjArrayMarkingStride*2) {
172 // A few slices only, process directly
173 array->oop_iterate_range(cl, 0, len);
174 } else {
237 pow--;
238 chunk *= 2;
239 bool pushed = q->push(ShenandoahMarkTask(array, true, weak, chunk - 1, pow));
240 assert(pushed, "overflow queue should always succeed pushing");
241 }
242
243 int chunk_size = 1 << pow;
244
245 int from = (chunk - 1) * chunk_size;
246 int to = chunk * chunk_size;
247
248 #ifdef ASSERT
249 int len = array->length();
250 assert (0 <= from && from < len, "from is sane: %d/%d", from, len);
251 assert (0 < to && to <= len, "to is sane: %d/%d", to, len);
252 #endif
253
254 array->oop_iterate_range(cl, from, to);
255 }
256
257 template <ShenandoahGenerationType GENERATION>
258 class ShenandoahSATBBufferClosure : public SATBBufferClosure {
259 private:
260 ShenandoahObjToScanQueue* _queue;
261 ShenandoahObjToScanQueue* _old_queue;
262 ShenandoahHeap* _heap;
263 ShenandoahMarkingContext* const _mark_context;
264 public:
265 ShenandoahSATBBufferClosure(ShenandoahObjToScanQueue* q, ShenandoahObjToScanQueue* old_q) :
266 _queue(q),
267 _old_queue(old_q),
268 _heap(ShenandoahHeap::heap()),
269 _mark_context(_heap->marking_context())
270 {
271 }
272
273 void do_buffer(void **buffer, size_t size) {
274 assert(size == 0 || !_heap->has_forwarded_objects() || _heap->is_concurrent_old_mark_in_progress(), "Forwarded objects are not expected here");
275 for (size_t i = 0; i < size; ++i) {
276 oop *p = (oop *) &buffer[i];
277 ShenandoahMark::mark_through_ref<oop, GENERATION>(p, _queue, _old_queue, _mark_context, false);
278 }
279 }
280 };
281
282 template<ShenandoahGenerationType GENERATION>
283 bool ShenandoahMark::in_generation(ShenandoahHeap* const heap, oop obj) {
284 // Each in-line expansion of in_generation() resolves GENERATION at compile time.
285 if (GENERATION == YOUNG) {
286 return heap->is_in_young(obj);
287 }
288
289 if (GENERATION == OLD) {
290 return heap->is_in_old(obj);
291 }
292
293 assert((GENERATION == GLOBAL || GENERATION == NON_GEN), "Unexpected generation type");
294 assert(heap->is_in(obj), "Object must be in heap");
295 return true;
296 }
297
298 template<class T, ShenandoahGenerationType GENERATION>
299 inline void ShenandoahMark::mark_through_ref(T *p, ShenandoahObjToScanQueue* q, ShenandoahObjToScanQueue* old_q, ShenandoahMarkingContext* const mark_context, bool weak) {
300 // Note: This is a very hot code path, so the code should be conditional on GENERATION template
301 // parameter where possible, in order to generate the most efficient code.
302
303 T o = RawAccess<>::oop_load(p);
304 if (!CompressedOops::is_null(o)) {
305 oop obj = CompressedOops::decode_not_null(o);
306
307 ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap();
308 shenandoah_assert_not_forwarded(p, obj);
309 shenandoah_assert_not_in_cset_except(p, obj, heap->cancelled_gc());
310 if (in_generation<GENERATION>(heap, obj)) {
311 mark_ref(q, mark_context, weak, obj);
312 shenandoah_assert_marked(p, obj);
313 // TODO: As implemented herein, GLOBAL collections reconstruct the card table during GLOBAL concurrent
314 // marking. Note that the card table is cleaned at init_mark time so it needs to be reconstructed to support
315 // future young-gen collections. It might be better to reconstruct card table in a different phase. We could
316 // either mark all live memory as dirty, or could use the GLOBAL update-refs scanning of pointers to determine
317 // precisely which cards to flag as dirty.
318 if (GENERATION == YOUNG && heap->is_in_old(p)) {
319 // Mark card as dirty because remembered set scanning still finds interesting pointer.
320 heap->old_generation()->mark_card_as_dirty((HeapWord*)p);
321 } else if (GENERATION == GLOBAL && heap->is_in_old(p) && heap->is_in_young(obj)) {
322 // Mark card as dirty because GLOBAL marking finds interesting pointer.
323 heap->old_generation()->mark_card_as_dirty((HeapWord*)p);
324 }
325 } else if (old_q != nullptr) {
326 // Young mark, bootstrapping old_q or concurrent with old_q marking.
327 mark_ref(old_q, mark_context, weak, obj);
328 shenandoah_assert_marked(p, obj);
329 } else if (GENERATION == OLD) {
330 // Old mark, found a young pointer.
331 // TODO: Rethink this: may be redundant with dirtying of cards identified during young-gen remembered set scanning
332 // and by mutator write barriers.
333 if (heap->is_in(p)) {
334 assert(heap->is_in_young(obj), "Expected young object.");
335 // TODO: This assert _should not_ pop, but it does. We need to figure out why.
336 // assert(heap->old_generation()->card_scan()->is_card_dirty((HeapWord*)p), "Card should already be marked.");
337 heap->old_generation()->mark_card_as_dirty(p);
338 }
339 }
340 }
341 }
342
343 template<>
344 inline void ShenandoahMark::mark_through_ref<oop, ShenandoahGenerationType::NON_GEN>(oop *p, ShenandoahObjToScanQueue* q, ShenandoahObjToScanQueue* old_q, ShenandoahMarkingContext* const mark_context, bool weak) {
345 mark_non_generational_ref(p, q, mark_context, weak);
346 }
347
348 template<>
349 inline void ShenandoahMark::mark_through_ref<narrowOop, ShenandoahGenerationType::NON_GEN>(narrowOop *p, ShenandoahObjToScanQueue* q, ShenandoahObjToScanQueue* old_q, ShenandoahMarkingContext* const mark_context, bool weak) {
350 mark_non_generational_ref(p, q, mark_context, weak);
351 }
352
353 template<class T>
354 inline void ShenandoahMark::mark_non_generational_ref(T* p, ShenandoahObjToScanQueue* q,
355 ShenandoahMarkingContext* const mark_context, bool weak) {
356 oop o = RawAccess<>::oop_load(p);
357 if (!CompressedOops::is_null(o)) {
358 oop obj = CompressedOops::decode_not_null(o);
359
360 shenandoah_assert_not_forwarded(p, obj);
361 shenandoah_assert_not_in_cset_except(p, obj, ShenandoahHeap::heap()->cancelled_gc());
362
363 mark_ref(q, mark_context, weak, obj);
364
365 shenandoah_assert_marked(p, obj);
366 }
367 }
368
369 inline void ShenandoahMark::mark_ref(ShenandoahObjToScanQueue* q,
370 ShenandoahMarkingContext* const mark_context,
371 bool weak, oop obj) {
372 bool skip_live = false;
373 bool marked;
374 if (weak) {
375 marked = mark_context->mark_weak(obj);
376 } else {
377 marked = mark_context->mark_strong(obj, /* was_upgraded = */ skip_live);
378 }
379 if (marked) {
380 bool pushed = q->push(ShenandoahMarkTask(obj, skip_live, weak));
381 assert(pushed, "overflow queue should always succeed pushing");
382 }
383 }
384
385 ShenandoahObjToScanQueueSet* ShenandoahMark::task_queues() const {
386 return _task_queues;
387 }
388
389 ShenandoahObjToScanQueue* ShenandoahMark::get_queue(uint index) const {
390 return _task_queues->queue(index);
391 }
392
393 ShenandoahObjToScanQueue* ShenandoahMark::get_old_queue(uint index) const {
394 if (_old_gen_task_queues != nullptr) {
395 return _old_gen_task_queues->queue(index);
396 }
397 return nullptr;
398 }
399
400 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARK_INLINE_HPP
|