Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 1359:23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
Summary: Make sure that two marking cycles do not overlap, i.e., a new one can only start after the concurrent marking thread finishes all its work. In the fix I piggy-back a couple of minor extra fixes: some general code reformatting for consistency (only around the code I modified), the removal of a field (G1CollectorPolicy::_should_initiate_conc_mark) which doesn't seem to be used at all (it's only set but never read), as well as moving the "is GC locker active" test earlier into the G1 pause / Full GC and using a more appropriate method for it.
Reviewed-by: johnc, jmasa, jcoomes, ysr
author | tonyp |
---|---|
date | Tue, 06 Apr 2010 10:59:45 -0400 |
parents | 664ae0c5e0e5 |
children | bda703475ded |
comparison
equal
deleted
inserted
replaced
1358:72f725c5a7be | 1359:23b1b27ac76c |
---|---|
900 } | 900 } |
901 }; | 901 }; |
902 | 902 |
903 void G1CollectedHeap::do_collection(bool full, bool clear_all_soft_refs, | 903 void G1CollectedHeap::do_collection(bool full, bool clear_all_soft_refs, |
904 size_t word_size) { | 904 size_t word_size) { |
905 if (GC_locker::check_active_before_gc()) { | |
906 return; // GC is disabled (e.g. JNI GetXXXCritical operation) | |
907 } | |
908 | |
905 ResourceMark rm; | 909 ResourceMark rm; |
906 | 910 |
907 if (PrintHeapAtGC) { | 911 if (PrintHeapAtGC) { |
908 Universe::print_heap_before_gc(); | 912 Universe::print_heap_before_gc(); |
909 } | 913 } |
913 return; | 917 return; |
914 } | 918 } |
915 | 919 |
916 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); | 920 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
917 assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread"); | 921 assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread"); |
918 | |
919 if (GC_locker::is_active()) { | |
920 return; // GC is disabled (e.g. JNI GetXXXCritical operation) | |
921 } | |
922 | 922 |
923 { | 923 { |
924 IsGCActiveMark x; | 924 IsGCActiveMark x; |
925 | 925 |
926 // Timing | 926 // Timing |
2656 } | 2656 } |
2657 }; | 2657 }; |
2658 | 2658 |
2659 void | 2659 void |
2660 G1CollectedHeap::do_collection_pause_at_safepoint() { | 2660 G1CollectedHeap::do_collection_pause_at_safepoint() { |
2661 if (GC_locker::check_active_before_gc()) { | |
2662 return; // GC is disabled (e.g. JNI GetXXXCritical operation) | |
2663 } | |
2664 | |
2661 if (PrintHeapAtGC) { | 2665 if (PrintHeapAtGC) { |
2662 Universe::print_heap_before_gc(); | 2666 Universe::print_heap_before_gc(); |
2663 } | 2667 } |
2664 | 2668 |
2665 { | 2669 { |
2666 ResourceMark rm; | 2670 ResourceMark rm; |
2671 | |
2672 // This call will decide whether this pause is an initial-mark | |
2673 // pause. If it is, during_initial_mark_pause() will return true | |
2674 // for the duration of this pause. | |
2675 g1_policy()->decide_on_conc_mark_initiation(); | |
2667 | 2676 |
2668 char verbose_str[128]; | 2677 char verbose_str[128]; |
2669 sprintf(verbose_str, "GC pause "); | 2678 sprintf(verbose_str, "GC pause "); |
2670 if (g1_policy()->in_young_gc_mode()) { | 2679 if (g1_policy()->in_young_gc_mode()) { |
2671 if (g1_policy()->full_young_gcs()) | 2680 if (g1_policy()->full_young_gcs()) |
2672 strcat(verbose_str, "(young)"); | 2681 strcat(verbose_str, "(young)"); |
2673 else | 2682 else |
2674 strcat(verbose_str, "(partial)"); | 2683 strcat(verbose_str, "(partial)"); |
2675 } | 2684 } |
2676 if (g1_policy()->should_initiate_conc_mark()) | 2685 if (g1_policy()->during_initial_mark_pause()) |
2677 strcat(verbose_str, " (initial-mark)"); | 2686 strcat(verbose_str, " (initial-mark)"); |
2678 | 2687 |
2679 // if PrintGCDetails is on, we'll print long statistics information | 2688 // if PrintGCDetails is on, we'll print long statistics information |
2680 // in the collector policy code, so let's not print this as the output | 2689 // in the collector policy code, so let's not print this as the output |
2681 // is messy if we do. | 2690 // is messy if we do. |
2693 increment_gc_time_stamp(); | 2702 increment_gc_time_stamp(); |
2694 | 2703 |
2695 if (g1_policy()->in_young_gc_mode()) { | 2704 if (g1_policy()->in_young_gc_mode()) { |
2696 assert(check_young_list_well_formed(), | 2705 assert(check_young_list_well_formed(), |
2697 "young list should be well formed"); | 2706 "young list should be well formed"); |
2698 } | |
2699 | |
2700 if (GC_locker::is_active()) { | |
2701 return; // GC is disabled (e.g. JNI GetXXXCritical operation) | |
2702 } | 2707 } |
2703 | 2708 |
2704 bool abandoned = false; | 2709 bool abandoned = false; |
2705 { // Call to jvmpi::post_class_unload_events must occur outside of active GC | 2710 { // Call to jvmpi::post_class_unload_events must occur outside of active GC |
2706 IsGCActiveMark x; | 2711 IsGCActiveMark x; |
2754 | 2759 |
2755 #if SCAN_ONLY_VERBOSE | 2760 #if SCAN_ONLY_VERBOSE |
2756 _young_list->print(); | 2761 _young_list->print(); |
2757 #endif // SCAN_ONLY_VERBOSE | 2762 #endif // SCAN_ONLY_VERBOSE |
2758 | 2763 |
2759 if (g1_policy()->should_initiate_conc_mark()) { | 2764 if (g1_policy()->during_initial_mark_pause()) { |
2760 concurrent_mark()->checkpointRootsInitialPre(); | 2765 concurrent_mark()->checkpointRootsInitialPre(); |
2761 } | 2766 } |
2762 save_marks(); | 2767 save_marks(); |
2763 | 2768 |
2764 // We must do this before any possible evacuation that should propagate | 2769 // We must do this before any possible evacuation that should propagate |
2856 // when they were freed. Add in the bytes evacuated. | 2861 // when they were freed. Add in the bytes evacuated. |
2857 _summary_bytes_used += g1_policy()->bytes_in_to_space(); | 2862 _summary_bytes_used += g1_policy()->bytes_in_to_space(); |
2858 } | 2863 } |
2859 | 2864 |
2860 if (g1_policy()->in_young_gc_mode() && | 2865 if (g1_policy()->in_young_gc_mode() && |
2861 g1_policy()->should_initiate_conc_mark()) { | 2866 g1_policy()->during_initial_mark_pause()) { |
2862 concurrent_mark()->checkpointRootsInitialPost(); | 2867 concurrent_mark()->checkpointRootsInitialPost(); |
2863 set_marking_started(); | 2868 set_marking_started(); |
2864 // CAUTION: after the doConcurrentMark() call below, | 2869 // CAUTION: after the doConcurrentMark() call below, |
2865 // the concurrent marking thread(s) could be running | 2870 // the concurrent marking thread(s) could be running |
2866 // concurrently with us. Make sure that anything after | 2871 // concurrently with us. Make sure that anything after |
3975 | 3980 |
3976 OopsInHeapRegionClosure *scan_root_cl; | 3981 OopsInHeapRegionClosure *scan_root_cl; |
3977 OopsInHeapRegionClosure *scan_perm_cl; | 3982 OopsInHeapRegionClosure *scan_perm_cl; |
3978 OopsInHeapRegionClosure *scan_so_cl; | 3983 OopsInHeapRegionClosure *scan_so_cl; |
3979 | 3984 |
3980 if (_g1h->g1_policy()->should_initiate_conc_mark()) { | 3985 if (_g1h->g1_policy()->during_initial_mark_pause()) { |
3981 scan_root_cl = &scan_mark_root_cl; | 3986 scan_root_cl = &scan_mark_root_cl; |
3982 scan_perm_cl = &scan_mark_perm_cl; | 3987 scan_perm_cl = &scan_mark_perm_cl; |
3983 scan_so_cl = &scan_mark_heap_rs_cl; | 3988 scan_so_cl = &scan_mark_heap_rs_cl; |
3984 } else { | 3989 } else { |
3985 scan_root_cl = &only_scan_root_cl; | 3990 scan_root_cl = &only_scan_root_cl; |
4138 | 4143 |
4139 FilterInHeapRegionAndIntoCSClosure scan_only(this, &boc); | 4144 FilterInHeapRegionAndIntoCSClosure scan_only(this, &boc); |
4140 FilterAndMarkInHeapRegionAndIntoCSClosure scan_and_mark(this, &boc, concurrent_mark()); | 4145 FilterAndMarkInHeapRegionAndIntoCSClosure scan_and_mark(this, &boc, concurrent_mark()); |
4141 | 4146 |
4142 OopsInHeapRegionClosure *foc; | 4147 OopsInHeapRegionClosure *foc; |
4143 if (g1_policy()->should_initiate_conc_mark()) | 4148 if (g1_policy()->during_initial_mark_pause()) |
4144 foc = &scan_and_mark; | 4149 foc = &scan_and_mark; |
4145 else | 4150 else |
4146 foc = &scan_only; | 4151 foc = &scan_only; |
4147 | 4152 |
4148 HeapRegion* hr; | 4153 HeapRegion* hr; |