Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 517:e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
Summary: Added safe_object_iterate() for use by JMapPerm.
Reviewed-by: tonyp
author | jmasa |
---|---|
date | Tue, 06 Jan 2009 07:05:05 -0800 |
parents | cc68c8e9b309 |
children | 65de26b5ea82 |
rev | line source |
---|---|
342 | 1 /* |
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. | |
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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot. | |
26 // It uses the "Garbage First" heap organization and algorithm, which | |
27 // may combine concurrent marking with parallel, incremental compaction of | |
28 // heap subsets that will yield large amounts of garbage. | |
29 | |
30 class HeapRegion; | |
31 class HeapRegionSeq; | |
32 class HeapRegionList; | |
33 class PermanentGenerationSpec; | |
34 class GenerationSpec; | |
35 class OopsInHeapRegionClosure; | |
36 class G1ScanHeapEvacClosure; | |
37 class ObjectClosure; | |
38 class SpaceClosure; | |
39 class CompactibleSpaceClosure; | |
40 class Space; | |
41 class G1CollectorPolicy; | |
42 class GenRemSet; | |
43 class G1RemSet; | |
44 class HeapRegionRemSetIterator; | |
45 class ConcurrentMark; | |
46 class ConcurrentMarkThread; | |
47 class ConcurrentG1Refine; | |
48 class ConcurrentZFThread; | |
49 | |
50 // If want to accumulate detailed statistics on work queues | |
51 // turn this on. | |
52 #define G1_DETAILED_STATS 0 | |
53 | |
54 #if G1_DETAILED_STATS | |
55 # define IF_G1_DETAILED_STATS(code) code | |
56 #else | |
57 # define IF_G1_DETAILED_STATS(code) | |
58 #endif | |
59 | |
60 typedef GenericTaskQueue<oop*> RefToScanQueue; | |
61 typedef GenericTaskQueueSet<oop*> RefToScanQueueSet; | |
62 | |
63 enum G1GCThreadGroups { | |
64 G1CRGroup = 0, | |
65 G1ZFGroup = 1, | |
66 G1CMGroup = 2, | |
67 G1CLGroup = 3 | |
68 }; | |
69 | |
70 enum GCAllocPurpose { | |
71 GCAllocForTenured, | |
72 GCAllocForSurvived, | |
73 GCAllocPurposeCount | |
74 }; | |
75 | |
76 class YoungList : public CHeapObj { | |
77 private: | |
78 G1CollectedHeap* _g1h; | |
79 | |
80 HeapRegion* _head; | |
81 | |
82 HeapRegion* _scan_only_head; | |
83 HeapRegion* _scan_only_tail; | |
84 size_t _length; | |
85 size_t _scan_only_length; | |
86 | |
87 size_t _last_sampled_rs_lengths; | |
88 size_t _sampled_rs_lengths; | |
89 HeapRegion* _curr; | |
90 HeapRegion* _curr_scan_only; | |
91 | |
92 HeapRegion* _survivor_head; | |
93 HeapRegion* _survivors_tail; | |
94 size_t _survivor_length; | |
95 | |
96 void empty_list(HeapRegion* list); | |
97 | |
98 public: | |
99 YoungList(G1CollectedHeap* g1h); | |
100 | |
101 void push_region(HeapRegion* hr); | |
102 void add_survivor_region(HeapRegion* hr); | |
103 HeapRegion* pop_region(); | |
104 void empty_list(); | |
105 bool is_empty() { return _length == 0; } | |
106 size_t length() { return _length; } | |
107 size_t scan_only_length() { return _scan_only_length; } | |
108 | |
109 void rs_length_sampling_init(); | |
110 bool rs_length_sampling_more(); | |
111 void rs_length_sampling_next(); | |
112 | |
113 void reset_sampled_info() { | |
114 _last_sampled_rs_lengths = 0; | |
115 } | |
116 size_t sampled_rs_lengths() { return _last_sampled_rs_lengths; } | |
117 | |
118 // for development purposes | |
119 void reset_auxilary_lists(); | |
120 HeapRegion* first_region() { return _head; } | |
121 HeapRegion* first_scan_only_region() { return _scan_only_head; } | |
122 HeapRegion* first_survivor_region() { return _survivor_head; } | |
123 HeapRegion* par_get_next_scan_only_region() { | |
124 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); | |
125 HeapRegion* ret = _curr_scan_only; | |
126 if (ret != NULL) | |
127 _curr_scan_only = ret->get_next_young_region(); | |
128 return ret; | |
129 } | |
130 | |
131 // debugging | |
132 bool check_list_well_formed(); | |
133 bool check_list_empty(bool ignore_scan_only_list, | |
134 bool check_sample = true); | |
135 void print(); | |
136 }; | |
137 | |
138 class RefineCardTableEntryClosure; | |
139 class G1CollectedHeap : public SharedHeap { | |
140 friend class VM_G1CollectForAllocation; | |
141 friend class VM_GenCollectForPermanentAllocation; | |
142 friend class VM_G1CollectFull; | |
143 friend class VM_G1IncCollectionPause; | |
144 friend class VM_G1PopRegionCollectionPause; | |
145 friend class VMStructs; | |
146 | |
147 // Closures used in implementation. | |
148 friend class G1ParCopyHelper; | |
149 friend class G1IsAliveClosure; | |
150 friend class G1EvacuateFollowersClosure; | |
151 friend class G1ParScanThreadState; | |
152 friend class G1ParScanClosureSuper; | |
153 friend class G1ParEvacuateFollowersClosure; | |
154 friend class G1ParTask; | |
155 friend class G1FreeGarbageRegionClosure; | |
156 friend class RefineCardTableEntryClosure; | |
157 friend class G1PrepareCompactClosure; | |
158 friend class RegionSorter; | |
159 friend class CountRCClosure; | |
160 friend class EvacPopObjClosure; | |
161 | |
162 // Other related classes. | |
163 friend class G1MarkSweep; | |
164 | |
165 private: | |
166 enum SomePrivateConstants { | |
167 VeryLargeInBytes = HeapRegion::GrainBytes/2, | |
168 VeryLargeInWords = VeryLargeInBytes/HeapWordSize, | |
169 MinHeapDeltaBytes = 10 * HeapRegion::GrainBytes, // FIXME | |
170 NumAPIs = HeapRegion::MaxAge | |
171 }; | |
172 | |
173 | |
174 // The one and only G1CollectedHeap, so static functions can find it. | |
175 static G1CollectedHeap* _g1h; | |
176 | |
177 // Storage for the G1 heap (excludes the permanent generation). | |
178 VirtualSpace _g1_storage; | |
179 MemRegion _g1_reserved; | |
180 | |
181 // The part of _g1_storage that is currently committed. | |
182 MemRegion _g1_committed; | |
183 | |
184 // The maximum part of _g1_storage that has ever been committed. | |
185 MemRegion _g1_max_committed; | |
186 | |
187 // The number of regions that are completely free. | |
188 size_t _free_regions; | |
189 | |
190 // The number of regions we could create by expansion. | |
191 size_t _expansion_regions; | |
192 | |
193 // Return the number of free regions in the heap (by direct counting.) | |
194 size_t count_free_regions(); | |
195 // Return the number of free regions on the free and unclean lists. | |
196 size_t count_free_regions_list(); | |
197 | |
198 // The block offset table for the G1 heap. | |
199 G1BlockOffsetSharedArray* _bot_shared; | |
200 | |
201 // Move all of the regions off the free lists, then rebuild those free | |
202 // lists, before and after full GC. | |
203 void tear_down_region_lists(); | |
204 void rebuild_region_lists(); | |
205 // This sets all non-empty regions to need zero-fill (which they will if | |
206 // they are empty after full collection.) | |
207 void set_used_regions_to_need_zero_fill(); | |
208 | |
209 // The sequence of all heap regions in the heap. | |
210 HeapRegionSeq* _hrs; | |
211 | |
212 // The region from which normal-sized objects are currently being | |
213 // allocated. May be NULL. | |
214 HeapRegion* _cur_alloc_region; | |
215 | |
216 // Postcondition: cur_alloc_region == NULL. | |
217 void abandon_cur_alloc_region(); | |
218 | |
219 // The to-space memory regions into which objects are being copied during | |
220 // a GC. | |
221 HeapRegion* _gc_alloc_regions[GCAllocPurposeCount]; | |
222 uint _gc_alloc_region_counts[GCAllocPurposeCount]; | |
223 | |
224 // A list of the regions that have been set to be alloc regions in the | |
225 // current collection. | |
226 HeapRegion* _gc_alloc_region_list; | |
227 | |
228 // When called by par thread, require par_alloc_during_gc_lock() to be held. | |
229 void push_gc_alloc_region(HeapRegion* hr); | |
230 | |
231 // This should only be called single-threaded. Undeclares all GC alloc | |
232 // regions. | |
233 void forget_alloc_region_list(); | |
234 | |
235 // Should be used to set an alloc region, because there's other | |
236 // associated bookkeeping. | |
237 void set_gc_alloc_region(int purpose, HeapRegion* r); | |
238 | |
239 // Check well-formedness of alloc region list. | |
240 bool check_gc_alloc_regions(); | |
241 | |
242 // Outside of GC pauses, the number of bytes used in all regions other | |
243 // than the current allocation region. | |
244 size_t _summary_bytes_used; | |
245 | |
246 // Summary information about popular objects; method to print it. | |
247 NumberSeq _pop_obj_rc_at_copy; | |
248 void print_popularity_summary_info() const; | |
249 | |
353
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
250 volatile unsigned _gc_time_stamp; |
342 | 251 |
252 size_t* _surviving_young_words; | |
253 | |
254 void setup_surviving_young_words(); | |
255 void update_surviving_young_words(size_t* surv_young_words); | |
256 void cleanup_surviving_young_words(); | |
257 | |
258 protected: | |
259 | |
260 // Returns "true" iff none of the gc alloc regions have any allocations | |
261 // since the last call to "save_marks". | |
262 bool all_alloc_regions_no_allocs_since_save_marks(); | |
263 // Calls "note_end_of_copying on all gc alloc_regions. | |
264 void all_alloc_regions_note_end_of_copying(); | |
265 | |
266 // The number of regions allocated to hold humongous objects. | |
267 int _num_humongous_regions; | |
268 YoungList* _young_list; | |
269 | |
270 // The current policy object for the collector. | |
271 G1CollectorPolicy* _g1_policy; | |
272 | |
273 // Parallel allocation lock to protect the current allocation region. | |
274 Mutex _par_alloc_during_gc_lock; | |
275 Mutex* par_alloc_during_gc_lock() { return &_par_alloc_during_gc_lock; } | |
276 | |
277 // If possible/desirable, allocate a new HeapRegion for normal object | |
278 // allocation sufficient for an allocation of the given "word_size". | |
279 // If "do_expand" is true, will attempt to expand the heap if necessary | |
280 // to to satisfy the request. If "zero_filled" is true, requires a | |
281 // zero-filled region. | |
282 // (Returning NULL will trigger a GC.) | |
283 virtual HeapRegion* newAllocRegion_work(size_t word_size, | |
284 bool do_expand, | |
285 bool zero_filled); | |
286 | |
287 virtual HeapRegion* newAllocRegion(size_t word_size, | |
288 bool zero_filled = true) { | |
289 return newAllocRegion_work(word_size, false, zero_filled); | |
290 } | |
291 virtual HeapRegion* newAllocRegionWithExpansion(int purpose, | |
292 size_t word_size, | |
293 bool zero_filled = true); | |
294 | |
295 // Attempt to allocate an object of the given (very large) "word_size". | |
296 // Returns "NULL" on failure. | |
297 virtual HeapWord* humongousObjAllocate(size_t word_size); | |
298 | |
299 // If possible, allocate a block of the given word_size, else return "NULL". | |
300 // Returning NULL will trigger GC or heap expansion. | |
301 // These two methods have rather awkward pre- and | |
302 // post-conditions. If they are called outside a safepoint, then | |
303 // they assume that the caller is holding the heap lock. Upon return | |
304 // they release the heap lock, if they are returning a non-NULL | |
305 // value. attempt_allocation_slow() also dirties the cards of a | |
306 // newly-allocated young region after it releases the heap | |
307 // lock. This change in interface was the neatest way to achieve | |
308 // this card dirtying without affecting mem_allocate(), which is a | |
309 // more frequently called method. We tried two or three different | |
310 // approaches, but they were even more hacky. | |
311 HeapWord* attempt_allocation(size_t word_size, | |
312 bool permit_collection_pause = true); | |
313 | |
314 HeapWord* attempt_allocation_slow(size_t word_size, | |
315 bool permit_collection_pause = true); | |
316 | |
317 // Allocate blocks during garbage collection. Will ensure an | |
318 // allocation region, either by picking one or expanding the | |
319 // heap, and then allocate a block of the given size. The block | |
320 // may not be a humongous - it must fit into a single heap region. | |
321 HeapWord* allocate_during_gc(GCAllocPurpose purpose, size_t word_size); | |
322 HeapWord* par_allocate_during_gc(GCAllocPurpose purpose, size_t word_size); | |
323 | |
324 HeapWord* allocate_during_gc_slow(GCAllocPurpose purpose, | |
325 HeapRegion* alloc_region, | |
326 bool par, | |
327 size_t word_size); | |
328 | |
329 // Ensure that no further allocations can happen in "r", bearing in mind | |
330 // that parallel threads might be attempting allocations. | |
331 void par_allocate_remaining_space(HeapRegion* r); | |
332 | |
333 // Helper function for two callbacks below. | |
334 // "full", if true, indicates that the GC is for a System.gc() request, | |
335 // and should collect the entire heap. If "clear_all_soft_refs" is true, | |
336 // all soft references are cleared during the GC. If "full" is false, | |
337 // "word_size" describes the allocation that the GC should | |
338 // attempt (at least) to satisfy. | |
339 void do_collection(bool full, bool clear_all_soft_refs, | |
340 size_t word_size); | |
341 | |
342 // Callback from VM_G1CollectFull operation. | |
343 // Perform a full collection. | |
344 void do_full_collection(bool clear_all_soft_refs); | |
345 | |
346 // Resize the heap if necessary after a full collection. If this is | |
347 // after a collect-for allocation, "word_size" is the allocation size, | |
348 // and will be considered part of the used portion of the heap. | |
349 void resize_if_necessary_after_full_collection(size_t word_size); | |
350 | |
351 // Callback from VM_G1CollectForAllocation operation. | |
352 // This function does everything necessary/possible to satisfy a | |
353 // failed allocation request (including collection, expansion, etc.) | |
354 HeapWord* satisfy_failed_allocation(size_t word_size); | |
355 | |
356 // Attempting to expand the heap sufficiently | |
357 // to support an allocation of the given "word_size". If | |
358 // successful, perform the allocation and return the address of the | |
359 // allocated block, or else "NULL". | |
360 virtual HeapWord* expand_and_allocate(size_t word_size); | |
361 | |
362 public: | |
363 // Expand the garbage-first heap by at least the given size (in bytes!). | |
364 // (Rounds up to a HeapRegion boundary.) | |
365 virtual void expand(size_t expand_bytes); | |
366 | |
367 // Do anything common to GC's. | |
368 virtual void gc_prologue(bool full); | |
369 virtual void gc_epilogue(bool full); | |
370 | |
371 protected: | |
372 | |
373 // Shrink the garbage-first heap by at most the given size (in bytes!). | |
374 // (Rounds down to a HeapRegion boundary.) | |
375 virtual void shrink(size_t expand_bytes); | |
376 void shrink_helper(size_t expand_bytes); | |
377 | |
378 // Do an incremental collection: identify a collection set, and evacuate | |
379 // its live objects elsewhere. | |
380 virtual void do_collection_pause(); | |
381 | |
382 // The guts of the incremental collection pause, executed by the vm | |
383 // thread. If "popular_region" is non-NULL, this pause should evacuate | |
384 // this single region whose remembered set has gotten large, moving | |
385 // any popular objects to one of the popular regions. | |
386 virtual void do_collection_pause_at_safepoint(HeapRegion* popular_region); | |
387 | |
388 // Actually do the work of evacuating the collection set. | |
389 virtual void evacuate_collection_set(); | |
390 | |
391 // If this is an appropriate right time, do a collection pause. | |
392 // The "word_size" argument, if non-zero, indicates the size of an | |
393 // allocation request that is prompting this query. | |
394 void do_collection_pause_if_appropriate(size_t word_size); | |
395 | |
396 // The g1 remembered set of the heap. | |
397 G1RemSet* _g1_rem_set; | |
398 // And it's mod ref barrier set, used to track updates for the above. | |
399 ModRefBarrierSet* _mr_bs; | |
400 | |
401 // The Heap Region Rem Set Iterator. | |
402 HeapRegionRemSetIterator** _rem_set_iterator; | |
403 | |
404 // The closure used to refine a single card. | |
405 RefineCardTableEntryClosure* _refine_cte_cl; | |
406 | |
407 // A function to check the consistency of dirty card logs. | |
408 void check_ct_logs_at_safepoint(); | |
409 | |
410 // After a collection pause, make the regions in the CS into free | |
411 // regions. | |
412 void free_collection_set(HeapRegion* cs_head); | |
413 | |
414 // Applies "scan_non_heap_roots" to roots outside the heap, | |
415 // "scan_rs" to roots inside the heap (having done "set_region" to | |
416 // indicate the region in which the root resides), and does "scan_perm" | |
417 // (setting the generation to the perm generation.) If "scan_rs" is | |
418 // NULL, then this step is skipped. The "worker_i" | |
419 // param is for use with parallel roots processing, and should be | |
420 // the "i" of the calling parallel worker thread's work(i) function. | |
421 // In the sequential case this param will be ignored. | |
422 void g1_process_strong_roots(bool collecting_perm_gen, | |
423 SharedHeap::ScanningOption so, | |
424 OopClosure* scan_non_heap_roots, | |
425 OopsInHeapRegionClosure* scan_rs, | |
426 OopsInHeapRegionClosure* scan_so, | |
427 OopsInGenClosure* scan_perm, | |
428 int worker_i); | |
429 | |
430 void scan_scan_only_set(OopsInHeapRegionClosure* oc, | |
431 int worker_i); | |
432 void scan_scan_only_region(HeapRegion* hr, | |
433 OopsInHeapRegionClosure* oc, | |
434 int worker_i); | |
435 | |
436 // Apply "blk" to all the weak roots of the system. These include | |
437 // JNI weak roots, the code cache, system dictionary, symbol table, | |
438 // string table, and referents of reachable weak refs. | |
439 void g1_process_weak_roots(OopClosure* root_closure, | |
440 OopClosure* non_root_closure); | |
441 | |
442 // Invoke "save_marks" on all heap regions. | |
443 void save_marks(); | |
444 | |
445 // Free a heap region. | |
446 void free_region(HeapRegion* hr); | |
447 // A component of "free_region", exposed for 'batching'. | |
448 // All the params after "hr" are out params: the used bytes of the freed | |
449 // region(s), the number of H regions cleared, the number of regions | |
450 // freed, and pointers to the head and tail of a list of freed contig | |
451 // regions, linked throught the "next_on_unclean_list" field. | |
452 void free_region_work(HeapRegion* hr, | |
453 size_t& pre_used, | |
454 size_t& cleared_h, | |
455 size_t& freed_regions, | |
456 UncleanRegionList* list, | |
457 bool par = false); | |
458 | |
459 | |
460 // The concurrent marker (and the thread it runs in.) | |
461 ConcurrentMark* _cm; | |
462 ConcurrentMarkThread* _cmThread; | |
463 bool _mark_in_progress; | |
464 | |
465 // The concurrent refiner. | |
466 ConcurrentG1Refine* _cg1r; | |
467 | |
468 // The concurrent zero-fill thread. | |
469 ConcurrentZFThread* _czft; | |
470 | |
471 // The parallel task queues | |
472 RefToScanQueueSet *_task_queues; | |
473 | |
474 // True iff a evacuation has failed in the current collection. | |
475 bool _evacuation_failed; | |
476 | |
477 // Set the attribute indicating whether evacuation has failed in the | |
478 // current collection. | |
479 void set_evacuation_failed(bool b) { _evacuation_failed = b; } | |
480 | |
481 // Failed evacuations cause some logical from-space objects to have | |
482 // forwarding pointers to themselves. Reset them. | |
483 void remove_self_forwarding_pointers(); | |
484 | |
485 // When one is non-null, so is the other. Together, they each pair is | |
486 // an object with a preserved mark, and its mark value. | |
487 GrowableArray<oop>* _objs_with_preserved_marks; | |
488 GrowableArray<markOop>* _preserved_marks_of_objs; | |
489 | |
490 // Preserve the mark of "obj", if necessary, in preparation for its mark | |
491 // word being overwritten with a self-forwarding-pointer. | |
492 void preserve_mark_if_necessary(oop obj, markOop m); | |
493 | |
494 // The stack of evac-failure objects left to be scanned. | |
495 GrowableArray<oop>* _evac_failure_scan_stack; | |
496 // The closure to apply to evac-failure objects. | |
497 | |
498 OopsInHeapRegionClosure* _evac_failure_closure; | |
499 // Set the field above. | |
500 void | |
501 set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_closure) { | |
502 _evac_failure_closure = evac_failure_closure; | |
503 } | |
504 | |
505 // Push "obj" on the scan stack. | |
506 void push_on_evac_failure_scan_stack(oop obj); | |
507 // Process scan stack entries until the stack is empty. | |
508 void drain_evac_failure_scan_stack(); | |
509 // True iff an invocation of "drain_scan_stack" is in progress; to | |
510 // prevent unnecessary recursion. | |
511 bool _drain_in_progress; | |
512 | |
513 // Do any necessary initialization for evacuation-failure handling. | |
514 // "cl" is the closure that will be used to process evac-failure | |
515 // objects. | |
516 void init_for_evac_failure(OopsInHeapRegionClosure* cl); | |
517 // Do any necessary cleanup for evacuation-failure handling data | |
518 // structures. | |
519 void finalize_for_evac_failure(); | |
520 | |
521 // An attempt to evacuate "obj" has failed; take necessary steps. | |
522 void handle_evacuation_failure(oop obj); | |
523 oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj); | |
524 void handle_evacuation_failure_common(oop obj, markOop m); | |
525 | |
526 | |
527 // Ensure that the relevant gc_alloc regions are set. | |
528 void get_gc_alloc_regions(); | |
529 // We're done with GC alloc regions; release them, as appropriate. | |
530 void release_gc_alloc_regions(); | |
531 | |
532 // ("Weak") Reference processing support | |
533 ReferenceProcessor* _ref_processor; | |
534 | |
535 enum G1H_process_strong_roots_tasks { | |
536 G1H_PS_mark_stack_oops_do, | |
537 G1H_PS_refProcessor_oops_do, | |
538 // Leave this one last. | |
539 G1H_PS_NumElements | |
540 }; | |
541 | |
542 SubTasksDone* _process_strong_tasks; | |
543 | |
544 // Allocate space to hold a popular object. Result is guaranteed below | |
545 // "popular_object_boundary()". Note: CURRENTLY halts the system if we | |
546 // run out of space to hold popular objects. | |
547 HeapWord* allocate_popular_object(size_t word_size); | |
548 | |
549 // The boundary between popular and non-popular objects. | |
550 HeapWord* _popular_object_boundary; | |
551 | |
552 HeapRegionList* _popular_regions_to_be_evacuated; | |
553 | |
554 // Compute which objects in "single_region" are popular. If any are, | |
555 // evacuate them to a popular region, leaving behind forwarding pointers, | |
556 // and select "popular_region" as the single collection set region. | |
557 // Otherwise, leave the collection set null. | |
558 void popularity_pause_preamble(HeapRegion* populer_region); | |
559 | |
560 // Compute which objects in "single_region" are popular, and evacuate | |
561 // them to a popular region, leaving behind forwarding pointers. | |
562 // Returns "true" if at least one popular object is discovered and | |
563 // evacuated. In any case, "*max_rc" is set to the maximum reference | |
564 // count of an object in the region. | |
565 bool compute_reference_counts_and_evac_popular(HeapRegion* populer_region, | |
566 size_t* max_rc); | |
567 // Subroutines used in the above. | |
568 bool _rc_region_above; | |
569 size_t _rc_region_diff; | |
570 jint* obj_rc_addr(oop obj) { | |
571 uintptr_t obj_addr = (uintptr_t)obj; | |
572 if (_rc_region_above) { | |
573 jint* res = (jint*)(obj_addr + _rc_region_diff); | |
574 assert((uintptr_t)res > obj_addr, "RC region is above."); | |
575 return res; | |
576 } else { | |
577 jint* res = (jint*)(obj_addr - _rc_region_diff); | |
578 assert((uintptr_t)res < obj_addr, "RC region is below."); | |
579 return res; | |
580 } | |
581 } | |
582 jint obj_rc(oop obj) { | |
583 return *obj_rc_addr(obj); | |
584 } | |
585 void inc_obj_rc(oop obj) { | |
586 (*obj_rc_addr(obj))++; | |
587 } | |
588 void atomic_inc_obj_rc(oop obj); | |
589 | |
590 | |
591 // Number of popular objects and bytes (latter is cheaper!). | |
592 size_t pop_object_used_objs(); | |
593 size_t pop_object_used_bytes(); | |
594 | |
595 // Index of the popular region in which allocation is currently being | |
596 // done. | |
597 int _cur_pop_hr_index; | |
598 | |
599 // List of regions which require zero filling. | |
600 UncleanRegionList _unclean_region_list; | |
601 bool _unclean_regions_coming; | |
602 | |
603 bool check_age_cohort_well_formed_work(int a, HeapRegion* hr); | |
604 | |
605 public: | |
606 void set_refine_cte_cl_concurrency(bool concurrent); | |
607 | |
608 RefToScanQueue *task_queue(int i); | |
609 | |
610 // Create a G1CollectedHeap with the specified policy. | |
611 // Must call the initialize method afterwards. | |
612 // May not return if something goes wrong. | |
613 G1CollectedHeap(G1CollectorPolicy* policy); | |
614 | |
615 // Initialize the G1CollectedHeap to have the initial and | |
616 // maximum sizes, permanent generation, and remembered and barrier sets | |
617 // specified by the policy object. | |
618 jint initialize(); | |
619 | |
620 void ref_processing_init(); | |
621 | |
622 void set_par_threads(int t) { | |
623 SharedHeap::set_par_threads(t); | |
624 _process_strong_tasks->set_par_threads(t); | |
625 } | |
626 | |
627 virtual CollectedHeap::Name kind() const { | |
628 return CollectedHeap::G1CollectedHeap; | |
629 } | |
630 | |
631 // The current policy object for the collector. | |
632 G1CollectorPolicy* g1_policy() const { return _g1_policy; } | |
633 | |
634 // Adaptive size policy. No such thing for g1. | |
635 virtual AdaptiveSizePolicy* size_policy() { return NULL; } | |
636 | |
637 // The rem set and barrier set. | |
638 G1RemSet* g1_rem_set() const { return _g1_rem_set; } | |
639 ModRefBarrierSet* mr_bs() const { return _mr_bs; } | |
640 | |
641 // The rem set iterator. | |
642 HeapRegionRemSetIterator* rem_set_iterator(int i) { | |
643 return _rem_set_iterator[i]; | |
644 } | |
645 | |
646 HeapRegionRemSetIterator* rem_set_iterator() { | |
647 return _rem_set_iterator[0]; | |
648 } | |
649 | |
650 unsigned get_gc_time_stamp() { | |
651 return _gc_time_stamp; | |
652 } | |
653 | |
654 void reset_gc_time_stamp() { | |
655 _gc_time_stamp = 0; | |
353
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
656 OrderAccess::fence(); |
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
657 } |
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
658 |
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
659 void increment_gc_time_stamp() { |
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
660 ++_gc_time_stamp; |
9bb2c10ac07b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
342
diff
changeset
|
661 OrderAccess::fence(); |
342 | 662 } |
663 | |
664 void iterate_dirty_card_closure(bool concurrent, int worker_i); | |
665 | |
666 // The shared block offset table array. | |
667 G1BlockOffsetSharedArray* bot_shared() const { return _bot_shared; } | |
668 | |
669 // Reference Processing accessor | |
670 ReferenceProcessor* ref_processor() { return _ref_processor; } | |
671 | |
672 // Reserved (g1 only; super method includes perm), capacity and the used | |
673 // portion in bytes. | |
674 size_t g1_reserved_obj_bytes() { return _g1_reserved.byte_size(); } | |
675 virtual size_t capacity() const; | |
676 virtual size_t used() const; | |
677 size_t recalculate_used() const; | |
678 #ifndef PRODUCT | |
679 size_t recalculate_used_regions() const; | |
680 #endif // PRODUCT | |
681 | |
682 // These virtual functions do the actual allocation. | |
683 virtual HeapWord* mem_allocate(size_t word_size, | |
684 bool is_noref, | |
685 bool is_tlab, | |
686 bool* gc_overhead_limit_was_exceeded); | |
687 | |
688 // Some heaps may offer a contiguous region for shared non-blocking | |
689 // allocation, via inlined code (by exporting the address of the top and | |
690 // end fields defining the extent of the contiguous allocation region.) | |
691 // But G1CollectedHeap doesn't yet support this. | |
692 | |
693 // Return an estimate of the maximum allocation that could be performed | |
694 // without triggering any collection or expansion activity. In a | |
695 // generational collector, for example, this is probably the largest | |
696 // allocation that could be supported (without expansion) in the youngest | |
697 // generation. It is "unsafe" because no locks are taken; the result | |
698 // should be treated as an approximation, not a guarantee, for use in | |
699 // heuristic resizing decisions. | |
700 virtual size_t unsafe_max_alloc(); | |
701 | |
702 virtual bool is_maximal_no_gc() const { | |
703 return _g1_storage.uncommitted_size() == 0; | |
704 } | |
705 | |
706 // The total number of regions in the heap. | |
707 size_t n_regions(); | |
708 | |
709 // The number of regions that are completely free. | |
710 size_t max_regions(); | |
711 | |
712 // The number of regions that are completely free. | |
713 size_t free_regions(); | |
714 | |
715 // The number of regions that are not completely free. | |
716 size_t used_regions() { return n_regions() - free_regions(); } | |
717 | |
718 // True iff the ZF thread should run. | |
719 bool should_zf(); | |
720 | |
721 // The number of regions available for "regular" expansion. | |
722 size_t expansion_regions() { return _expansion_regions; } | |
723 | |
724 #ifndef PRODUCT | |
725 bool regions_accounted_for(); | |
726 bool print_region_accounting_info(); | |
727 void print_region_counts(); | |
728 #endif | |
729 | |
730 HeapRegion* alloc_region_from_unclean_list(bool zero_filled); | |
731 HeapRegion* alloc_region_from_unclean_list_locked(bool zero_filled); | |
732 | |
733 void put_region_on_unclean_list(HeapRegion* r); | |
734 void put_region_on_unclean_list_locked(HeapRegion* r); | |
735 | |
736 void prepend_region_list_on_unclean_list(UncleanRegionList* list); | |
737 void prepend_region_list_on_unclean_list_locked(UncleanRegionList* list); | |
738 | |
739 void set_unclean_regions_coming(bool b); | |
740 void set_unclean_regions_coming_locked(bool b); | |
741 // Wait for cleanup to be complete. | |
742 void wait_for_cleanup_complete(); | |
743 // Like above, but assumes that the calling thread owns the Heap_lock. | |
744 void wait_for_cleanup_complete_locked(); | |
745 | |
746 // Return the head of the unclean list. | |
747 HeapRegion* peek_unclean_region_list_locked(); | |
748 // Remove and return the head of the unclean list. | |
749 HeapRegion* pop_unclean_region_list_locked(); | |
750 | |
751 // List of regions which are zero filled and ready for allocation. | |
752 HeapRegion* _free_region_list; | |
753 // Number of elements on the free list. | |
754 size_t _free_region_list_size; | |
755 | |
756 // If the head of the unclean list is ZeroFilled, move it to the free | |
757 // list. | |
758 bool move_cleaned_region_to_free_list_locked(); | |
759 bool move_cleaned_region_to_free_list(); | |
760 | |
761 void put_free_region_on_list_locked(HeapRegion* r); | |
762 void put_free_region_on_list(HeapRegion* r); | |
763 | |
764 // Remove and return the head element of the free list. | |
765 HeapRegion* pop_free_region_list_locked(); | |
766 | |
767 // If "zero_filled" is true, we first try the free list, then we try the | |
768 // unclean list, zero-filling the result. If "zero_filled" is false, we | |
769 // first try the unclean list, then the zero-filled list. | |
770 HeapRegion* alloc_free_region_from_lists(bool zero_filled); | |
771 | |
772 // Verify the integrity of the region lists. | |
773 void remove_allocated_regions_from_lists(); | |
774 bool verify_region_lists(); | |
775 bool verify_region_lists_locked(); | |
776 size_t unclean_region_list_length(); | |
777 size_t free_region_list_length(); | |
778 | |
779 // Perform a collection of the heap; intended for use in implementing | |
780 // "System.gc". This probably implies as full a collection as the | |
781 // "CollectedHeap" supports. | |
782 virtual void collect(GCCause::Cause cause); | |
783 | |
784 // The same as above but assume that the caller holds the Heap_lock. | |
785 void collect_locked(GCCause::Cause cause); | |
786 | |
787 // This interface assumes that it's being called by the | |
788 // vm thread. It collects the heap assuming that the | |
789 // heap lock is already held and that we are executing in | |
790 // the context of the vm thread. | |
791 virtual void collect_as_vm_thread(GCCause::Cause cause); | |
792 | |
793 // True iff a evacuation has failed in the most-recent collection. | |
794 bool evacuation_failed() { return _evacuation_failed; } | |
795 | |
796 // Free a region if it is totally full of garbage. Returns the number of | |
797 // bytes freed (0 ==> didn't free it). | |
798 size_t free_region_if_totally_empty(HeapRegion *hr); | |
799 void free_region_if_totally_empty_work(HeapRegion *hr, | |
800 size_t& pre_used, | |
801 size_t& cleared_h_regions, | |
802 size_t& freed_regions, | |
803 UncleanRegionList* list, | |
804 bool par = false); | |
805 | |
806 // If we've done free region work that yields the given changes, update | |
807 // the relevant global variables. | |
808 void finish_free_region_work(size_t pre_used, | |
809 size_t cleared_h_regions, | |
810 size_t freed_regions, | |
811 UncleanRegionList* list); | |
812 | |
813 | |
814 // Returns "TRUE" iff "p" points into the allocated area of the heap. | |
815 virtual bool is_in(const void* p) const; | |
816 | |
817 // Return "TRUE" iff the given object address is within the collection | |
818 // set. | |
819 inline bool obj_in_cs(oop obj); | |
820 | |
821 // Return "TRUE" iff the given object address is in the reserved | |
822 // region of g1 (excluding the permanent generation). | |
823 bool is_in_g1_reserved(const void* p) const { | |
824 return _g1_reserved.contains(p); | |
825 } | |
826 | |
827 // Returns a MemRegion that corresponds to the space that has been | |
828 // committed in the heap | |
829 MemRegion g1_committed() { | |
830 return _g1_committed; | |
831 } | |
832 | |
833 NOT_PRODUCT( bool is_in_closed_subset(const void* p) const; ) | |
834 | |
835 // Dirty card table entries covering a list of young regions. | |
836 void dirtyCardsForYoungRegions(CardTableModRefBS* ct_bs, HeapRegion* list); | |
837 | |
838 // This resets the card table to all zeros. It is used after | |
839 // a collection pause which used the card table to claim cards. | |
840 void cleanUpCardTable(); | |
841 | |
842 // Iteration functions. | |
843 | |
844 // Iterate over all the ref-containing fields of all objects, calling | |
845 // "cl.do_oop" on each. | |
846 virtual void oop_iterate(OopClosure* cl); | |
847 | |
848 // Same as above, restricted to a memory region. | |
849 virtual void oop_iterate(MemRegion mr, OopClosure* cl); | |
850 | |
851 // Iterate over all objects, calling "cl.do_object" on each. | |
852 virtual void object_iterate(ObjectClosure* cl); | |
517
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
390
diff
changeset
|
853 virtual void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); } |
342 | 854 |
855 // Iterate over all objects allocated since the last collection, calling | |
856 // "cl.do_object" on each. The heap must have been initialized properly | |
857 // to support this function, or else this call will fail. | |
858 virtual void object_iterate_since_last_GC(ObjectClosure* cl); | |
859 | |
860 // Iterate over all spaces in use in the heap, in ascending address order. | |
861 virtual void space_iterate(SpaceClosure* cl); | |
862 | |
863 // Iterate over heap regions, in address order, terminating the | |
864 // iteration early if the "doHeapRegion" method returns "true". | |
865 void heap_region_iterate(HeapRegionClosure* blk); | |
866 | |
867 // Iterate over heap regions starting with r (or the first region if "r" | |
868 // is NULL), in address order, terminating early if the "doHeapRegion" | |
869 // method returns "true". | |
870 void heap_region_iterate_from(HeapRegion* r, HeapRegionClosure* blk); | |
871 | |
872 // As above but starting from the region at index idx. | |
873 void heap_region_iterate_from(int idx, HeapRegionClosure* blk); | |
874 | |
875 HeapRegion* region_at(size_t idx); | |
876 | |
877 // Divide the heap region sequence into "chunks" of some size (the number | |
878 // of regions divided by the number of parallel threads times some | |
879 // overpartition factor, currently 4). Assumes that this will be called | |
880 // in parallel by ParallelGCThreads worker threads with discinct worker | |
881 // ids in the range [0..max(ParallelGCThreads-1, 1)], that all parallel | |
882 // calls will use the same "claim_value", and that that claim value is | |
883 // different from the claim_value of any heap region before the start of | |
884 // the iteration. Applies "blk->doHeapRegion" to each of the regions, by | |
885 // attempting to claim the first region in each chunk, and, if | |
886 // successful, applying the closure to each region in the chunk (and | |
887 // setting the claim value of the second and subsequent regions of the | |
888 // chunk.) For now requires that "doHeapRegion" always returns "false", | |
889 // i.e., that a closure never attempt to abort a traversal. | |
890 void heap_region_par_iterate_chunked(HeapRegionClosure* blk, | |
891 int worker, | |
892 jint claim_value); | |
893 | |
390 | 894 // It resets all the region claim values to the default. |
895 void reset_heap_region_claim_values(); | |
896 | |
355 | 897 #ifdef ASSERT |
898 bool check_heap_region_claim_values(jint claim_value); | |
899 #endif // ASSERT | |
900 | |
342 | 901 // Iterate over the regions (if any) in the current collection set. |
902 void collection_set_iterate(HeapRegionClosure* blk); | |
903 | |
904 // As above but starting from region r | |
905 void collection_set_iterate_from(HeapRegion* r, HeapRegionClosure *blk); | |
906 | |
907 // Returns the first (lowest address) compactible space in the heap. | |
908 virtual CompactibleSpace* first_compactible_space(); | |
909 | |
910 // A CollectedHeap will contain some number of spaces. This finds the | |
911 // space containing a given address, or else returns NULL. | |
912 virtual Space* space_containing(const void* addr) const; | |
913 | |
914 // A G1CollectedHeap will contain some number of heap regions. This | |
915 // finds the region containing a given address, or else returns NULL. | |
916 HeapRegion* heap_region_containing(const void* addr) const; | |
917 | |
918 // Like the above, but requires "addr" to be in the heap (to avoid a | |
919 // null-check), and unlike the above, may return an continuing humongous | |
920 // region. | |
921 HeapRegion* heap_region_containing_raw(const void* addr) const; | |
922 | |
923 // A CollectedHeap is divided into a dense sequence of "blocks"; that is, | |
924 // each address in the (reserved) heap is a member of exactly | |
925 // one block. The defining characteristic of a block is that it is | |
926 // possible to find its size, and thus to progress forward to the next | |
927 // block. (Blocks may be of different sizes.) Thus, blocks may | |
928 // represent Java objects, or they might be free blocks in a | |
929 // free-list-based heap (or subheap), as long as the two kinds are | |
930 // distinguishable and the size of each is determinable. | |
931 | |
932 // Returns the address of the start of the "block" that contains the | |
933 // address "addr". We say "blocks" instead of "object" since some heaps | |
934 // may not pack objects densely; a chunk may either be an object or a | |
935 // non-object. | |
936 virtual HeapWord* block_start(const void* addr) const; | |
937 | |
938 // Requires "addr" to be the start of a chunk, and returns its size. | |
939 // "addr + size" is required to be the start of a new chunk, or the end | |
940 // of the active area of the heap. | |
941 virtual size_t block_size(const HeapWord* addr) const; | |
942 | |
943 // Requires "addr" to be the start of a block, and returns "TRUE" iff | |
944 // the block is an object. | |
945 virtual bool block_is_obj(const HeapWord* addr) const; | |
946 | |
947 // Does this heap support heap inspection? (+PrintClassHistogram) | |
948 virtual bool supports_heap_inspection() const { return true; } | |
949 | |
950 // Section on thread-local allocation buffers (TLABs) | |
951 // See CollectedHeap for semantics. | |
952 | |
953 virtual bool supports_tlab_allocation() const; | |
954 virtual size_t tlab_capacity(Thread* thr) const; | |
955 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const; | |
956 virtual HeapWord* allocate_new_tlab(size_t size); | |
957 | |
958 // Can a compiler initialize a new object without store barriers? | |
959 // This permission only extends from the creation of a new object | |
960 // via a TLAB up to the first subsequent safepoint. | |
961 virtual bool can_elide_tlab_store_barriers() const { | |
962 // Since G1's TLAB's may, on occasion, come from non-young regions | |
963 // as well. (Is there a flag controlling that? XXX) | |
964 return false; | |
965 } | |
966 | |
967 // Can a compiler elide a store barrier when it writes | |
968 // a permanent oop into the heap? Applies when the compiler | |
969 // is storing x to the heap, where x->is_perm() is true. | |
970 virtual bool can_elide_permanent_oop_store_barriers() const { | |
971 // At least until perm gen collection is also G1-ified, at | |
972 // which point this should return false. | |
973 return true; | |
974 } | |
975 | |
976 virtual bool allocs_are_zero_filled(); | |
977 | |
978 // The boundary between a "large" and "small" array of primitives, in | |
979 // words. | |
980 virtual size_t large_typearray_limit(); | |
981 | |
982 // All popular objects are guaranteed to have addresses below this | |
983 // boundary. | |
984 HeapWord* popular_object_boundary() { | |
985 return _popular_object_boundary; | |
986 } | |
987 | |
988 // Declare the region as one that should be evacuated because its | |
989 // remembered set is too large. | |
990 void schedule_popular_region_evac(HeapRegion* r); | |
991 // If there is a popular region to evacuate it, remove it from the list | |
992 // and return it. | |
993 HeapRegion* popular_region_to_evac(); | |
994 // Evacuate the given popular region. | |
995 void evac_popular_region(HeapRegion* r); | |
996 | |
997 // Returns "true" iff the given word_size is "very large". | |
998 static bool isHumongous(size_t word_size) { | |
999 return word_size >= VeryLargeInWords; | |
1000 } | |
1001 | |
1002 // Update mod union table with the set of dirty cards. | |
1003 void updateModUnion(); | |
1004 | |
1005 // Set the mod union bits corresponding to the given memRegion. Note | |
1006 // that this is always a safe operation, since it doesn't clear any | |
1007 // bits. | |
1008 void markModUnionRange(MemRegion mr); | |
1009 | |
1010 // Records the fact that a marking phase is no longer in progress. | |
1011 void set_marking_complete() { | |
1012 _mark_in_progress = false; | |
1013 } | |
1014 void set_marking_started() { | |
1015 _mark_in_progress = true; | |
1016 } | |
1017 bool mark_in_progress() { | |
1018 return _mark_in_progress; | |
1019 } | |
1020 | |
1021 // Print the maximum heap capacity. | |
1022 virtual size_t max_capacity() const; | |
1023 | |
1024 virtual jlong millis_since_last_gc(); | |
1025 | |
1026 // Perform any cleanup actions necessary before allowing a verification. | |
1027 virtual void prepare_for_verify(); | |
1028 | |
1029 // Perform verification. | |
1030 virtual void verify(bool allow_dirty, bool silent); | |
1031 virtual void print() const; | |
1032 virtual void print_on(outputStream* st) const; | |
1033 | |
1034 virtual void print_gc_threads_on(outputStream* st) const; | |
1035 virtual void gc_threads_do(ThreadClosure* tc) const; | |
1036 | |
1037 // Override | |
1038 void print_tracing_info() const; | |
1039 | |
1040 // If "addr" is a pointer into the (reserved?) heap, returns a positive | |
1041 // number indicating the "arena" within the heap in which "addr" falls. | |
1042 // Or else returns 0. | |
1043 virtual int addr_to_arena_id(void* addr) const; | |
1044 | |
1045 // Convenience function to be used in situations where the heap type can be | |
1046 // asserted to be this type. | |
1047 static G1CollectedHeap* heap(); | |
1048 | |
1049 void empty_young_list(); | |
1050 bool should_set_young_locked(); | |
1051 | |
1052 void set_region_short_lived_locked(HeapRegion* hr); | |
1053 // add appropriate methods for any other surv rate groups | |
1054 | |
1055 void young_list_rs_length_sampling_init() { | |
1056 _young_list->rs_length_sampling_init(); | |
1057 } | |
1058 bool young_list_rs_length_sampling_more() { | |
1059 return _young_list->rs_length_sampling_more(); | |
1060 } | |
1061 void young_list_rs_length_sampling_next() { | |
1062 _young_list->rs_length_sampling_next(); | |
1063 } | |
1064 size_t young_list_sampled_rs_lengths() { | |
1065 return _young_list->sampled_rs_lengths(); | |
1066 } | |
1067 | |
1068 size_t young_list_length() { return _young_list->length(); } | |
1069 size_t young_list_scan_only_length() { | |
1070 return _young_list->scan_only_length(); } | |
1071 | |
1072 HeapRegion* pop_region_from_young_list() { | |
1073 return _young_list->pop_region(); | |
1074 } | |
1075 | |
1076 HeapRegion* young_list_first_region() { | |
1077 return _young_list->first_region(); | |
1078 } | |
1079 | |
1080 // debugging | |
1081 bool check_young_list_well_formed() { | |
1082 return _young_list->check_list_well_formed(); | |
1083 } | |
1084 bool check_young_list_empty(bool ignore_scan_only_list, | |
1085 bool check_sample = true); | |
1086 | |
1087 // *** Stuff related to concurrent marking. It's not clear to me that so | |
1088 // many of these need to be public. | |
1089 | |
1090 // The functions below are helper functions that a subclass of | |
1091 // "CollectedHeap" can use in the implementation of its virtual | |
1092 // functions. | |
1093 // This performs a concurrent marking of the live objects in a | |
1094 // bitmap off to the side. | |
1095 void doConcurrentMark(); | |
1096 | |
1097 // This is called from the marksweep collector which then does | |
1098 // a concurrent mark and verifies that the results agree with | |
1099 // the stop the world marking. | |
1100 void checkConcurrentMark(); | |
1101 void do_sync_mark(); | |
1102 | |
1103 bool isMarkedPrev(oop obj) const; | |
1104 bool isMarkedNext(oop obj) const; | |
1105 | |
1106 // Determine if an object is dead, given the object and also | |
1107 // the region to which the object belongs. An object is dead | |
1108 // iff a) it was not allocated since the last mark and b) it | |
1109 // is not marked. | |
1110 | |
1111 bool is_obj_dead(const oop obj, const HeapRegion* hr) const { | |
1112 return | |
1113 !hr->obj_allocated_since_prev_marking(obj) && | |
1114 !isMarkedPrev(obj); | |
1115 } | |
1116 | |
1117 // This is used when copying an object to survivor space. | |
1118 // If the object is marked live, then we mark the copy live. | |
1119 // If the object is allocated since the start of this mark | |
1120 // cycle, then we mark the copy live. | |
1121 // If the object has been around since the previous mark | |
1122 // phase, and hasn't been marked yet during this phase, | |
1123 // then we don't mark it, we just wait for the | |
1124 // current marking cycle to get to it. | |
1125 | |
1126 // This function returns true when an object has been | |
1127 // around since the previous marking and hasn't yet | |
1128 // been marked during this marking. | |
1129 | |
1130 bool is_obj_ill(const oop obj, const HeapRegion* hr) const { | |
1131 return | |
1132 !hr->obj_allocated_since_next_marking(obj) && | |
1133 !isMarkedNext(obj); | |
1134 } | |
1135 | |
1136 // Determine if an object is dead, given only the object itself. | |
1137 // This will find the region to which the object belongs and | |
1138 // then call the region version of the same function. | |
1139 | |
1140 // Added if it is in permanent gen it isn't dead. | |
1141 // Added if it is NULL it isn't dead. | |
1142 | |
1143 bool is_obj_dead(oop obj) { | |
1144 HeapRegion* hr = heap_region_containing(obj); | |
1145 if (hr == NULL) { | |
1146 if (Universe::heap()->is_in_permanent(obj)) | |
1147 return false; | |
1148 else if (obj == NULL) return false; | |
1149 else return true; | |
1150 } | |
1151 else return is_obj_dead(obj, hr); | |
1152 } | |
1153 | |
1154 bool is_obj_ill(oop obj) { | |
1155 HeapRegion* hr = heap_region_containing(obj); | |
1156 if (hr == NULL) { | |
1157 if (Universe::heap()->is_in_permanent(obj)) | |
1158 return false; | |
1159 else if (obj == NULL) return false; | |
1160 else return true; | |
1161 } | |
1162 else return is_obj_ill(obj, hr); | |
1163 } | |
1164 | |
1165 // The following is just to alert the verification code | |
1166 // that a full collection has occurred and that the | |
1167 // remembered sets are no longer up to date. | |
1168 bool _full_collection; | |
1169 void set_full_collection() { _full_collection = true;} | |
1170 void clear_full_collection() {_full_collection = false;} | |
1171 bool full_collection() {return _full_collection;} | |
1172 | |
1173 ConcurrentMark* concurrent_mark() const { return _cm; } | |
1174 ConcurrentG1Refine* concurrent_g1_refine() const { return _cg1r; } | |
1175 | |
1176 public: | |
1177 void stop_conc_gc_threads(); | |
1178 | |
1179 // <NEW PREDICTION> | |
1180 | |
1181 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); | |
1182 void check_if_region_is_too_expensive(double predicted_time_ms); | |
1183 size_t pending_card_num(); | |
1184 size_t max_pending_card_num(); | |
1185 size_t cards_scanned(); | |
1186 | |
1187 // </NEW PREDICTION> | |
1188 | |
1189 protected: | |
1190 size_t _max_heap_capacity; | |
1191 | |
1192 // debug_only(static void check_for_valid_allocation_state();) | |
1193 | |
1194 public: | |
1195 // Temporary: call to mark things unimplemented for the G1 heap (e.g., | |
1196 // MemoryService). In productization, we can make this assert false | |
1197 // to catch such places (as well as searching for calls to this...) | |
1198 static void g1_unimplemented(); | |
1199 | |
1200 }; | |
1201 | |
1202 // Local Variables: *** | |
1203 // c-indentation-style: gnu *** | |
1204 // End: *** |