annotate src/share/vm/gc_implementation/g1/g1RemSet.hpp @ 1836:894b1d7c7e01

6423256: GC stacks should use a better data structure 6942771: SEGV in ParScanThreadState::take_from_overflow_stack Reviewed-by: apetrusenko, ysr, pbk
author jcoomes
date Tue, 28 Sep 2010 15:56:15 -0700
parents a03ae377b2e8
children c32059ef4dc0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 890
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 890
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 890
diff changeset
21 * questions.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
25 // A G1RemSet provides ways of iterating over pointers into a selected
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
26 // collection set.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
27
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
28 class G1CollectedHeap;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
29 class CardTableModRefBarrierSet;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
30 class HRInto_G1RemSet;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
31 class ConcurrentG1Refine;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
32
549
fe3d7c11b4b7 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 342
diff changeset
33 class G1RemSet: public CHeapObj {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34 protected:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35 G1CollectedHeap* _g1;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36 unsigned _conc_refine_cards;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 size_t n_workers();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
38
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
39 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 G1RemSet(G1CollectedHeap* g1) :
794
315a5d70b295 6484957: G1: parallel concurrent refinement
iveresov
parents: 628
diff changeset
41 _g1(g1), _conc_refine_cards(0)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 // Invoke "blk->do_oop" on all pointers into the CS in object in regions
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45 // outside the CS (having invoked "blk->set_region" to set the "from"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
46 // region correctly beforehand.) The "worker_i" param is for the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
47 // parallel case where the number of the worker thread calling this
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
48 // function can be helpful in partitioning the work to be done. It
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
49 // should be the same as the "i" passed to the calling thread's
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50 // work(i) function. In the sequential case this param will be ingored.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51 virtual void oops_into_collection_set_do(OopsInHeapRegionClosure* blk,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
52 int worker_i) = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
54 // Prepare for and cleanup after an oops_into_collection_set_do
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
55 // call. Must call each of these once before and after (in sequential
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
56 // code) any threads call oops into collection set do. (This offers an
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
57 // opportunity to sequential setup and teardown of structures needed by a
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
58 // parallel iteration over the CS's RS.)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
59 virtual void prepare_for_oops_into_collection_set_do() = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
60 virtual void cleanup_after_oops_into_collection_set_do() = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
61
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
62 // If "this" is of the given subtype, return "this", else "NULL".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
63 virtual HRInto_G1RemSet* as_HRInto_G1RemSet() { return NULL; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
64
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
65 // Record, if necessary, the fact that *p (where "p" is in region "from",
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
66 // and is, a fortiori, required to be non-NULL) has changed to its new value.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
67 virtual void write_ref(HeapRegion* from, oop* p) = 0;
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
68 virtual void write_ref(HeapRegion* from, narrowOop* p) = 0;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
69 virtual void par_write_ref(HeapRegion* from, oop* p, int tid) = 0;
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
70 virtual void par_write_ref(HeapRegion* from, narrowOop* p, int tid) = 0;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
71
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
72 // Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
73 // or card, respectively, such that a region or card with a corresponding
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 // 0 bit contains no part of any live object. Eliminates any remembered
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 // set entries that correspond to dead heap ranges.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
76 virtual void scrub(BitMap* region_bm, BitMap* card_bm) = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
77 // Like the above, but assumes is called in parallel: "worker_num" is the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78 // parallel thread id of the current thread, and "claim_val" is the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79 // value that should be used to claim heap regions.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
80 virtual void scrub_par(BitMap* region_bm, BitMap* card_bm,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
81 int worker_num, int claim_val) = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
82
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 // Refine the card corresponding to "card_ptr". If "sts" is non-NULL,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84 // join and leave around parts that must be atomic wrt GC. (NULL means
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
85 // being done at a safepoint.)
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
86 // With some implementations of this routine, when check_for_refs_into_cset
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
87 // is true, a true result may be returned if the given card contains oops
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
88 // that have references into the current collection set.
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
89 virtual bool concurrentRefineOneCard(jbyte* card_ptr, int worker_i,
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
90 bool check_for_refs_into_cset) {
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
91 return false;
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
92 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
93
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94 // Print any relevant summary info.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
95 virtual void print_summary_info() {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
96
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
97 // Prepare remebered set for verification.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
98 virtual void prepare_for_verify() {};
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
99 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
100
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
101
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102 // The simplest possible G1RemSet: iterates over all objects in non-CS
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
103 // regions, searching for pointers into the CS.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
104 class StupidG1RemSet: public G1RemSet {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
105 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
106 StupidG1RemSet(G1CollectedHeap* g1) : G1RemSet(g1) {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
107
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
108 void oops_into_collection_set_do(OopsInHeapRegionClosure* blk,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
109 int worker_i);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
110
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
111 void prepare_for_oops_into_collection_set_do() {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
112 void cleanup_after_oops_into_collection_set_do() {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
113
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
114 // Nothing is necessary in the version below.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
115 void write_ref(HeapRegion* from, oop* p) {}
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
116 void write_ref(HeapRegion* from, narrowOop* p) {}
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
117 void par_write_ref(HeapRegion* from, oop* p, int tid) {}
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
118 void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {}
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
119
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
120 void scrub(BitMap* region_bm, BitMap* card_bm) {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121 void scrub_par(BitMap* region_bm, BitMap* card_bm,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
122 int worker_num, int claim_val) {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
124 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
125
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
126 // A G1RemSet in which each heap region has a rem set that records the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
127 // external heap references into it. Uses a mod ref bs to track updates,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
128 // so that they can be used to update the individual region remsets.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
129
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
130 class HRInto_G1RemSet: public G1RemSet {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 protected:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
132 enum SomePrivateConstants {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
133 UpdateRStoMergeSync = 0,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
134 MergeRStoDoDirtySync = 1,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 DoDirtySync = 2,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136 LastSync = 3,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 SeqTask = 0,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
139 NumSeqTasks = 1
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 CardTableModRefBS* _ct_bs;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143 SubTasksDone* _seq_task;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144 G1CollectorPolicy* _g1p;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146 ConcurrentG1Refine* _cg1r;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
147
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
148 size_t* _cards_scanned;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
149 size_t _total_cards_scanned;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150
1708
a03ae377b2e8 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 1705
diff changeset
151 // _traversal_in_progress is "true" iff a traversal is in progress.
a03ae377b2e8 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 1705
diff changeset
152
a03ae377b2e8 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 1705
diff changeset
153 bool _traversal_in_progress;
a03ae377b2e8 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 1705
diff changeset
154 void set_traversal(bool b) { _traversal_in_progress = b; }
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
155
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
156 // Used for caching the closure that is responsible for scanning
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
157 // references into the collection set.
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
158 OopsInHeapRegionClosure** _cset_rs_update_cl;
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
159
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 845
diff changeset
160 // The routine that performs the actual work of refining a dirty
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 845
diff changeset
161 // card.
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
162 // If check_for_refs_into_refs is true then a true result is returned
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
163 // if the card contains oops that have references into the current
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
164 // collection set.
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
165 bool concurrentRefineOneCard_impl(jbyte* card_ptr, int worker_i,
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
166 bool check_for_refs_into_cset);
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 845
diff changeset
167
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
168 protected:
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
169 template <class T> void write_ref_nv(HeapRegion* from, T* p);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
170 template <class T> void par_write_ref_nv(HeapRegion* from, T* p, int tid);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
173 // This is called to reset dual hash tables after the gc pause
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174 // is finished and the initial hash table is no longer being
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175 // scanned.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
176 void cleanupHRRS();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
177
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
178 HRInto_G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 ~HRInto_G1RemSet();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 void oops_into_collection_set_do(OopsInHeapRegionClosure* blk,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 int worker_i);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 void prepare_for_oops_into_collection_set_do();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 void cleanup_after_oops_into_collection_set_do();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186 void scanRS(OopsInHeapRegionClosure* oc, int worker_i);
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
187 template <class T> void scanNewRefsRS_work(OopsInHeapRegionClosure* oc, int worker_i);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
188 void scanNewRefsRS(OopsInHeapRegionClosure* oc, int worker_i) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
189 if (UseCompressedOops) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
190 scanNewRefsRS_work<narrowOop>(oc, worker_i);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
191 } else {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
192 scanNewRefsRS_work<oop>(oc, worker_i);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
193 }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
194 }
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
195 void updateRS(DirtyCardQueue* into_cset_dcq, int worker_i);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
196 HeapRegion* calculateStartRegion(int i);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198 HRInto_G1RemSet* as_HRInto_G1RemSet() { return this; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200 CardTableModRefBS* ct_bs() { return _ct_bs; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
201 size_t cardsScanned() { return _total_cards_scanned; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
202
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 // Record, if necessary, the fact that *p (where "p" is in region "from",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204 // which is required to be non-NULL) has changed to a new non-NULL value.
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
205 // [Below the virtual version calls a non-virtual protected
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
206 // workhorse that is templatified for narrow vs wide oop.]
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
207 inline void write_ref(HeapRegion* from, oop* p) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
208 write_ref_nv(from, p);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
209 }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
210 inline void write_ref(HeapRegion* from, narrowOop* p) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
211 write_ref_nv(from, p);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
212 }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
213 inline void par_write_ref(HeapRegion* from, oop* p, int tid) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
214 par_write_ref_nv(from, p, tid);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
215 }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
216 inline void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
217 par_write_ref_nv(from, p, tid);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
218 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
219
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
220 bool self_forwarded(oop obj);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
221
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
222 void scrub(BitMap* region_bm, BitMap* card_bm);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
223 void scrub_par(BitMap* region_bm, BitMap* card_bm,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 int worker_num, int claim_val);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
225
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
226 // If check_for_refs_into_cset is true then a true result is returned
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
227 // if the card contains oops that have references into the current
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
228 // collection set.
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
229 virtual bool concurrentRefineOneCard(jbyte* card_ptr, int worker_i,
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
230 bool check_for_refs_into_cset);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
231
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
232 virtual void print_summary_info();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233 virtual void prepare_for_verify();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
236 #define G1_REM_SET_LOGGING 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
238 class CountNonCleanMemRegionClosure: public MemRegionClosure {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
239 G1CollectedHeap* _g1;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240 int _n;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241 HeapWord* _start_first;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
243 CountNonCleanMemRegionClosure(G1CollectedHeap* g1) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
244 _g1(g1), _n(0), _start_first(NULL)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
245 {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
246 void do_MemRegion(MemRegion mr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
247 int n() { return _n; };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
248 HeapWord* start_first() { return _start_first; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
249 };
626
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
250
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
251 class UpdateRSOopClosure: public OopClosure {
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
252 HeapRegion* _from;
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
253 HRInto_G1RemSet* _rs;
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
254 int _worker_i;
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
255
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
256 template <class T> void do_oop_work(T* p);
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
257
626
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
258 public:
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
259 UpdateRSOopClosure(HRInto_G1RemSet* rs, int worker_i = 0) :
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
260 _from(NULL), _rs(rs), _worker_i(worker_i) {
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
261 guarantee(_rs != NULL, "Requires an HRIntoG1RemSet");
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
262 }
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
263
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
264 void set_from(HeapRegion* from) {
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
265 assert(from != NULL, "from region must be non-NULL");
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
266 _from = from;
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
267 }
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
268
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
269 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 794
diff changeset
270 virtual void do_oop(oop* p) { do_oop_work(p); }
626
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
271
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
272 // Override: this closure is idempotent.
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
273 // bool idempotent() { return true; }
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
274 bool apply_to_weak_ref_discovered_field() { return true; }
87fa6e083d82 6760309: G1: update remembered sets during Full GCs
apetrusenko
parents: 616
diff changeset
275 };
1705
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
276
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
277 class UpdateRSetImmediate: public OopsInHeapRegionClosure {
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
278 private:
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
279 G1RemSet* _g1_rem_set;
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
280
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
281 template <class T> void do_oop_work(T* p);
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
282 public:
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
283 UpdateRSetImmediate(G1RemSet* rs) :
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
284 _g1_rem_set(rs) {}
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
285
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
286 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
287 virtual void do_oop( oop* p) { do_oop_work(p); }
2d160770d2e5 6814437: G1: remove the _new_refs array
johnc
parents: 1552
diff changeset
288 };