Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/concurrentMark.hpp @ 4787:2ace1c4ee8da
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
Summary: This change simplifies the interaction between GC and concurrent marking. By disabling survivor spaces during the initial-mark pause we don't need to propagate marks of objects we copy during each GC (since we never need to copy an explicitly marked object).
Reviewed-by: johnc, brutisso
author | tonyp |
---|---|
date | Tue, 10 Jan 2012 18:58:13 -0500 |
parents | 441e946dc1af |
children | 2e966d967c5c |
comparison
equal
deleted
inserted
replaced
4786:1d6185f732aa | 4787:2ace1c4ee8da |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
164 | 164 |
165 // Represents a marking stack used by the CM collector. | 165 // Represents a marking stack used by the CM collector. |
166 // Ideally this should be GrowableArray<> just like MSC's marking stack(s). | 166 // Ideally this should be GrowableArray<> just like MSC's marking stack(s). |
167 class CMMarkStack VALUE_OBJ_CLASS_SPEC { | 167 class CMMarkStack VALUE_OBJ_CLASS_SPEC { |
168 ConcurrentMark* _cm; | 168 ConcurrentMark* _cm; |
169 oop* _base; // bottom of stack | 169 oop* _base; // bottom of stack |
170 jint _index; // one more than last occupied index | 170 jint _index; // one more than last occupied index |
171 jint _capacity; // max #elements | 171 jint _capacity; // max #elements |
172 jint _oops_do_bound; // Number of elements to include in next iteration. | 172 jint _saved_index; // value of _index saved at start of GC |
173 NOT_PRODUCT(jint _max_depth;) // max depth plumbed during run | 173 NOT_PRODUCT(jint _max_depth;) // max depth plumbed during run |
174 | 174 |
175 bool _overflow; | 175 bool _overflow; |
176 DEBUG_ONLY(bool _drain_in_progress;) | 176 DEBUG_ONLY(bool _drain_in_progress;) |
177 DEBUG_ONLY(bool _drain_in_progress_yields;) | 177 DEBUG_ONLY(bool _drain_in_progress_yields;) |
245 | 245 |
246 int size() { return _index; } | 246 int size() { return _index; } |
247 | 247 |
248 void setEmpty() { _index = 0; clear_overflow(); } | 248 void setEmpty() { _index = 0; clear_overflow(); } |
249 | 249 |
250 // Record the current size; a subsequent "oops_do" will iterate only over | 250 // Record the current index. |
251 // indices valid at the time of this call. | 251 void note_start_of_gc(); |
252 void set_oops_do_bound(jint bound = -1) { | 252 |
253 if (bound == -1) { | 253 // Make sure that we have not added any entries to the stack during GC. |
254 _oops_do_bound = _index; | 254 void note_end_of_gc(); |
255 } else { | 255 |
256 _oops_do_bound = bound; | |
257 } | |
258 } | |
259 jint oops_do_bound() { return _oops_do_bound; } | |
260 // iterate over the oops in the mark stack, up to the bound recorded via | 256 // iterate over the oops in the mark stack, up to the bound recorded via |
261 // the call above. | 257 // the call above. |
262 void oops_do(OopClosure* f); | 258 void oops_do(OopClosure* f); |
263 }; | 259 }; |
264 | 260 |
722 | 718 |
723 // The following three are interaction between CM and | 719 // The following three are interaction between CM and |
724 // G1CollectedHeap | 720 // G1CollectedHeap |
725 | 721 |
726 // This notifies CM that a root during initial-mark needs to be | 722 // This notifies CM that a root during initial-mark needs to be |
727 // grayed and it's MT-safe. Currently, we just mark it. But, in the | 723 // grayed. It is MT-safe. |
728 // future, we can experiment with pushing it on the stack and we can | 724 inline void grayRoot(oop obj, size_t word_size); |
729 // do this without changing G1CollectedHeap. | 725 |
730 void grayRoot(oop p); | |
731 // It's used during evacuation pauses to gray a region, if | 726 // It's used during evacuation pauses to gray a region, if |
732 // necessary, and it's MT-safe. It assumes that the caller has | 727 // necessary, and it's MT-safe. It assumes that the caller has |
733 // marked any objects on that region. If _should_gray_objects is | 728 // marked any objects on that region. If _should_gray_objects is |
734 // true and we're still doing concurrent marking, the region is | 729 // true and we're still doing concurrent marking, the region is |
735 // pushed on the region stack, if it is located below the global | 730 // pushed on the region stack, if it is located below the global |
736 // finger, otherwise we do nothing. | 731 // finger, otherwise we do nothing. |
737 void grayRegionIfNecessary(MemRegion mr); | 732 void grayRegionIfNecessary(MemRegion mr); |
733 | |
738 // It's used during evacuation pauses to mark and, if necessary, | 734 // It's used during evacuation pauses to mark and, if necessary, |
739 // gray a single object and it's MT-safe. It assumes the caller did | 735 // gray a single object and it's MT-safe. It assumes the caller did |
740 // not mark the object. If _should_gray_objects is true and we're | 736 // not mark the object. If _should_gray_objects is true and we're |
741 // still doing concurrent marking, the objects is pushed on the | 737 // still doing concurrent marking, the objects is pushed on the |
742 // global stack, if it is located below the global finger, otherwise | 738 // global stack, if it is located below the global finger, otherwise |
789 void cleanup(); | 785 void cleanup(); |
790 void completeCleanup(); | 786 void completeCleanup(); |
791 | 787 |
792 // Mark in the previous bitmap. NB: this is usually read-only, so use | 788 // Mark in the previous bitmap. NB: this is usually read-only, so use |
793 // this carefully! | 789 // this carefully! |
794 void markPrev(oop p); | 790 inline void markPrev(oop p); |
791 inline void markNext(oop p); | |
795 void clear(oop p); | 792 void clear(oop p); |
796 // Clears marks for all objects in the given range, for both prev and | 793 // Clears marks for all objects in the given range, for the prev, |
797 // next bitmaps. NB: the previous bitmap is usually read-only, so use | 794 // next, or both bitmaps. NB: the previous bitmap is usually |
798 // this carefully! | 795 // read-only, so use this carefully! |
799 void clearRangeBothMaps(MemRegion mr); | 796 void clearRangePrevBitmap(MemRegion mr); |
800 | 797 void clearRangeNextBitmap(MemRegion mr); |
801 // Record the current top of the mark and region stacks; a | 798 void clearRangeBothBitmaps(MemRegion mr); |
802 // subsequent oops_do() on the mark stack and | 799 |
803 // invalidate_entries_into_cset() on the region stack will iterate | 800 // Notify data structures that a GC has started. |
804 // only over indices valid at the time of this call. | 801 void note_start_of_gc() { |
805 void set_oops_do_bound() { | 802 _markStack.note_start_of_gc(); |
806 _markStack.set_oops_do_bound(); | 803 } |
807 _regionStack.set_oops_do_bound(); | 804 |
808 } | 805 // Notify data structures that a GC is finished. |
806 void note_end_of_gc() { | |
807 _markStack.note_end_of_gc(); | |
808 } | |
809 | |
809 // Iterate over the oops in the mark stack and all local queues. It | 810 // Iterate over the oops in the mark stack and all local queues. It |
810 // also calls invalidate_entries_into_cset() on the region stack. | 811 // also calls invalidate_entries_into_cset() on the region stack. |
811 void oops_do(OopClosure* f); | 812 void oops_do(OopClosure* f); |
813 | |
814 // Verify that there are no CSet oops on the stacks (taskqueues / | |
815 // global mark stack), enqueued SATB buffers, per-thread SATB | |
816 // buffers, and fingers (global / per-task). The boolean parameters | |
817 // decide which of the above data structures to verify. If marking | |
818 // is not in progress, it's a no-op. | |
819 void verify_no_cset_oops(bool verify_stacks, | |
820 bool verify_enqueued_buffers, | |
821 bool verify_thread_buffers, | |
822 bool verify_fingers) PRODUCT_RETURN; | |
823 | |
812 // It is called at the end of an evacuation pause during marking so | 824 // It is called at the end of an evacuation pause during marking so |
813 // that CM is notified of where the new end of the heap is. It | 825 // that CM is notified of where the new end of the heap is. It |
814 // doesn't do anything if concurrent_marking_in_progress() is false, | 826 // doesn't do anything if concurrent_marking_in_progress() is false, |
815 // unless the force parameter is true. | 827 // unless the force parameter is true. |
816 void update_g1_committed(bool force = false); | 828 void update_g1_committed(bool force = false); |
1164 // partially if false, it tries to empty them totally. | 1176 // partially if false, it tries to empty them totally. |
1165 void drain_global_stack(bool partially); | 1177 void drain_global_stack(bool partially); |
1166 // It keeps picking SATB buffers and processing them until no SATB | 1178 // It keeps picking SATB buffers and processing them until no SATB |
1167 // buffers are available. | 1179 // buffers are available. |
1168 void drain_satb_buffers(); | 1180 void drain_satb_buffers(); |
1181 | |
1169 // It keeps popping regions from the region stack and processing | 1182 // It keeps popping regions from the region stack and processing |
1170 // them until the region stack is empty. | 1183 // them until the region stack is empty. |
1171 void drain_region_stack(BitMapClosure* closure); | 1184 void drain_region_stack(BitMapClosure* closure); |
1172 | 1185 |
1173 // moves the local finger to a new location | 1186 // moves the local finger to a new location |