annotate src/share/vm/gc/g1/g1MarkSweep.hpp @ 13535:4d2fded7bd7d

8177544: Restructure G1 Full GC code Reviewed-by: tschatzl, ehelin
author sjohanss
date Mon, 21 Aug 2017 10:45:02 +0200
parents 47e760fe99e8
children
rev   line source
ysr@342 1 /*
sjohanss@12514 2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
ysr@342 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@342 4 *
ysr@342 5 * This code is free software; you can redistribute it and/or modify it
ysr@342 6 * under the terms of the GNU General Public License version 2 only, as
ysr@342 7 * published by the Free Software Foundation.
ysr@342 8 *
ysr@342 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@342 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@342 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@342 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@342 13 * accompanied this code).
ysr@342 14 *
ysr@342 15 * You should have received a copy of the GNU General Public License version
ysr@342 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@342 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@342 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
ysr@342 22 *
ysr@342 23 */
ysr@342 24
pliden@8413 25 #ifndef SHARE_VM_GC_G1_G1MARKSWEEP_HPP
pliden@8413 26 #define SHARE_VM_GC_G1_G1MARKSWEEP_HPP
stefank@1879 27
pliden@8413 28 #include "gc/g1/g1CollectedHeap.hpp"
pliden@8413 29 #include "gc/g1/heapRegion.hpp"
pliden@8413 30 #include "gc/serial/genMarkSweep.hpp"
pliden@8413 31 #include "gc/shared/generation.hpp"
stefank@1879 32 #include "memory/universe.hpp"
stefank@1879 33 #include "oops/markOop.hpp"
stefank@1879 34 #include "oops/oop.hpp"
stefank@1879 35 #include "runtime/timer.hpp"
stefank@1879 36 #include "utilities/growableArray.hpp"
stefank@1879 37
ysr@342 38 class ReferenceProcessor;
ysr@342 39
ysr@342 40 // G1MarkSweep takes care of global mark-compact garbage collection for a
ysr@342 41 // G1CollectedHeap using a four-phase pointer forwarding algorithm. All
ysr@342 42 // generations are assumed to support marking; those that can also support
ysr@342 43 // compaction.
ysr@342 44 //
ysr@342 45 // Class unloading will only occur when a full gc is invoked.
sjohanss@7124 46 class G1PrepareCompactClosure;
jiangli@8544 47 class G1ArchiveRegionMap;
ysr@342 48
ysr@342 49 class G1MarkSweep : AllStatic {
ysr@342 50 public:
ysr@342 51
ysr@342 52 static void invoke_at_safepoint(ReferenceProcessor* rp,
ysr@342 53 bool clear_all_softrefs);
ysr@342 54
sjohanss@13535 55 static STWGCTimer* gc_timer();
sjohanss@13535 56 static SerialOldTracer* gc_tracer();
sla@4802 57
sjohanss@12514 58 private:
ysr@342 59 // Mark live objects
ysr@342 60 static void mark_sweep_phase1(bool& marked_for_deopt,
ysr@342 61 bool clear_all_softrefs);
ysr@342 62 // Calculate new addresses
ysr@342 63 static void mark_sweep_phase2();
ysr@342 64 // Update pointers
ysr@342 65 static void mark_sweep_phase3();
ysr@342 66 // Move objects to new positions
ysr@342 67 static void mark_sweep_phase4();
ysr@342 68
ysr@342 69 static void allocate_stacks();
sjohanss@7124 70 static void prepare_compaction();
sjohanss@7124 71 static void prepare_compaction_work(G1PrepareCompactClosure* blk);
sjohanss@7124 72 };
sjohanss@7124 73
sjohanss@7124 74 class G1PrepareCompactClosure : public HeapRegionClosure {
sjohanss@7124 75 protected:
sjohanss@7124 76 G1CollectedHeap* _g1h;
sjohanss@7124 77 ModRefBarrierSet* _mrbs;
sjohanss@7124 78 CompactPoint _cp;
david@9731 79 uint _humongous_regions_removed;
sjohanss@7124 80
sjohanss@7124 81 virtual void prepare_for_compaction(HeapRegion* hr, HeapWord* end);
sjohanss@7124 82 void prepare_for_compaction_work(CompactPoint* cp, HeapRegion* hr, HeapWord* end);
sjohanss@7124 83 void free_humongous_region(HeapRegion* hr);
sjohanss@7124 84 bool is_cp_initialized() const { return _cp.space != NULL; }
sjohanss@7124 85
sjohanss@7124 86 public:
sjohanss@7124 87 G1PrepareCompactClosure() :
sjohanss@7124 88 _g1h(G1CollectedHeap::heap()),
sjohanss@7124 89 _mrbs(_g1h->g1_barrier_set()),
david@9731 90 _humongous_regions_removed(0) { }
sjohanss@7124 91
sjohanss@7124 92 void update_sets();
sjohanss@7124 93 bool doHeapRegion(HeapRegion* hr);
ysr@342 94 };
stefank@1879 95
pliden@8413 96 #endif // SHARE_VM_GC_G1_G1MARKSWEEP_HPP