|
1 | 1 | /* |
2 | | - * Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved. |
| 2 | + * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
27 | 27 |
|
28 | 28 | #include "gc/shared/taskqueue.hpp" |
29 | 29 | #include "gc/shared/taskTerminator.hpp" |
| 30 | +#include "gc/shenandoah/shenandoahMark.hpp" |
30 | 31 | #include "gc/shenandoah/shenandoahOopClosures.hpp" |
31 | | -#include "gc/shenandoah/shenandoahPhaseTimings.hpp" |
32 | 32 | #include "gc/shenandoah/shenandoahTaskqueue.hpp" |
33 | 33 |
|
34 | 34 | class ShenandoahStrDedupQueue; |
35 | 35 | class ShenandoahReferenceProcessor; |
36 | 36 |
|
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; |
41 | 40 |
|
42 | 41 | 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(); |
51 | 43 |
|
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(); |
54 | 47 |
|
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(); |
57 | 52 |
|
58 | | - inline void count_liveness(ShenandoahLiveData* live_data, oop obj); |
59 | 53 |
|
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(); |
75 | 55 |
|
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); |
92 | 59 |
|
| 60 | +private: |
| 61 | + void finish_mark_work(); |
93 | 62 | }; |
94 | 63 |
|
95 | 64 | #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP |
0 commit comments