Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/g1/heapRegion.hpp @ 2149:7e37af9d69ef
7011379: G1: overly long concurrent marking cycles
Summary: This changeset introduces filtering of SATB buffers at the point when they are about to be enqueued. If this filtering clears enough entries on each buffer, the buffer can then be re-used and not enqueued. This cuts down the number of SATB buffers that need to be processed by the concurrent marking threads.
Reviewed-by: johnc, ysr
author | tonyp |
---|---|
date | Wed, 19 Jan 2011 09:35:17 -0500 |
parents | b158bed62ef5 |
children | 0fa27f37d4d4 |
rev | line source |
---|---|
342 | 1 /* |
2133
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
342 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1394
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1394
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:
1394
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP | |
27 | |
28 #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" | |
29 #include "gc_implementation/g1/g1_specialized_oop_closures.hpp" | |
30 #include "gc_implementation/g1/survRateGroup.hpp" | |
31 #include "gc_implementation/shared/ageTable.hpp" | |
32 #include "gc_implementation/shared/spaceDecorator.hpp" | |
33 #include "memory/space.inline.hpp" | |
34 #include "memory/watermark.hpp" | |
35 | |
342 | 36 #ifndef SERIALGC |
37 | |
38 // A HeapRegion is the smallest piece of a G1CollectedHeap that | |
39 // can be collected independently. | |
40 | |
41 // NOTE: Although a HeapRegion is a Space, its | |
42 // Space::initDirtyCardClosure method must not be called. | |
43 // The problem is that the existence of this method breaks | |
44 // the independence of barrier sets from remembered sets. | |
45 // The solution is to remove this method from the definition | |
46 // of a Space. | |
47 | |
48 class CompactibleSpace; | |
49 class ContiguousSpace; | |
50 class HeapRegionRemSet; | |
51 class HeapRegionRemSetIterator; | |
52 class HeapRegion; | |
53 | |
54 // A dirty card to oop closure for heap regions. It | |
55 // knows how to get the G1 heap and how to use the bitmap | |
56 // in the concurrent marker used by G1 to filter remembered | |
57 // sets. | |
58 | |
59 class HeapRegionDCTOC : public ContiguousSpaceDCTOC { | |
60 public: | |
61 // Specification of possible DirtyCardToOopClosure filtering. | |
62 enum FilterKind { | |
63 NoFilterKind, | |
64 IntoCSFilterKind, | |
65 OutOfRegionFilterKind | |
66 }; | |
67 | |
68 protected: | |
69 HeapRegion* _hr; | |
70 FilterKind _fk; | |
71 G1CollectedHeap* _g1; | |
72 | |
73 void walk_mem_region_with_cl(MemRegion mr, | |
74 HeapWord* bottom, HeapWord* top, | |
75 OopClosure* cl); | |
76 | |
77 // We don't specialize this for FilteringClosure; filtering is handled by | |
78 // the "FilterKind" mechanism. But we provide this to avoid a compiler | |
79 // warning. | |
80 void walk_mem_region_with_cl(MemRegion mr, | |
81 HeapWord* bottom, HeapWord* top, | |
82 FilteringClosure* cl) { | |
83 HeapRegionDCTOC::walk_mem_region_with_cl(mr, bottom, top, | |
84 (OopClosure*)cl); | |
85 } | |
86 | |
87 // Get the actual top of the area on which the closure will | |
88 // operate, given where the top is assumed to be (the end of the | |
89 // memory region passed to do_MemRegion) and where the object | |
90 // at the top is assumed to start. For example, an object may | |
91 // start at the top but actually extend past the assumed top, | |
92 // in which case the top becomes the end of the object. | |
93 HeapWord* get_actual_top(HeapWord* top, HeapWord* top_obj) { | |
94 return ContiguousSpaceDCTOC::get_actual_top(top, top_obj); | |
95 } | |
96 | |
97 // Walk the given memory region from bottom to (actual) top | |
98 // looking for objects and applying the oop closure (_cl) to | |
99 // them. The base implementation of this treats the area as | |
100 // blocks, where a block may or may not be an object. Sub- | |
101 // classes should override this to provide more accurate | |
102 // or possibly more efficient walking. | |
103 void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top) { | |
104 Filtering_DCTOC::walk_mem_region(mr, bottom, top); | |
105 } | |
106 | |
107 public: | |
108 HeapRegionDCTOC(G1CollectedHeap* g1, | |
109 HeapRegion* hr, OopClosure* cl, | |
110 CardTableModRefBS::PrecisionStyle precision, | |
111 FilterKind fk); | |
112 }; | |
113 | |
114 | |
115 // The complicating factor is that BlockOffsetTable diverged | |
116 // significantly, and we need functionality that is only in the G1 version. | |
117 // So I copied that code, which led to an alternate G1 version of | |
118 // OffsetTableContigSpace. If the two versions of BlockOffsetTable could | |
119 // be reconciled, then G1OffsetTableContigSpace could go away. | |
120 | |
121 // The idea behind time stamps is the following. Doing a save_marks on | |
122 // all regions at every GC pause is time consuming (if I remember | |
123 // well, 10ms or so). So, we would like to do that only for regions | |
124 // that are GC alloc regions. To achieve this, we use time | |
125 // stamps. For every evacuation pause, G1CollectedHeap generates a | |
126 // unique time stamp (essentially a counter that gets | |
127 // incremented). Every time we want to call save_marks on a region, | |
128 // we set the saved_mark_word to top and also copy the current GC | |
129 // time stamp to the time stamp field of the space. Reading the | |
130 // saved_mark_word involves checking the time stamp of the | |
131 // region. If it is the same as the current GC time stamp, then we | |
132 // can safely read the saved_mark_word field, as it is valid. If the | |
133 // time stamp of the region is not the same as the current GC time | |
134 // stamp, then we instead read top, as the saved_mark_word field is | |
135 // invalid. Time stamps (on the regions and also on the | |
136 // G1CollectedHeap) are reset at every cleanup (we iterate over | |
137 // the regions anyway) and at the end of a Full GC. The current scheme | |
138 // that uses sequential unsigned ints will fail only if we have 4b | |
139 // evacuation pauses between two cleanups, which is _highly_ unlikely. | |
140 | |
141 class G1OffsetTableContigSpace: public ContiguousSpace { | |
142 friend class VMStructs; | |
143 protected: | |
144 G1BlockOffsetArrayContigSpace _offsets; | |
145 Mutex _par_alloc_lock; | |
146 volatile unsigned _gc_time_stamp; | |
147 | |
148 public: | |
149 // Constructor. If "is_zeroed" is true, the MemRegion "mr" may be | |
150 // assumed to contain zeros. | |
151 G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, | |
152 MemRegion mr, bool is_zeroed = false); | |
153 | |
154 void set_bottom(HeapWord* value); | |
155 void set_end(HeapWord* value); | |
156 | |
157 virtual HeapWord* saved_mark_word() const; | |
158 virtual void set_saved_mark(); | |
159 void reset_gc_time_stamp() { _gc_time_stamp = 0; } | |
160 | |
356 | 161 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space); |
162 virtual void clear(bool mangle_space); | |
342 | 163 |
164 HeapWord* block_start(const void* p); | |
165 HeapWord* block_start_const(const void* p) const; | |
166 | |
167 // Add offset table update. | |
168 virtual HeapWord* allocate(size_t word_size); | |
169 HeapWord* par_allocate(size_t word_size); | |
170 | |
171 // MarkSweep support phase3 | |
172 virtual HeapWord* initialize_threshold(); | |
173 virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* end); | |
174 | |
175 virtual void print() const; | |
2133
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
176 |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
177 void reset_bot() { |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
178 _offsets.zero_bottom_entry(); |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
179 _offsets.initialize_threshold(); |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
180 } |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
181 |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
182 void update_bot_for_object(HeapWord* start, size_t word_size) { |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
183 _offsets.alloc_block(start, word_size); |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
184 } |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
185 |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
186 void print_bot_on(outputStream* out) { |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
187 _offsets.print_on(out); |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
188 } |
342 | 189 }; |
190 | |
191 class HeapRegion: public G1OffsetTableContigSpace { | |
192 friend class VMStructs; | |
193 private: | |
194 | |
355 | 195 enum HumongousType { |
196 NotHumongous = 0, | |
197 StartsHumongous, | |
198 ContinuesHumongous | |
199 }; | |
200 | |
342 | 201 // The next filter kind that should be used for a "new_dcto_cl" call with |
202 // the "traditional" signature. | |
203 HeapRegionDCTOC::FilterKind _next_fk; | |
204 | |
205 // Requires that the region "mr" be dense with objects, and begin and end | |
206 // with an object. | |
207 void oops_in_mr_iterate(MemRegion mr, OopClosure* cl); | |
208 | |
209 // The remembered set for this region. | |
210 // (Might want to make this "inline" later, to avoid some alloc failure | |
211 // issues.) | |
212 HeapRegionRemSet* _rem_set; | |
213 | |
214 G1BlockOffsetArrayContigSpace* offsets() { return &_offsets; } | |
215 | |
216 protected: | |
217 // If this region is a member of a HeapRegionSeq, the index in that | |
218 // sequence, otherwise -1. | |
219 int _hrs_index; | |
220 | |
355 | 221 HumongousType _humongous_type; |
342 | 222 // For a humongous region, region in which it starts. |
223 HeapRegion* _humongous_start_region; | |
224 // For the start region of a humongous sequence, it's original end(). | |
225 HeapWord* _orig_end; | |
226 | |
227 // True iff the region is in current collection_set. | |
228 bool _in_collection_set; | |
229 | |
230 // True iff the region is on the unclean list, waiting to be zero filled. | |
231 bool _is_on_unclean_list; | |
232 | |
233 // True iff the region is on the free list, ready for allocation. | |
234 bool _is_on_free_list; | |
235 | |
236 // Is this or has it been an allocation region in the current collection | |
237 // pause. | |
238 bool _is_gc_alloc_region; | |
239 | |
240 // True iff an attempt to evacuate an object in the region failed. | |
241 bool _evacuation_failed; | |
242 | |
243 // A heap region may be a member one of a number of special subsets, each | |
244 // represented as linked lists through the field below. Currently, these | |
245 // sets include: | |
246 // The collection set. | |
247 // The set of allocation regions used in a collection pause. | |
248 // Spaces that may contain gray objects. | |
249 HeapRegion* _next_in_special_set; | |
250 | |
251 // next region in the young "generation" region set | |
252 HeapRegion* _next_young_region; | |
253 | |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
254 // Next region whose cards need cleaning |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
255 HeapRegion* _next_dirty_cards_region; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
256 |
342 | 257 // For parallel heapRegion traversal. |
258 jint _claimed; | |
259 | |
260 // We use concurrent marking to determine the amount of live data | |
261 // in each heap region. | |
262 size_t _prev_marked_bytes; // Bytes known to be live via last completed marking. | |
263 size_t _next_marked_bytes; // Bytes known to be live via in-progress marking. | |
264 | |
265 // See "sort_index" method. -1 means is not in the array. | |
266 int _sort_index; | |
267 | |
268 // <PREDICTION> | |
269 double _gc_efficiency; | |
270 // </PREDICTION> | |
271 | |
272 enum YoungType { | |
273 NotYoung, // a region is not young | |
274 Young, // a region is young | |
275 Survivor // a region is young and it contains | |
276 // survivor | |
277 }; | |
278 | |
1666
5cbac8938c4c
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
1552
diff
changeset
|
279 volatile YoungType _young_type; |
342 | 280 int _young_index_in_cset; |
281 SurvRateGroup* _surv_rate_group; | |
282 int _age_index; | |
283 | |
284 // The start of the unmarked area. The unmarked area extends from this | |
285 // word until the top and/or end of the region, and is the part | |
286 // of the region for which no marking was done, i.e. objects may | |
287 // have been allocated in this part since the last mark phase. | |
288 // "prev" is the top at the start of the last completed marking. | |
289 // "next" is the top at the start of the in-progress marking (if any.) | |
290 HeapWord* _prev_top_at_mark_start; | |
291 HeapWord* _next_top_at_mark_start; | |
292 // If a collection pause is in progress, this is the top at the start | |
293 // of that pause. | |
294 | |
295 // We've counted the marked bytes of objects below here. | |
296 HeapWord* _top_at_conc_mark_count; | |
297 | |
298 void init_top_at_mark_start() { | |
299 assert(_prev_marked_bytes == 0 && | |
300 _next_marked_bytes == 0, | |
301 "Must be called after zero_marked_bytes."); | |
302 HeapWord* bot = bottom(); | |
303 _prev_top_at_mark_start = bot; | |
304 _next_top_at_mark_start = bot; | |
305 _top_at_conc_mark_count = bot; | |
306 } | |
307 | |
308 jint _zfs; // A member of ZeroFillState. Protected by ZF_lock. | |
309 Thread* _zero_filler; // If _zfs is ZeroFilling, the thread that (last) | |
310 // made it so. | |
311 | |
312 void set_young_type(YoungType new_type) { | |
313 //assert(_young_type != new_type, "setting the same type" ); | |
314 // TODO: add more assertions here | |
315 _young_type = new_type; | |
316 } | |
317 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
318 // Cached attributes used in the collection set policy information |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
319 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
320 // The RSet length that was added to the total value |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
321 // for the collection set. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
322 size_t _recorded_rs_length; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
323 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
324 // The predicted elapsed time that was added to total value |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
325 // for the collection set. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
326 double _predicted_elapsed_time_ms; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
327 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
328 // The predicted number of bytes to copy that was added to |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
329 // the total value for the collection set. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
330 size_t _predicted_bytes_to_copy; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
331 |
342 | 332 public: |
333 // If "is_zeroed" is "true", the region "mr" can be assumed to contain zeros. | |
334 HeapRegion(G1BlockOffsetSharedArray* sharedOffsetArray, | |
335 MemRegion mr, bool is_zeroed); | |
336 | |
942
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
337 static int LogOfHRGrainBytes; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
338 static int LogOfHRGrainWords; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
339 // The normal type of these should be size_t. However, they used to |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
340 // be members of an enum before and they are assumed by the |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
341 // compilers to be ints. To avoid going and fixing all their uses, |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
342 // I'm declaring them as ints. I'm not anticipating heap region |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
343 // sizes to reach anywhere near 2g, so using an int here is safe. |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
344 static int GrainBytes; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
345 static int GrainWords; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
346 static int CardsPerRegion; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
347 |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
348 // It sets up the heap region size (GrainBytes / GrainWords), as |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
349 // well as other related fields that are based on the heap region |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
350 // size (LogOfHRGrainBytes / LogOfHRGrainWords / |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
351 // CardsPerRegion). All those fields are considered constant |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
352 // throughout the JVM's execution, therefore they should only be set |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
353 // up once during initialization time. |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
811
diff
changeset
|
354 static void setup_heap_region_size(uintx min_heap_size); |
342 | 355 |
355 | 356 enum ClaimValues { |
357 InitialClaimValue = 0, | |
358 FinalCountClaimValue = 1, | |
359 NoteEndClaimValue = 2, | |
390 | 360 ScrubRemSetClaimValue = 3, |
626
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
549
diff
changeset
|
361 ParVerifyClaimValue = 4, |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
549
diff
changeset
|
362 RebuildRSClaimValue = 5 |
355 | 363 }; |
364 | |
342 | 365 // Concurrent refinement requires contiguous heap regions (in which TLABs |
366 // might be allocated) to be zero-filled. Each region therefore has a | |
367 // zero-fill-state. | |
368 enum ZeroFillState { | |
369 NotZeroFilled, | |
370 ZeroFilling, | |
371 ZeroFilled, | |
372 Allocated | |
373 }; | |
374 | |
2134
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
375 inline HeapWord* par_allocate_no_bot_updates(size_t word_size) { |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
376 assert(is_young(), "we can only skip BOT updates on young regions"); |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
377 return ContiguousSpace::par_allocate(word_size); |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
378 } |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
379 inline HeapWord* allocate_no_bot_updates(size_t word_size) { |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
380 assert(is_young(), "we can only skip BOT updates on young regions"); |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
381 return ContiguousSpace::allocate(word_size); |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
382 } |
b158bed62ef5
6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents:
2133
diff
changeset
|
383 |
342 | 384 // If this region is a member of a HeapRegionSeq, the index in that |
385 // sequence, otherwise -1. | |
386 int hrs_index() const { return _hrs_index; } | |
387 void set_hrs_index(int index) { _hrs_index = index; } | |
388 | |
389 // The number of bytes marked live in the region in the last marking phase. | |
390 size_t marked_bytes() { return _prev_marked_bytes; } | |
391 // The number of bytes counted in the next marking. | |
392 size_t next_marked_bytes() { return _next_marked_bytes; } | |
393 // The number of bytes live wrt the next marking. | |
394 size_t next_live_bytes() { | |
395 return (top() - next_top_at_mark_start()) | |
396 * HeapWordSize | |
397 + next_marked_bytes(); | |
398 } | |
399 | |
400 // A lower bound on the amount of garbage bytes in the region. | |
401 size_t garbage_bytes() { | |
402 size_t used_at_mark_start_bytes = | |
403 (prev_top_at_mark_start() - bottom()) * HeapWordSize; | |
404 assert(used_at_mark_start_bytes >= marked_bytes(), | |
405 "Can't mark more than we have."); | |
406 return used_at_mark_start_bytes - marked_bytes(); | |
407 } | |
408 | |
409 // An upper bound on the number of live bytes in the region. | |
410 size_t max_live_bytes() { return used() - garbage_bytes(); } | |
411 | |
412 void add_to_marked_bytes(size_t incr_bytes) { | |
413 _next_marked_bytes = _next_marked_bytes + incr_bytes; | |
414 guarantee( _next_marked_bytes <= used(), "invariant" ); | |
415 } | |
416 | |
417 void zero_marked_bytes() { | |
418 _prev_marked_bytes = _next_marked_bytes = 0; | |
419 } | |
420 | |
355 | 421 bool isHumongous() const { return _humongous_type != NotHumongous; } |
422 bool startsHumongous() const { return _humongous_type == StartsHumongous; } | |
423 bool continuesHumongous() const { return _humongous_type == ContinuesHumongous; } | |
342 | 424 // For a humongous region, region in which it starts. |
425 HeapRegion* humongous_start_region() const { | |
426 return _humongous_start_region; | |
427 } | |
428 | |
2133
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
429 // Makes the current region be a "starts humongous" region, i.e., |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
430 // the first region in a series of one or more contiguous regions |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
431 // that will contain a single "humongous" object. The two parameters |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
432 // are as follows: |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
433 // |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
434 // new_top : The new value of the top field of this region which |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
435 // points to the end of the humongous object that's being |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
436 // allocated. If there is more than one region in the series, top |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
437 // will lie beyond this region's original end field and on the last |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
438 // region in the series. |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
439 // |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
440 // new_end : The new value of the end field of this region which |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
441 // points to the end of the last region in the series. If there is |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
442 // one region in the series (namely: this one) end will be the same |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
443 // as the original end of this region. |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
444 // |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
445 // Updating top and end as described above makes this region look as |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
446 // if it spans the entire space taken up by all the regions in the |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
447 // series and an single allocation moved its top to new_top. This |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
448 // ensures that the space (capacity / allocated) taken up by all |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
449 // humongous regions can be calculated by just looking at the |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
450 // "starts humongous" regions and by ignoring the "continues |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
451 // humongous" regions. |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
452 void set_startsHumongous(HeapWord* new_top, HeapWord* new_end); |
342 | 453 |
2133
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
454 // Makes the current region be a "continues humongous' |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
455 // region. first_hr is the "start humongous" region of the series |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
456 // which this region will be part of. |
2250ee17e258
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
1972
diff
changeset
|
457 void set_continuesHumongous(HeapRegion* first_hr); |
342 | 458 |
459 // If the region has a remembered set, return a pointer to it. | |
460 HeapRegionRemSet* rem_set() const { | |
461 return _rem_set; | |
462 } | |
463 | |
464 // True iff the region is in current collection_set. | |
465 bool in_collection_set() const { | |
466 return _in_collection_set; | |
467 } | |
468 void set_in_collection_set(bool b) { | |
469 _in_collection_set = b; | |
470 } | |
471 HeapRegion* next_in_collection_set() { | |
472 assert(in_collection_set(), "should only invoke on member of CS."); | |
473 assert(_next_in_special_set == NULL || | |
474 _next_in_special_set->in_collection_set(), | |
475 "Malformed CS."); | |
476 return _next_in_special_set; | |
477 } | |
478 void set_next_in_collection_set(HeapRegion* r) { | |
479 assert(in_collection_set(), "should only invoke on member of CS."); | |
480 assert(r == NULL || r->in_collection_set(), "Malformed CS."); | |
481 _next_in_special_set = r; | |
482 } | |
483 | |
484 // True iff it is or has been an allocation region in the current | |
485 // collection pause. | |
486 bool is_gc_alloc_region() const { | |
487 return _is_gc_alloc_region; | |
488 } | |
489 void set_is_gc_alloc_region(bool b) { | |
490 _is_gc_alloc_region = b; | |
491 } | |
492 HeapRegion* next_gc_alloc_region() { | |
493 assert(is_gc_alloc_region(), "should only invoke on member of CS."); | |
494 assert(_next_in_special_set == NULL || | |
495 _next_in_special_set->is_gc_alloc_region(), | |
496 "Malformed CS."); | |
497 return _next_in_special_set; | |
498 } | |
499 void set_next_gc_alloc_region(HeapRegion* r) { | |
500 assert(is_gc_alloc_region(), "should only invoke on member of CS."); | |
501 assert(r == NULL || r->is_gc_alloc_region(), "Malformed CS."); | |
502 _next_in_special_set = r; | |
503 } | |
504 | |
505 bool is_on_free_list() { | |
506 return _is_on_free_list; | |
507 } | |
508 | |
509 void set_on_free_list(bool b) { | |
510 _is_on_free_list = b; | |
511 } | |
512 | |
513 HeapRegion* next_from_free_list() { | |
514 assert(is_on_free_list(), | |
515 "Should only invoke on free space."); | |
516 assert(_next_in_special_set == NULL || | |
517 _next_in_special_set->is_on_free_list(), | |
518 "Malformed Free List."); | |
519 return _next_in_special_set; | |
520 } | |
521 | |
522 void set_next_on_free_list(HeapRegion* r) { | |
523 assert(r == NULL || r->is_on_free_list(), "Malformed free list."); | |
524 _next_in_special_set = r; | |
525 } | |
526 | |
527 bool is_on_unclean_list() { | |
528 return _is_on_unclean_list; | |
529 } | |
530 | |
531 void set_on_unclean_list(bool b); | |
532 | |
533 HeapRegion* next_from_unclean_list() { | |
534 assert(is_on_unclean_list(), | |
535 "Should only invoke on unclean space."); | |
536 assert(_next_in_special_set == NULL || | |
537 _next_in_special_set->is_on_unclean_list(), | |
538 "Malformed unclean List."); | |
539 return _next_in_special_set; | |
540 } | |
541 | |
542 void set_next_on_unclean_list(HeapRegion* r); | |
543 | |
544 HeapRegion* get_next_young_region() { return _next_young_region; } | |
545 void set_next_young_region(HeapRegion* hr) { | |
546 _next_young_region = hr; | |
547 } | |
548 | |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
549 HeapRegion* get_next_dirty_cards_region() const { return _next_dirty_cards_region; } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
550 HeapRegion** next_dirty_cards_region_addr() { return &_next_dirty_cards_region; } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
551 void set_next_dirty_cards_region(HeapRegion* hr) { _next_dirty_cards_region = hr; } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
552 bool is_on_dirty_cards_region_list() const { return get_next_dirty_cards_region() != NULL; } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
677
diff
changeset
|
553 |
342 | 554 // Allows logical separation between objects allocated before and after. |
555 void save_marks(); | |
556 | |
557 // Reset HR stuff to default values. | |
558 void hr_clear(bool par, bool clear_space); | |
559 | |
356 | 560 void initialize(MemRegion mr, bool clear_space, bool mangle_space); |
342 | 561 |
562 // Ensure that "this" is zero-filled. | |
563 void ensure_zero_filled(); | |
564 // This one requires that the calling thread holds ZF_mon. | |
565 void ensure_zero_filled_locked(); | |
566 | |
567 // Get the start of the unmarked area in this region. | |
568 HeapWord* prev_top_at_mark_start() const { return _prev_top_at_mark_start; } | |
569 HeapWord* next_top_at_mark_start() const { return _next_top_at_mark_start; } | |
570 | |
571 // Apply "cl->do_oop" to (the addresses of) all reference fields in objects | |
572 // allocated in the current region before the last call to "save_mark". | |
573 void oop_before_save_marks_iterate(OopClosure* cl); | |
574 | |
575 // This call determines the "filter kind" argument that will be used for | |
576 // the next call to "new_dcto_cl" on this region with the "traditional" | |
577 // signature (i.e., the call below.) The default, in the absence of a | |
578 // preceding call to this method, is "NoFilterKind", and a call to this | |
579 // method is necessary for each such call, or else it reverts to the | |
580 // default. | |
581 // (This is really ugly, but all other methods I could think of changed a | |
582 // lot of main-line code for G1.) | |
583 void set_next_filter_kind(HeapRegionDCTOC::FilterKind nfk) { | |
584 _next_fk = nfk; | |
585 } | |
586 | |
587 DirtyCardToOopClosure* | |
588 new_dcto_closure(OopClosure* cl, | |
589 CardTableModRefBS::PrecisionStyle precision, | |
590 HeapRegionDCTOC::FilterKind fk); | |
591 | |
592 #if WHASSUP | |
593 DirtyCardToOopClosure* | |
594 new_dcto_closure(OopClosure* cl, | |
595 CardTableModRefBS::PrecisionStyle precision, | |
596 HeapWord* boundary) { | |
597 assert(boundary == NULL, "This arg doesn't make sense here."); | |
598 DirtyCardToOopClosure* res = new_dcto_closure(cl, precision, _next_fk); | |
599 _next_fk = HeapRegionDCTOC::NoFilterKind; | |
600 return res; | |
601 } | |
602 #endif | |
603 | |
604 // | |
605 // Note the start or end of marking. This tells the heap region | |
606 // that the collector is about to start or has finished (concurrently) | |
607 // marking the heap. | |
608 // | |
609 | |
610 // Note the start of a marking phase. Record the | |
611 // start of the unmarked area of the region here. | |
612 void note_start_of_marking(bool during_initial_mark) { | |
613 init_top_at_conc_mark_count(); | |
614 _next_marked_bytes = 0; | |
615 if (during_initial_mark && is_young() && !is_survivor()) | |
616 _next_top_at_mark_start = bottom(); | |
617 else | |
618 _next_top_at_mark_start = top(); | |
619 } | |
620 | |
621 // Note the end of a marking phase. Install the start of | |
622 // the unmarked area that was captured at start of marking. | |
623 void note_end_of_marking() { | |
624 _prev_top_at_mark_start = _next_top_at_mark_start; | |
625 _prev_marked_bytes = _next_marked_bytes; | |
626 _next_marked_bytes = 0; | |
627 | |
628 guarantee(_prev_marked_bytes <= | |
629 (size_t) (prev_top_at_mark_start() - bottom()) * HeapWordSize, | |
630 "invariant"); | |
631 } | |
632 | |
633 // After an evacuation, we need to update _next_top_at_mark_start | |
634 // to be the current top. Note this is only valid if we have only | |
635 // ever evacuated into this region. If we evacuate, allocate, and | |
636 // then evacuate we are in deep doodoo. | |
637 void note_end_of_copying() { | |
1021
1f19207eefc2
6847956: G1: crash in oopDesc*G1ParCopyHelper::copy_to_survivor_space(oopDesc*)
tonyp
parents:
1020
diff
changeset
|
638 assert(top() >= _next_top_at_mark_start, "Increase only"); |
1f19207eefc2
6847956: G1: crash in oopDesc*G1ParCopyHelper::copy_to_survivor_space(oopDesc*)
tonyp
parents:
1020
diff
changeset
|
639 _next_top_at_mark_start = top(); |
342 | 640 } |
641 | |
642 // Returns "false" iff no object in the region was allocated when the | |
643 // last mark phase ended. | |
644 bool is_marked() { return _prev_top_at_mark_start != bottom(); } | |
645 | |
646 // If "is_marked()" is true, then this is the index of the region in | |
647 // an array constructed at the end of marking of the regions in a | |
648 // "desirability" order. | |
649 int sort_index() { | |
650 return _sort_index; | |
651 } | |
652 void set_sort_index(int i) { | |
653 _sort_index = i; | |
654 } | |
655 | |
656 void init_top_at_conc_mark_count() { | |
657 _top_at_conc_mark_count = bottom(); | |
658 } | |
659 | |
660 void set_top_at_conc_mark_count(HeapWord *cur) { | |
661 assert(bottom() <= cur && cur <= end(), "Sanity."); | |
662 _top_at_conc_mark_count = cur; | |
663 } | |
664 | |
665 HeapWord* top_at_conc_mark_count() { | |
666 return _top_at_conc_mark_count; | |
667 } | |
668 | |
669 void reset_during_compaction() { | |
670 guarantee( isHumongous() && startsHumongous(), | |
671 "should only be called for humongous regions"); | |
672 | |
673 zero_marked_bytes(); | |
674 init_top_at_mark_start(); | |
675 } | |
676 | |
677 // <PREDICTION> | |
678 void calc_gc_efficiency(void); | |
679 double gc_efficiency() { return _gc_efficiency;} | |
680 // </PREDICTION> | |
681 | |
682 bool is_young() const { return _young_type != NotYoung; } | |
683 bool is_survivor() const { return _young_type == Survivor; } | |
684 | |
685 int young_index_in_cset() const { return _young_index_in_cset; } | |
686 void set_young_index_in_cset(int index) { | |
687 assert( (index == -1) || is_young(), "pre-condition" ); | |
688 _young_index_in_cset = index; | |
689 } | |
690 | |
691 int age_in_surv_rate_group() { | |
692 assert( _surv_rate_group != NULL, "pre-condition" ); | |
693 assert( _age_index > -1, "pre-condition" ); | |
694 return _surv_rate_group->age_in_group(_age_index); | |
695 } | |
696 | |
697 void record_surv_words_in_group(size_t words_survived) { | |
698 assert( _surv_rate_group != NULL, "pre-condition" ); | |
699 assert( _age_index > -1, "pre-condition" ); | |
700 int age_in_group = age_in_surv_rate_group(); | |
701 _surv_rate_group->record_surviving_words(age_in_group, words_survived); | |
702 } | |
703 | |
704 int age_in_surv_rate_group_cond() { | |
705 if (_surv_rate_group != NULL) | |
706 return age_in_surv_rate_group(); | |
707 else | |
708 return -1; | |
709 } | |
710 | |
711 SurvRateGroup* surv_rate_group() { | |
712 return _surv_rate_group; | |
713 } | |
714 | |
715 void install_surv_rate_group(SurvRateGroup* surv_rate_group) { | |
716 assert( surv_rate_group != NULL, "pre-condition" ); | |
717 assert( _surv_rate_group == NULL, "pre-condition" ); | |
718 assert( is_young(), "pre-condition" ); | |
719 | |
720 _surv_rate_group = surv_rate_group; | |
721 _age_index = surv_rate_group->next_age_index(); | |
722 } | |
723 | |
724 void uninstall_surv_rate_group() { | |
725 if (_surv_rate_group != NULL) { | |
726 assert( _age_index > -1, "pre-condition" ); | |
727 assert( is_young(), "pre-condition" ); | |
728 | |
729 _surv_rate_group = NULL; | |
730 _age_index = -1; | |
731 } else { | |
732 assert( _age_index == -1, "pre-condition" ); | |
733 } | |
734 } | |
735 | |
736 void set_young() { set_young_type(Young); } | |
737 | |
738 void set_survivor() { set_young_type(Survivor); } | |
739 | |
740 void set_not_young() { set_young_type(NotYoung); } | |
741 | |
742 // Determine if an object has been allocated since the last | |
743 // mark performed by the collector. This returns true iff the object | |
744 // is within the unmarked area of the region. | |
745 bool obj_allocated_since_prev_marking(oop obj) const { | |
746 return (HeapWord *) obj >= prev_top_at_mark_start(); | |
747 } | |
748 bool obj_allocated_since_next_marking(oop obj) const { | |
749 return (HeapWord *) obj >= next_top_at_mark_start(); | |
750 } | |
751 | |
752 // For parallel heapRegion traversal. | |
753 bool claimHeapRegion(int claimValue); | |
754 jint claim_value() { return _claimed; } | |
755 // Use this carefully: only when you're sure no one is claiming... | |
756 void set_claim_value(int claimValue) { _claimed = claimValue; } | |
757 | |
758 // Returns the "evacuation_failed" property of the region. | |
759 bool evacuation_failed() { return _evacuation_failed; } | |
760 | |
761 // Sets the "evacuation_failed" property of the region. | |
762 void set_evacuation_failed(bool b) { | |
763 _evacuation_failed = b; | |
764 | |
765 if (b) { | |
766 init_top_at_conc_mark_count(); | |
767 _next_marked_bytes = 0; | |
768 } | |
769 } | |
770 | |
771 // Requires that "mr" be entirely within the region. | |
772 // Apply "cl->do_object" to all objects that intersect with "mr". | |
773 // If the iteration encounters an unparseable portion of the region, | |
774 // or if "cl->abort()" is true after a closure application, | |
775 // terminate the iteration and return the address of the start of the | |
776 // subregion that isn't done. (The two can be distinguished by querying | |
777 // "cl->abort()".) Return of "NULL" indicates that the iteration | |
778 // completed. | |
779 HeapWord* | |
780 object_iterate_mem_careful(MemRegion mr, ObjectClosure* cl); | |
781 | |
1666
5cbac8938c4c
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
1552
diff
changeset
|
782 // In this version - if filter_young is true and the region |
5cbac8938c4c
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
1552
diff
changeset
|
783 // is a young region then we skip the iteration. |
342 | 784 HeapWord* |
785 oops_on_card_seq_iterate_careful(MemRegion mr, | |
1666
5cbac8938c4c
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
1552
diff
changeset
|
786 FilterOutOfRegionClosure* cl, |
5cbac8938c4c
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
1552
diff
changeset
|
787 bool filter_young); |
342 | 788 |
789 // A version of block start that is guaranteed to find *some* block | |
790 // boundary at or before "p", but does not object iteration, and may | |
791 // therefore be used safely when the heap is unparseable. | |
792 HeapWord* block_start_careful(const void* p) const { | |
793 return _offsets.block_start_careful(p); | |
794 } | |
795 | |
796 // Requires that "addr" is within the region. Returns the start of the | |
797 // first ("careful") block that starts at or after "addr", or else the | |
798 // "end" of the region if there is no such block. | |
799 HeapWord* next_block_start_careful(HeapWord* addr); | |
800 | |
801 // Returns the zero-fill-state of the current region. | |
802 ZeroFillState zero_fill_state() { return (ZeroFillState)_zfs; } | |
803 bool zero_fill_is_allocated() { return _zfs == Allocated; } | |
804 Thread* zero_filler() { return _zero_filler; } | |
805 | |
806 // Indicate that the contents of the region are unknown, and therefore | |
807 // might require zero-filling. | |
808 void set_zero_fill_needed() { | |
809 set_zero_fill_state_work(NotZeroFilled); | |
810 } | |
811 void set_zero_fill_in_progress(Thread* t) { | |
812 set_zero_fill_state_work(ZeroFilling); | |
813 _zero_filler = t; | |
814 } | |
815 void set_zero_fill_complete(); | |
816 void set_zero_fill_allocated() { | |
817 set_zero_fill_state_work(Allocated); | |
818 } | |
819 | |
820 void set_zero_fill_state_work(ZeroFillState zfs); | |
821 | |
822 // This is called when a full collection shrinks the heap. | |
823 // We want to set the heap region to a value which says | |
824 // it is no longer part of the heap. For now, we'll let "NotZF" fill | |
825 // that role. | |
826 void reset_zero_fill() { | |
827 set_zero_fill_state_work(NotZeroFilled); | |
828 _zero_filler = NULL; | |
829 } | |
830 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
831 size_t recorded_rs_length() const { return _recorded_rs_length; } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
832 double predicted_elapsed_time_ms() const { return _predicted_elapsed_time_ms; } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
833 size_t predicted_bytes_to_copy() const { return _predicted_bytes_to_copy; } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
834 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
835 void set_recorded_rs_length(size_t rs_length) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
836 _recorded_rs_length = rs_length; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
837 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
838 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
839 void set_predicted_elapsed_time_ms(double ms) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
840 _predicted_elapsed_time_ms = ms; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
841 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
842 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
843 void set_predicted_bytes_to_copy(size_t bytes) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
844 _predicted_bytes_to_copy = bytes; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
845 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1021
diff
changeset
|
846 |
342 | 847 #define HeapRegion_OOP_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \ |
848 virtual void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl); | |
849 SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(HeapRegion_OOP_SINCE_SAVE_MARKS_DECL) | |
850 | |
851 CompactibleSpace* next_compaction_space() const; | |
852 | |
853 virtual void reset_after_compaction(); | |
854 | |
855 void print() const; | |
856 void print_on(outputStream* st) const; | |
857 | |
811 | 858 // use_prev_marking == true -> use "prev" marking information, |
859 // use_prev_marking == false -> use "next" marking information | |
860 // NOTE: Only the "prev" marking information is guaranteed to be | |
861 // consistent most of the time, so most calls to this should use | |
862 // use_prev_marking == true. Currently, there is only one case where | |
863 // this is called with use_prev_marking == false, which is to verify | |
864 // the "next" marking information at the end of remark. | |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
942
diff
changeset
|
865 void verify(bool allow_dirty, bool use_prev_marking, bool *failures) const; |
811 | 866 |
867 // Override; it uses the "prev" marking information | |
342 | 868 virtual void verify(bool allow_dirty) const; |
869 | |
870 #ifdef DEBUG | |
871 HeapWord* allocate(size_t size); | |
872 #endif | |
873 }; | |
874 | |
875 // HeapRegionClosure is used for iterating over regions. | |
876 // Terminates the iteration when the "doHeapRegion" method returns "true". | |
877 class HeapRegionClosure : public StackObj { | |
878 friend class HeapRegionSeq; | |
879 friend class G1CollectedHeap; | |
880 | |
881 bool _complete; | |
882 void incomplete() { _complete = false; } | |
883 | |
884 public: | |
885 HeapRegionClosure(): _complete(true) {} | |
886 | |
887 // Typically called on each region until it returns true. | |
888 virtual bool doHeapRegion(HeapRegion* r) = 0; | |
889 | |
890 // True after iteration if the closure was applied to all heap regions | |
891 // and returned "false" in all cases. | |
892 bool complete() { return _complete; } | |
893 }; | |
894 | |
895 // A linked lists of heap regions. It leaves the "next" field | |
896 // unspecified; that's up to subtypes. | |
549
fe3d7c11b4b7
6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents:
545
diff
changeset
|
897 class RegionList VALUE_OBJ_CLASS_SPEC { |
342 | 898 protected: |
899 virtual HeapRegion* get_next(HeapRegion* chr) = 0; | |
900 virtual void set_next(HeapRegion* chr, | |
901 HeapRegion* new_next) = 0; | |
902 | |
903 HeapRegion* _hd; | |
904 HeapRegion* _tl; | |
905 size_t _sz; | |
906 | |
907 // Protected constructor because this type is only meaningful | |
908 // when the _get/_set next functions are defined. | |
909 RegionList() : _hd(NULL), _tl(NULL), _sz(0) {} | |
910 public: | |
911 void reset() { | |
912 _hd = NULL; | |
913 _tl = NULL; | |
914 _sz = 0; | |
915 } | |
916 HeapRegion* hd() { return _hd; } | |
917 HeapRegion* tl() { return _tl; } | |
918 size_t sz() { return _sz; } | |
919 size_t length(); | |
920 | |
921 bool well_formed() { | |
922 return | |
923 ((hd() == NULL && tl() == NULL && sz() == 0) | |
924 || (hd() != NULL && tl() != NULL && sz() > 0)) | |
925 && (sz() == length()); | |
926 } | |
927 virtual void insert_before_head(HeapRegion* r); | |
928 void prepend_list(RegionList* new_list); | |
929 virtual HeapRegion* pop(); | |
930 void dec_sz() { _sz--; } | |
931 // Requires that "r" is an element of the list, and is not the tail. | |
932 void delete_after(HeapRegion* r); | |
933 }; | |
934 | |
935 class EmptyNonHRegionList: public RegionList { | |
936 protected: | |
937 // Protected constructor because this type is only meaningful | |
938 // when the _get/_set next functions are defined. | |
939 EmptyNonHRegionList() : RegionList() {} | |
940 | |
941 public: | |
942 void insert_before_head(HeapRegion* r) { | |
943 // assert(r->is_empty(), "Better be empty"); | |
944 assert(!r->isHumongous(), "Better not be humongous."); | |
945 RegionList::insert_before_head(r); | |
946 } | |
947 void prepend_list(EmptyNonHRegionList* new_list) { | |
948 // assert(new_list->hd() == NULL || new_list->hd()->is_empty(), | |
949 // "Better be empty"); | |
950 assert(new_list->hd() == NULL || !new_list->hd()->isHumongous(), | |
951 "Better not be humongous."); | |
952 // assert(new_list->tl() == NULL || new_list->tl()->is_empty(), | |
953 // "Better be empty"); | |
954 assert(new_list->tl() == NULL || !new_list->tl()->isHumongous(), | |
955 "Better not be humongous."); | |
956 RegionList::prepend_list(new_list); | |
957 } | |
958 }; | |
959 | |
960 class UncleanRegionList: public EmptyNonHRegionList { | |
961 public: | |
962 HeapRegion* get_next(HeapRegion* hr) { | |
963 return hr->next_from_unclean_list(); | |
964 } | |
965 void set_next(HeapRegion* hr, HeapRegion* new_next) { | |
966 hr->set_next_on_unclean_list(new_next); | |
967 } | |
968 | |
969 UncleanRegionList() : EmptyNonHRegionList() {} | |
970 | |
971 void insert_before_head(HeapRegion* r) { | |
972 assert(!r->is_on_free_list(), | |
973 "Better not already be on free list"); | |
974 assert(!r->is_on_unclean_list(), | |
975 "Better not already be on unclean list"); | |
976 r->set_zero_fill_needed(); | |
977 r->set_on_unclean_list(true); | |
978 EmptyNonHRegionList::insert_before_head(r); | |
979 } | |
980 void prepend_list(UncleanRegionList* new_list) { | |
981 assert(new_list->tl() == NULL || !new_list->tl()->is_on_free_list(), | |
982 "Better not already be on free list"); | |
983 assert(new_list->tl() == NULL || new_list->tl()->is_on_unclean_list(), | |
984 "Better already be marked as on unclean list"); | |
985 assert(new_list->hd() == NULL || !new_list->hd()->is_on_free_list(), | |
986 "Better not already be on free list"); | |
987 assert(new_list->hd() == NULL || new_list->hd()->is_on_unclean_list(), | |
988 "Better already be marked as on unclean list"); | |
989 EmptyNonHRegionList::prepend_list(new_list); | |
990 } | |
991 HeapRegion* pop() { | |
992 HeapRegion* res = RegionList::pop(); | |
993 if (res != NULL) res->set_on_unclean_list(false); | |
994 return res; | |
995 } | |
996 }; | |
997 | |
998 // Local Variables: *** | |
999 // c-indentation-style: gnu *** | |
1000 // End: *** | |
1001 | |
1002 #endif // SERIALGC | |
1972 | 1003 |
1004 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP |