589 gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : " |
589 gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : " |
590 "res == NULL, trying the secondary_free_list"); |
590 "res == NULL, trying the secondary_free_list"); |
591 } |
591 } |
592 res = new_region_try_secondary_free_list(); |
592 res = new_region_try_secondary_free_list(); |
593 } |
593 } |
594 if (res == NULL && do_expand) { |
594 if (res == NULL && do_expand && _expand_heap_after_alloc_failure) { |
|
595 // Currently, only attempts to allocate GC alloc regions set |
|
596 // do_expand to true. So, we should only reach here during a |
|
597 // safepoint. If this assumption changes we might have to |
|
598 // reconsider the use of _expand_heap_after_alloc_failure. |
|
599 assert(SafepointSynchronize::is_at_safepoint(), "invariant"); |
|
600 |
595 ergo_verbose1(ErgoHeapSizing, |
601 ergo_verbose1(ErgoHeapSizing, |
596 "attempt heap expansion", |
602 "attempt heap expansion", |
597 ergo_format_reason("region allocation request failed") |
603 ergo_format_reason("region allocation request failed") |
598 ergo_format_byte("allocation request"), |
604 ergo_format_byte("allocation request"), |
599 word_size * HeapWordSize); |
605 word_size * HeapWordSize); |
600 if (expand(word_size * HeapWordSize)) { |
606 if (expand(word_size * HeapWordSize)) { |
601 // Even though the heap was expanded, it might not have reached |
607 // Given that expand() succeeded in expanding the heap, and we |
602 // the desired size. So, we cannot assume that the allocation |
608 // always expand the heap by an amount aligned to the heap |
603 // will succeed. |
609 // region size, the free list should in theory not be empty. So |
|
610 // it would probably be OK to use remove_head(). But the extra |
|
611 // check for NULL is unlikely to be a performance issue here (we |
|
612 // just expanded the heap!) so let's just be conservative and |
|
613 // use remove_head_or_null(). |
604 res = _free_list.remove_head_or_null(); |
614 res = _free_list.remove_head_or_null(); |
|
615 } else { |
|
616 _expand_heap_after_alloc_failure = false; |
605 } |
617 } |
606 } |
618 } |
607 return res; |
619 return res; |
608 } |
620 } |
609 |
621 |
1836 _humongous_set("Master Humongous Set"), |
1848 _humongous_set("Master Humongous Set"), |
1837 _free_regions_coming(false), |
1849 _free_regions_coming(false), |
1838 _young_list(new YoungList(this)), |
1850 _young_list(new YoungList(this)), |
1839 _gc_time_stamp(0), |
1851 _gc_time_stamp(0), |
1840 _retained_old_gc_alloc_region(NULL), |
1852 _retained_old_gc_alloc_region(NULL), |
|
1853 _expand_heap_after_alloc_failure(true), |
1841 _surviving_young_words(NULL), |
1854 _surviving_young_words(NULL), |
1842 _full_collections_completed(0), |
1855 _full_collections_completed(0), |
1843 _in_cset_fast_test(NULL), |
1856 _in_cset_fast_test(NULL), |
1844 _in_cset_fast_test_base(NULL), |
1857 _in_cset_fast_test_base(NULL), |
1845 _dirty_cards_region_list(NULL), |
1858 _dirty_cards_region_list(NULL), |
5437 double ref_enq_time = os::elapsedTime() - ref_enq_start; |
5450 double ref_enq_time = os::elapsedTime() - ref_enq_start; |
5438 g1_policy()->record_ref_enq_time(ref_enq_time * 1000.0); |
5451 g1_policy()->record_ref_enq_time(ref_enq_time * 1000.0); |
5439 } |
5452 } |
5440 |
5453 |
5441 void G1CollectedHeap::evacuate_collection_set() { |
5454 void G1CollectedHeap::evacuate_collection_set() { |
|
5455 _expand_heap_after_alloc_failure = true; |
5442 set_evacuation_failed(false); |
5456 set_evacuation_failed(false); |
5443 |
5457 |
5444 g1_rem_set()->prepare_for_oops_into_collection_set_do(); |
5458 g1_rem_set()->prepare_for_oops_into_collection_set_do(); |
5445 concurrent_g1_refine()->set_use_cache(false); |
5459 concurrent_g1_refine()->set_use_cache(false); |
5446 concurrent_g1_refine()->clear_hot_cache_claimed_index(); |
5460 concurrent_g1_refine()->clear_hot_cache_claimed_index(); |