18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
27 #include "gc_implementation/parNew/parNewGeneration.hpp"
28 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
29 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
30 #include "gc_implementation/shared/ageTable.hpp"
31 #include "gc_implementation/shared/copyFailedInfo.hpp"
32 #include "gc_implementation/shared/gcHeapSummary.hpp"
33 #include "gc_implementation/shared/gcTimer.hpp"
34 #include "gc_implementation/shared/gcTrace.hpp"
35 #include "gc_implementation/shared/gcTraceTime.hpp"
36 #include "gc_implementation/shared/parGCAllocBuffer.inline.hpp"
37 #include "gc_implementation/shared/spaceDecorator.hpp"
38 #include "memory/defNewGeneration.inline.hpp"
39 #include "memory/genCollectedHeap.hpp"
40 #include "memory/genOopClosures.inline.hpp"
41 #include "memory/generation.hpp"
42 #include "memory/generation.inline.hpp"
43 #include "memory/referencePolicy.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "memory/sharedHeap.hpp"
46 #include "memory/space.hpp"
47 #include "oops/objArrayOop.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "oops/oop.pcgc.inline.hpp"
50 #include "runtime/atomic.inline.hpp"
51 #include "runtime/handles.hpp"
52 #include "runtime/handles.inline.hpp"
53 #include "runtime/java.hpp"
54 #include "runtime/thread.inline.hpp"
55 #include "utilities/copy.hpp"
56 #include "utilities/globalDefinitions.hpp"
57 #include "utilities/workgroup.hpp"
58
59 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
60
61 #ifdef _MSC_VER
62 #pragma warning( push )
63 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
64 #endif
65 ParScanThreadState::ParScanThreadState(Space* to_space_,
66 ParNewGeneration* gen_,
67 Generation* old_gen_,
131 int remainder = end - start;
132 assert(start <= end, "just checking");
133 if (remainder > 2 * ParGCArrayScanChunk) {
134 // Test above combines last partial chunk with a full chunk
135 end = start + ParGCArrayScanChunk;
136 arrayOop(old)->set_length(end);
137 // Push remainder.
138 bool ok = work_queue()->push(old);
139 assert(ok, "just popped, push must be okay");
140 } else {
141 // Restore length so that it can be used if there
142 // is a promotion failure and forwarding pointers
143 // must be removed.
144 arrayOop(old)->set_length(end);
145 }
146
147 // process our set of indices (include header in first chunk)
148 // should make sure end is even (aligned to HeapWord in case of compressed oops)
149 if ((HeapWord *)obj < young_old_boundary()) {
150 // object is in to_space
151 obj->oop_iterate_range(&_to_space_closure, start, end);
152 } else {
153 // object is in old generation
154 obj->oop_iterate_range(&_old_gen_closure, start, end);
155 }
156 }
157
158
159 void ParScanThreadState::trim_queues(int max_size) {
160 ObjToScanQueue* queue = work_queue();
161 do {
162 while (queue->size() > (juint)max_size) {
163 oop obj_to_scan;
164 if (queue->pop_local(obj_to_scan)) {
165 if ((HeapWord *)obj_to_scan < young_old_boundary()) {
166 if (obj_to_scan->is_objArray() &&
167 obj_to_scan->is_forwarded() &&
168 obj_to_scan->forwardee() != obj_to_scan) {
169 scan_partial_array_and_push_remainder(obj_to_scan);
170 } else {
171 // object is in to_space
172 obj_to_scan->oop_iterate(&_to_space_closure);
173 }
174 } else {
858 gch->set_par_threads(0); // 0 ==> non-parallel.
859 gch->save_marks();
860 }
861
862 ScanClosureWithParBarrier::
863 ScanClosureWithParBarrier(ParNewGeneration* g, bool gc_barrier) :
864 ScanClosure(g, gc_barrier) {}
865
866 EvacuateFollowersClosureGeneral::
867 EvacuateFollowersClosureGeneral(GenCollectedHeap* gch, int level,
868 OopsInGenClosure* cur,
869 OopsInGenClosure* older) :
870 _gch(gch), _level(level),
871 _scan_cur_or_nonheap(cur), _scan_older(older)
872 {}
873
874 void EvacuateFollowersClosureGeneral::do_void() {
875 do {
876 // Beware: this call will lead to closure applications via virtual
877 // calls.
878 _gch->oop_since_save_marks_iterate(_level,
879 _scan_cur_or_nonheap,
880 _scan_older);
881 } while (!_gch->no_allocs_since_save_marks(_level));
882 }
883
884
885 // A Generation that does parallel young-gen collection.
886
887 bool ParNewGeneration::_avoid_promotion_undo = false;
888
889 void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer) {
890 assert(_promo_failure_scan_stack.is_empty(), "post condition");
891 _promo_failure_scan_stack.clear(true); // Clear cached segments.
892
893 remove_forwarding_pointers();
894 if (PrintGCDetails) {
895 gclog_or_tty->print(" (promotion failed)");
896 }
897 // All the spaces are in play for mark-sweep.
898 swap_spaces(); // Make life simpler for CMS || rescan; see 6483690.
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
27 #include "gc_implementation/parNew/parNewGeneration.hpp"
28 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
29 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
30 #include "gc_implementation/shared/ageTable.hpp"
31 #include "gc_implementation/shared/copyFailedInfo.hpp"
32 #include "gc_implementation/shared/gcHeapSummary.hpp"
33 #include "gc_implementation/shared/gcTimer.hpp"
34 #include "gc_implementation/shared/gcTrace.hpp"
35 #include "gc_implementation/shared/gcTraceTime.hpp"
36 #include "gc_implementation/shared/parGCAllocBuffer.inline.hpp"
37 #include "gc_implementation/shared/spaceDecorator.hpp"
38 #include "gc_interface/collectedHeap.inline.hpp"
39 #include "memory/defNewGeneration.inline.hpp"
40 #include "memory/genCollectedHeap.inline.hpp"
41 #include "memory/genOopClosures.inline.hpp"
42 #include "memory/generation.hpp"
43 #include "memory/generation.inline.hpp"
44 #include "memory/referencePolicy.hpp"
45 #include "memory/resourceArea.hpp"
46 #include "memory/sharedHeap.hpp"
47 #include "memory/space.hpp"
48 #include "oops/objArrayOop.inline.hpp"
49 #include "oops/oop.inline.hpp"
50 #include "oops/oop.pcgc.inline.hpp"
51 #include "runtime/atomic.inline.hpp"
52 #include "runtime/handles.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/java.hpp"
55 #include "runtime/thread.inline.hpp"
56 #include "utilities/copy.hpp"
57 #include "utilities/globalDefinitions.hpp"
58 #include "utilities/workgroup.hpp"
59
60 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
61
62 #ifdef _MSC_VER
63 #pragma warning( push )
64 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
65 #endif
66 ParScanThreadState::ParScanThreadState(Space* to_space_,
67 ParNewGeneration* gen_,
68 Generation* old_gen_,
132 int remainder = end - start;
133 assert(start <= end, "just checking");
134 if (remainder > 2 * ParGCArrayScanChunk) {
135 // Test above combines last partial chunk with a full chunk
136 end = start + ParGCArrayScanChunk;
137 arrayOop(old)->set_length(end);
138 // Push remainder.
139 bool ok = work_queue()->push(old);
140 assert(ok, "just popped, push must be okay");
141 } else {
142 // Restore length so that it can be used if there
143 // is a promotion failure and forwarding pointers
144 // must be removed.
145 arrayOop(old)->set_length(end);
146 }
147
148 // process our set of indices (include header in first chunk)
149 // should make sure end is even (aligned to HeapWord in case of compressed oops)
150 if ((HeapWord *)obj < young_old_boundary()) {
151 // object is in to_space
152 obj->oop_iterate_range_t<true>(&_to_space_closure, start, end);
153 } else {
154 // object is in old generation
155 obj->oop_iterate_range_t<true>(&_old_gen_closure, start, end);
156 }
157 }
158
159
160 void ParScanThreadState::trim_queues(int max_size) {
161 ObjToScanQueue* queue = work_queue();
162 do {
163 while (queue->size() > (juint)max_size) {
164 oop obj_to_scan;
165 if (queue->pop_local(obj_to_scan)) {
166 if ((HeapWord *)obj_to_scan < young_old_boundary()) {
167 if (obj_to_scan->is_objArray() &&
168 obj_to_scan->is_forwarded() &&
169 obj_to_scan->forwardee() != obj_to_scan) {
170 scan_partial_array_and_push_remainder(obj_to_scan);
171 } else {
172 // object is in to_space
173 obj_to_scan->oop_iterate(&_to_space_closure);
174 }
175 } else {
859 gch->set_par_threads(0); // 0 ==> non-parallel.
860 gch->save_marks();
861 }
862
863 ScanClosureWithParBarrier::
864 ScanClosureWithParBarrier(ParNewGeneration* g, bool gc_barrier) :
865 ScanClosure(g, gc_barrier) {}
866
867 EvacuateFollowersClosureGeneral::
868 EvacuateFollowersClosureGeneral(GenCollectedHeap* gch, int level,
869 OopsInGenClosure* cur,
870 OopsInGenClosure* older) :
871 _gch(gch), _level(level),
872 _scan_cur_or_nonheap(cur), _scan_older(older)
873 {}
874
875 void EvacuateFollowersClosureGeneral::do_void() {
876 do {
877 // Beware: this call will lead to closure applications via virtual
878 // calls.
879 _gch->gch_oop_since_save_marks_iterate<false>(_level,
880 _scan_cur_or_nonheap,
881 _scan_older);
882 } while (!_gch->no_allocs_since_save_marks(_level));
883 }
884
885
886 // A Generation that does parallel young-gen collection.
887
888 bool ParNewGeneration::_avoid_promotion_undo = false;
889
890 void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer) {
891 assert(_promo_failure_scan_stack.is_empty(), "post condition");
892 _promo_failure_scan_stack.clear(true); // Clear cached segments.
893
894 remove_forwarding_pointers();
895 if (PrintGCDetails) {
896 gclog_or_tty->print(" (promotion failed)");
897 }
898 // All the spaces are in play for mark-sweep.
899 swap_spaces(); // Make life simpler for CMS || rescan; see 6483690.
|