1 /*
2 * Copyright (c) 2014, 2021, 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_SHENANDOAHFULLGC_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHFULLGC_HPP
27
28 #include "gc/shared/gcTimer.hpp"
29 #include "gc/shenandoah/shenandoahGC.hpp"
30 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
31
32 /**
33 * This implements Full GC (e.g. when invoking System.gc()) using a mark-compact algorithm.
34 *
35 * Current implementation is parallel sliding Lisp-2-style algorithm, based on
36 * "Parallel Garbage Collection for Shared Memory Multiprocessors", by Christine Flood et al.
37 * http://people.csail.mit.edu/shanir/publications/dfsz2001.pdf
38 *
39 * It is implemented in four phases:
40 *
41 * 1. Mark all live objects of the heap by traversing objects starting at GC roots.
42 * 2. Calculate the new location of each live object. This is done by sequentially scanning
43 * the heap, keeping track of a next-location-pointer, which is then written to each
44 * object's fwdptr field.
45 * 3. Update all references. This is implemented by another scan of the heap, and updates
46 * all references in live objects by what's stored in the target object's fwdptr.
47 * 4. Compact the heap by copying all live objects to their new location.
48 *
49 * Parallelization is handled by assigning each GC worker the slice of the heap (the set of regions)
50 * where it does sliding compaction, without interfering with other threads.
51 */
52
53 class PreservedMarksSet;
54 class VM_ShenandoahFullGC;
55 class ShenandoahDegenGC;
56
57 class ShenandoahFullGC : public ShenandoahGC {
58 friend class ShenandoahPrepareForCompactionObjectClosure;
59 friend class VM_ShenandoahFullGC;
60 friend class ShenandoahDegenGC;
61
62 private:
63 GCTimer* _gc_timer;
64
65 PreservedMarksSet* _preserved_marks;
66
67 public:
68 ShenandoahFullGC();
69 ~ShenandoahFullGC();
70 bool collect(GCCause::Cause cause);
71
72 private:
73 // GC entries
74 void vmop_entry_full(GCCause::Cause cause);
75 void entry_full(GCCause::Cause cause);
76 void op_full(GCCause::Cause cause);
77
78 void do_it(GCCause::Cause gc_cause);
79
80 void phase1_mark_heap();
81 void phase2_calculate_target_addresses(ShenandoahHeapRegionSet** worker_slices);
82 void phase3_update_references();
83 void phase4_compact_objects(ShenandoahHeapRegionSet** worker_slices);
84 void phase5_epilog();
85
86 void distribute_slices(ShenandoahHeapRegionSet** worker_slices);
87 void calculate_target_humongous_objects();
88 void compact_humongous_objects();
89 };
90
91 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFULLGC_HPP
--- EOF ---