src/share/vm/gc_implementation/g1/g1MarkSweep.hpp

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

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

mercurial