Skip to content

Commit da6bcf9

Browse files
committed
8255019: Shenandoah: Split STW and concurrent mark into separate classes
Reviewed-by: rkennke, shade
1 parent aba3431 commit da6bcf9

20 files changed

+932
-620
lines changed

src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp

Lines changed: 89 additions & 332 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,69 +27,38 @@
2727

2828
#include "gc/shared/taskqueue.hpp"
2929
#include "gc/shared/taskTerminator.hpp"
30+
#include "gc/shenandoah/shenandoahMark.hpp"
3031
#include "gc/shenandoah/shenandoahOopClosures.hpp"
31-
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
3232
#include "gc/shenandoah/shenandoahTaskqueue.hpp"
3333

3434
class ShenandoahStrDedupQueue;
3535
class ShenandoahReferenceProcessor;
3636

37-
class ShenandoahConcurrentMark: public CHeapObj<mtGC> {
38-
private:
39-
ShenandoahHeap* _heap;
40-
ShenandoahObjToScanQueueSet* _task_queues;
37+
class ShenandoahConcurrentMark: public ShenandoahMark {
38+
friend class ShenandoahConcurrentMarkingTask;
39+
friend class ShenandoahFinalMarkingTask;
4140

4241
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, ShenandoahLiveData* live_data, ShenandoahMarkTask* task);
42+
ShenandoahConcurrentMark();
5143

52-
template <class T>
53-
inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array, bool weak);
44+
// When concurrent stack processing is not supported
45+
void mark_stw_roots();
46+
void mark_concurrent_roots();
5447

55-
template <class T>
56-
inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow, bool weak);
48+
// Concurrent mark
49+
void concurrent_mark();
50+
// Finish mark at a safepoint
51+
void finish_mark();
5752

58-
inline void count_liveness(ShenandoahLiveData* live_data, oop obj);
5953

60-
template <class T, bool CANCELLABLE>
61-
void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, TaskTerminator *t);
62-
63-
template <bool CANCELLABLE>
64-
void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ShenandoahReferenceProcessor* rp, bool strdedup);
65-
66-
public:
67-
void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor* 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-
}
54+
static void cancel();
7555

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, bool weak);
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-
// ---------- Helpers
87-
// Used from closures, need to be public
88-
//
89-
public:
90-
ShenandoahObjToScanQueue* get_queue(uint worker_id);
91-
ShenandoahObjToScanQueueSet* task_queues() { return _task_queues; }
56+
// TODO: where to put them
57+
static void update_roots(ShenandoahPhaseTimings::Phase root_phase);
58+
static void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase);
9259

60+
private:
61+
void finish_mark_work();
9362
};
9463

9564
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP

src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,12 +24,13 @@
2424

2525
#include "precompiled.hpp"
2626

27-
#include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
27+
#include "gc/shenandoah/shenandoahConcurrentMark.hpp"
2828
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
2929
#include "gc/shenandoah/shenandoahControlThread.hpp"
3030
#include "gc/shenandoah/shenandoahFreeSet.hpp"
3131
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
3232
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
33+
#include "gc/shenandoah/shenandoahMark.inline.hpp"
3334
#include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
3435
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
3536
#include "gc/shenandoah/shenandoahUtils.hpp"
@@ -397,6 +398,10 @@ void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cau
397398
// Start initial mark under STW
398399
heap->vmop_entry_init_mark();
399400

401+
// Concurrent mark roots
402+
heap->entry_mark_roots();
403+
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_outside_cycle)) return;
404+
400405
// Continue concurrent mark
401406
heap->entry_mark();
402407
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_mark)) return;

0 commit comments

Comments
 (0)