Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 1991:016a3628c885
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
Summary: Allow the eden to the expanded up to a point when the GC locker is active.
Reviewed-by: jwilhelm, johnc, ysr, jcoomes
author | tonyp |
---|---|
date | Tue, 07 Dec 2010 16:47:42 -0500 |
parents | d9310331a29c |
children | 8df09fb45352 |
comparison
equal
deleted
inserted
replaced
1975:d9310331a29c | 1991:016a3628c885 |
---|---|
617 // See the comment in the .hpp file about the locking protocol and | 617 // See the comment in the .hpp file about the locking protocol and |
618 // assumptions of this method (and other related ones). | 618 // assumptions of this method (and other related ones). |
619 HeapWord* | 619 HeapWord* |
620 G1CollectedHeap::replace_cur_alloc_region_and_allocate(size_t word_size, | 620 G1CollectedHeap::replace_cur_alloc_region_and_allocate(size_t word_size, |
621 bool at_safepoint, | 621 bool at_safepoint, |
622 bool do_dirtying) { | 622 bool do_dirtying, |
623 bool can_expand) { | |
623 assert_heap_locked_or_at_safepoint(); | 624 assert_heap_locked_or_at_safepoint(); |
624 assert(_cur_alloc_region == NULL, | 625 assert(_cur_alloc_region == NULL, |
625 "replace_cur_alloc_region_and_allocate() should only be called " | 626 "replace_cur_alloc_region_and_allocate() should only be called " |
626 "after retiring the previous current alloc region"); | 627 "after retiring the previous current alloc region"); |
627 assert(SafepointSynchronize::is_at_safepoint() == at_safepoint, | 628 assert(SafepointSynchronize::is_at_safepoint() == at_safepoint, |
628 "at_safepoint and is_at_safepoint() should be a tautology"); | 629 "at_safepoint and is_at_safepoint() should be a tautology"); |
629 | 630 assert(!can_expand || g1_policy()->can_expand_young_list(), |
630 if (!g1_policy()->is_young_list_full()) { | 631 "we should not call this method with can_expand == true if " |
632 "we are not allowed to expand the young gen"); | |
633 | |
634 if (can_expand || !g1_policy()->is_young_list_full()) { | |
631 if (!at_safepoint) { | 635 if (!at_safepoint) { |
632 // The cleanup operation might update _summary_bytes_used | 636 // The cleanup operation might update _summary_bytes_used |
633 // concurrently with this method. So, right now, if we don't | 637 // concurrently with this method. So, right now, if we don't |
634 // wait for it to complete, updates to _summary_bytes_used might | 638 // wait for it to complete, updates to _summary_bytes_used might |
635 // get lost. This will be resolved in the near future when the | 639 // get lost. This will be resolved in the near future when the |
736 return result; | 740 return result; |
737 } | 741 } |
738 } | 742 } |
739 | 743 |
740 if (GC_locker::is_active_and_needs_gc()) { | 744 if (GC_locker::is_active_and_needs_gc()) { |
741 // We are locked out of GC because of the GC locker. Right now, | 745 // We are locked out of GC because of the GC locker. We can |
742 // we'll just stall until the GC locker-induced GC | 746 // allocate a new region only if we can expand the young gen. |
743 // completes. This will be fixed in the near future by extending | 747 |
744 // the eden while waiting for the GC locker to schedule the GC | 748 if (g1_policy()->can_expand_young_list()) { |
745 // (see CR 6994056). | 749 // Yes, we are allowed to expand the young gen. Let's try to |
750 // allocate a new current alloc region. | |
751 | |
752 HeapWord* result = | |
753 replace_cur_alloc_region_and_allocate(word_size, | |
754 false, /* at_safepoint */ | |
755 true, /* do_dirtying */ | |
756 true /* can_expand */); | |
757 if (result != NULL) { | |
758 assert_heap_not_locked(); | |
759 return result; | |
760 } | |
761 } | |
762 // We could not expand the young gen further (or we could but we | |
763 // failed to allocate a new region). We'll stall until the GC | |
764 // locker forces a GC. | |
746 | 765 |
747 // If this thread is not in a jni critical section, we stall | 766 // If this thread is not in a jni critical section, we stall |
748 // the requestor until the critical section has cleared and | 767 // the requestor until the critical section has cleared and |
749 // GC allowed. When the critical section clears, a GC is | 768 // GC allowed. When the critical section clears, a GC is |
750 // initiated by the last thread exiting the critical section; so | 769 // initiated by the last thread exiting the critical section; so |
948 | 967 |
949 assert(_cur_alloc_region == NULL, | 968 assert(_cur_alloc_region == NULL, |
950 "at this point we should have no cur alloc region"); | 969 "at this point we should have no cur alloc region"); |
951 return replace_cur_alloc_region_and_allocate(word_size, | 970 return replace_cur_alloc_region_and_allocate(word_size, |
952 true, /* at_safepoint */ | 971 true, /* at_safepoint */ |
953 false /* do_dirtying */); | 972 false /* do_dirtying */, |
973 false /* can_expand */); | |
954 } else { | 974 } else { |
955 return attempt_allocation_humongous(word_size, | 975 return attempt_allocation_humongous(word_size, |
956 true /* at_safepoint */); | 976 true /* at_safepoint */); |
957 } | 977 } |
958 | 978 |