1/*
2 * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_HPP
25#define SHARE_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_HPP
26
27#include "memory/allocation.hpp"
28#include "gc/shenandoah/shenandoahHeap.hpp"
29#include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
30#include "gc/shenandoah/shenandoahTaskqueue.hpp"
31#include "runtime/thread.hpp"
32
33class ShenandoahTraversalGC : public CHeapObj<mtGC> {
34private:
35 ShenandoahHeap* const _heap;
36 ShenandoahObjToScanQueueSet* const _task_queues;
37 ShenandoahHeapRegionSet _traversal_set;
38
39public:
40 ShenandoahTraversalGC(ShenandoahHeap* heap, size_t num_regions);
41 ~ShenandoahTraversalGC();
42
43 ShenandoahHeapRegionSet* traversal_set() { return &_traversal_set; }
44
45 void reset();
46 void prepare();
47 void init_traversal_collection();
48 void concurrent_traversal_collection();
49 void final_traversal_collection();
50
51 template <class T, bool STRING_DEDUP, bool DEGEN>
52 inline void process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, ShenandoahMarkingContext* const mark_context);
53
54 bool check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield);
55
56 ShenandoahObjToScanQueueSet* task_queues();
57
58 void main_loop(uint worker_id, ShenandoahTaskTerminator* terminator, bool sts_yield);
59
60private:
61 void prepare_regions();
62
63 template <class T>
64 void main_loop_work(T* cl, jushort* live_data, uint worker_id, ShenandoahTaskTerminator* terminator, bool sts_yield);
65
66 void preclean_weak_refs();
67 void weak_refs_work();
68 void weak_refs_work_doit();
69
70 void fixup_roots();
71};
72
73#endif // SHARE_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_HPP
74