Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 1656:4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
Summary: G1 was not handling explicit GCs correctly in many ways. It does now. See the CR for the list of improvements contained in this changeset.
Reviewed-by: iveresov, ysr, johnc
author | tonyp |
---|---|
date | Mon, 28 Jun 2010 14:13:17 -0400 |
parents | 215576b54709 |
children | 2d160770d2e5 |
comparison
equal
deleted
inserted
replaced
1655:e7ec8cd4dd8a | 1656:4e5661ba9d98 |
---|---|
275 | 275 |
276 void setup_surviving_young_words(); | 276 void setup_surviving_young_words(); |
277 void update_surviving_young_words(size_t* surv_young_words); | 277 void update_surviving_young_words(size_t* surv_young_words); |
278 void cleanup_surviving_young_words(); | 278 void cleanup_surviving_young_words(); |
279 | 279 |
280 // It decides whether an explicit GC should start a concurrent cycle | |
281 // instead of doing a STW GC. Currently, a concurrent cycle is | |
282 // explicitly started if: | |
283 // (a) cause == _gc_locker and +GCLockerInvokesConcurrent, or | |
284 // (b) cause == _java_lang_system_gc and +ExplicitGCInvokesConcurrent. | |
285 bool should_do_concurrent_full_gc(GCCause::Cause cause); | |
286 | |
287 // Keeps track of how many "full collections" (i.e., Full GCs or | |
288 // concurrent cycles) we have completed. The number of them we have | |
289 // started is maintained in _total_full_collections in CollectedHeap. | |
290 volatile unsigned int _full_collections_completed; | |
291 | |
280 protected: | 292 protected: |
281 | 293 |
282 // Returns "true" iff none of the gc alloc regions have any allocations | 294 // Returns "true" iff none of the gc alloc regions have any allocations |
283 // since the last call to "save_marks". | 295 // since the last call to "save_marks". |
284 bool all_alloc_regions_no_allocs_since_save_marks(); | 296 bool all_alloc_regions_no_allocs_since_save_marks(); |
354 | 366 |
355 // Retires an allocation region when it is full or at the end of a | 367 // Retires an allocation region when it is full or at the end of a |
356 // GC pause. | 368 // GC pause. |
357 void retire_alloc_region(HeapRegion* alloc_region, bool par); | 369 void retire_alloc_region(HeapRegion* alloc_region, bool par); |
358 | 370 |
359 // Helper function for two callbacks below. | 371 // - if explicit_gc is true, the GC is for a System.gc() or a heap |
360 // "full", if true, indicates that the GC is for a System.gc() request, | 372 // inspection request and should collect the entire heap |
361 // and should collect the entire heap. If "clear_all_soft_refs" is true, | 373 // - if clear_all_soft_refs is true, all soft references are cleared |
362 // all soft references are cleared during the GC. If "full" is false, | 374 // during the GC |
363 // "word_size" describes the allocation that the GC should | 375 // - if explicit_gc is false, word_size describes the allocation that |
364 // attempt (at least) to satisfy. | 376 // the GC should attempt (at least) to satisfy |
365 void do_collection(bool full, bool clear_all_soft_refs, | 377 void do_collection(bool explicit_gc, |
378 bool clear_all_soft_refs, | |
366 size_t word_size); | 379 size_t word_size); |
367 | 380 |
368 // Callback from VM_G1CollectFull operation. | 381 // Callback from VM_G1CollectFull operation. |
369 // Perform a full collection. | 382 // Perform a full collection. |
370 void do_full_collection(bool clear_all_soft_refs); | 383 void do_full_collection(bool clear_all_soft_refs); |
429 assert(_in_cset_fast_test_base != NULL, "sanity"); | 442 assert(_in_cset_fast_test_base != NULL, "sanity"); |
430 memset(_in_cset_fast_test_base, false, | 443 memset(_in_cset_fast_test_base, false, |
431 _in_cset_fast_test_length * sizeof(bool)); | 444 _in_cset_fast_test_length * sizeof(bool)); |
432 } | 445 } |
433 | 446 |
447 // This is called at the end of either a concurrent cycle or a Full | |
448 // GC to update the number of full collections completed. Those two | |
449 // can happen in a nested fashion, i.e., we start a concurrent | |
450 // cycle, a Full GC happens half-way through it which ends first, | |
451 // and then the cycle notices that a Full GC happened and ends | |
452 // too. The outer parameter is a boolean to help us do a bit tighter | |
453 // consistency checking in the method. If outer is false, the caller | |
454 // is the inner caller in the nesting (i.e., the Full GC). If outer | |
455 // is true, the caller is the outer caller in this nesting (i.e., | |
456 // the concurrent cycle). Further nesting is not currently | |
457 // supported. The end of the this call also notifies the | |
458 // FullGCCount_lock in case a Java thread is waiting for a full GC | |
459 // to happen (e.g., it called System.gc() with | |
460 // +ExplicitGCInvokesConcurrent). | |
461 void increment_full_collections_completed(bool outer); | |
462 | |
463 unsigned int full_collections_completed() { | |
464 return _full_collections_completed; | |
465 } | |
466 | |
434 protected: | 467 protected: |
435 | 468 |
436 // Shrink the garbage-first heap by at most the given size (in bytes!). | 469 // Shrink the garbage-first heap by at most the given size (in bytes!). |
437 // (Rounds down to a HeapRegion boundary.) | 470 // (Rounds down to a HeapRegion boundary.) |
438 virtual void shrink(size_t expand_bytes); | 471 virtual void shrink(size_t expand_bytes); |
442 // its live objects elsewhere. | 475 // its live objects elsewhere. |
443 virtual void do_collection_pause(); | 476 virtual void do_collection_pause(); |
444 | 477 |
445 // The guts of the incremental collection pause, executed by the vm | 478 // The guts of the incremental collection pause, executed by the vm |
446 // thread. | 479 // thread. |
447 virtual void do_collection_pause_at_safepoint(); | 480 virtual void do_collection_pause_at_safepoint(double target_pause_time_ms); |
448 | 481 |
449 // Actually do the work of evacuating the collection set. | 482 // Actually do the work of evacuating the collection set. |
450 virtual void evacuate_collection_set(); | 483 virtual void evacuate_collection_set(); |
451 | 484 |
452 // If this is an appropriate right time, do a collection pause. | 485 // If this is an appropriate right time, do a collection pause. |