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

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

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

merge

aoqi@0 1 /*
stefank@6969 2 * Copyright (c) 2001, 2014, 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_G1REMSET_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP
aoqi@0 27
aoqi@0 28 #include "gc_implementation/g1/g1RemSetSummary.hpp"
aoqi@0 29
aoqi@0 30 // A G1RemSet provides ways of iterating over pointers into a selected
aoqi@0 31 // collection set.
aoqi@0 32
aoqi@0 33 class G1CollectedHeap;
aoqi@0 34 class CardTableModRefBarrierSet;
aoqi@0 35 class ConcurrentG1Refine;
mgerdin@7655 36 class G1ParPushHeapRSClosure;
aoqi@0 37
aoqi@0 38 // A G1RemSet in which each heap region has a rem set that records the
aoqi@0 39 // external heap references into it. Uses a mod ref bs to track updates,
aoqi@0 40 // so that they can be used to update the individual region remsets.
aoqi@0 41
aoqi@0 42 class G1RemSet: public CHeapObj<mtGC> {
aoqi@0 43 private:
aoqi@0 44 G1RemSetSummary _prev_period_summary;
aoqi@0 45 protected:
aoqi@0 46 G1CollectedHeap* _g1;
aoqi@0 47 size_t _conc_refine_cards;
aoqi@0 48 uint n_workers();
aoqi@0 49
aoqi@0 50 protected:
aoqi@0 51 enum SomePrivateConstants {
aoqi@0 52 UpdateRStoMergeSync = 0,
aoqi@0 53 MergeRStoDoDirtySync = 1,
aoqi@0 54 DoDirtySync = 2,
aoqi@0 55 LastSync = 3,
aoqi@0 56
aoqi@0 57 SeqTask = 0,
aoqi@0 58 NumSeqTasks = 1
aoqi@0 59 };
aoqi@0 60
aoqi@0 61 CardTableModRefBS* _ct_bs;
aoqi@0 62 G1CollectorPolicy* _g1p;
aoqi@0 63
aoqi@0 64 ConcurrentG1Refine* _cg1r;
aoqi@0 65
aoqi@0 66 size_t* _cards_scanned;
aoqi@0 67 size_t _total_cards_scanned;
aoqi@0 68
aoqi@0 69 // Used for caching the closure that is responsible for scanning
aoqi@0 70 // references into the collection set.
mgerdin@7655 71 G1ParPushHeapRSClosure** _cset_rs_update_cl;
aoqi@0 72
aoqi@0 73 // Print the given summary info
aoqi@0 74 virtual void print_summary_info(G1RemSetSummary * summary, const char * header = NULL);
aoqi@0 75 public:
aoqi@0 76 // This is called to reset dual hash tables after the gc pause
aoqi@0 77 // is finished and the initial hash table is no longer being
aoqi@0 78 // scanned.
aoqi@0 79 void cleanupHRRS();
aoqi@0 80
aoqi@0 81 G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs);
aoqi@0 82 ~G1RemSet();
aoqi@0 83
aoqi@0 84 // Invoke "blk->do_oop" on all pointers into the collection set
aoqi@0 85 // from objects in regions outside the collection set (having
aoqi@0 86 // invoked "blk->set_region" to set the "from" region correctly
aoqi@0 87 // beforehand.)
aoqi@0 88 //
aoqi@0 89 // Invoke code_root_cl->do_code_blob on the unmarked nmethods
aoqi@0 90 // on the strong code roots list for each region in the
aoqi@0 91 // collection set.
aoqi@0 92 //
aoqi@0 93 // The "worker_i" param is for the parallel case where the id
aoqi@0 94 // of the worker thread calling this function can be helpful in
aoqi@0 95 // partitioning the work to be done. It should be the same as
aoqi@0 96 // the "i" passed to the calling thread's work(i) function.
aoqi@0 97 // In the sequential case this param will be ignored.
mgerdin@7655 98 void oops_into_collection_set_do(G1ParPushHeapRSClosure* blk,
mgerdin@7208 99 CodeBlobClosure* code_root_cl,
aoqi@0 100 uint worker_i);
aoqi@0 101
aoqi@0 102 // Prepare for and cleanup after an oops_into_collection_set_do
aoqi@0 103 // call. Must call each of these once before and after (in sequential
aoqi@0 104 // code) any threads call oops_into_collection_set_do. (This offers an
aoqi@0 105 // opportunity to sequential setup and teardown of structures needed by a
aoqi@0 106 // parallel iteration over the CS's RS.)
aoqi@0 107 void prepare_for_oops_into_collection_set_do();
aoqi@0 108 void cleanup_after_oops_into_collection_set_do();
aoqi@0 109
mgerdin@7655 110 void scanRS(G1ParPushHeapRSClosure* oc,
mgerdin@7208 111 CodeBlobClosure* code_root_cl,
aoqi@0 112 uint worker_i);
aoqi@0 113
aoqi@0 114 void updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i);
aoqi@0 115
aoqi@0 116 CardTableModRefBS* ct_bs() { return _ct_bs; }
aoqi@0 117 size_t cardsScanned() { return _total_cards_scanned; }
aoqi@0 118
aoqi@0 119 // Record, if necessary, the fact that *p (where "p" is in region "from",
aoqi@0 120 // which is required to be non-NULL) has changed to a new non-NULL value.
aoqi@0 121 template <class T> void write_ref(HeapRegion* from, T* p);
aoqi@0 122 template <class T> void par_write_ref(HeapRegion* from, T* p, int tid);
aoqi@0 123
aoqi@0 124 // Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
aoqi@0 125 // or card, respectively, such that a region or card with a corresponding
aoqi@0 126 // 0 bit contains no part of any live object. Eliminates any remembered
aoqi@0 127 // set entries that correspond to dead heap ranges.
aoqi@0 128 void scrub(BitMap* region_bm, BitMap* card_bm);
aoqi@0 129
aoqi@0 130 // Like the above, but assumes is called in parallel: "worker_num" is the
aoqi@0 131 // parallel thread id of the current thread, and "claim_val" is the
aoqi@0 132 // value that should be used to claim heap regions.
aoqi@0 133 void scrub_par(BitMap* region_bm, BitMap* card_bm,
aoqi@0 134 uint worker_num, int claim_val);
aoqi@0 135
aoqi@0 136 // Refine the card corresponding to "card_ptr".
aoqi@0 137 // If check_for_refs_into_cset is true, a true result is returned
aoqi@0 138 // if the given card contains oops that have references into the
aoqi@0 139 // current collection set.
aoqi@0 140 virtual bool refine_card(jbyte* card_ptr,
aoqi@0 141 uint worker_i,
aoqi@0 142 bool check_for_refs_into_cset);
aoqi@0 143
aoqi@0 144 // Print accumulated summary info from the start of the VM.
aoqi@0 145 virtual void print_summary_info();
aoqi@0 146
aoqi@0 147 // Print accumulated summary info from the last time called.
aoqi@0 148 virtual void print_periodic_summary_info(const char* header);
aoqi@0 149
aoqi@0 150 // Prepare remembered set for verification.
aoqi@0 151 virtual void prepare_for_verify();
aoqi@0 152
aoqi@0 153 size_t conc_refine_cards() const {
aoqi@0 154 return _conc_refine_cards;
aoqi@0 155 }
aoqi@0 156 };
aoqi@0 157
aoqi@0 158 class CountNonCleanMemRegionClosure: public MemRegionClosure {
aoqi@0 159 G1CollectedHeap* _g1;
aoqi@0 160 int _n;
aoqi@0 161 HeapWord* _start_first;
aoqi@0 162 public:
aoqi@0 163 CountNonCleanMemRegionClosure(G1CollectedHeap* g1) :
aoqi@0 164 _g1(g1), _n(0), _start_first(NULL)
aoqi@0 165 {}
aoqi@0 166 void do_MemRegion(MemRegion mr);
aoqi@0 167 int n() { return _n; };
aoqi@0 168 HeapWord* start_first() { return _start_first; }
aoqi@0 169 };
aoqi@0 170
aoqi@0 171 class UpdateRSOopClosure: public ExtendedOopClosure {
aoqi@0 172 HeapRegion* _from;
aoqi@0 173 G1RemSet* _rs;
aoqi@0 174 uint _worker_i;
aoqi@0 175
aoqi@0 176 template <class T> void do_oop_work(T* p);
aoqi@0 177
aoqi@0 178 public:
aoqi@0 179 UpdateRSOopClosure(G1RemSet* rs, uint worker_i = 0) :
aoqi@0 180 _from(NULL), _rs(rs), _worker_i(worker_i)
aoqi@0 181 {}
aoqi@0 182
aoqi@0 183 void set_from(HeapRegion* from) {
aoqi@0 184 assert(from != NULL, "from region must be non-NULL");
aoqi@0 185 _from = from;
aoqi@0 186 }
aoqi@0 187
aoqi@0 188 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
aoqi@0 189 virtual void do_oop(oop* p) { do_oop_work(p); }
aoqi@0 190
aoqi@0 191 // Override: this closure is idempotent.
aoqi@0 192 // bool idempotent() { return true; }
aoqi@0 193 bool apply_to_weak_ref_discovered_field() { return true; }
aoqi@0 194 };
aoqi@0 195
aoqi@0 196 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP

mercurial