26 #include "gc/parallel/mutableSpace.hpp"
27 #include "gc/parallel/parallelScavengeHeap.hpp"
28 #include "gc/parallel/psOldGen.hpp"
29 #include "gc/parallel/psPromotionManager.inline.hpp"
30 #include "gc/parallel/psScavenge.hpp"
31 #include "gc/shared/continuationGCSupport.inline.hpp"
32 #include "gc/shared/gcTrace.hpp"
33 #include "gc/shared/partialArraySplitter.inline.hpp"
34 #include "gc/shared/partialArrayState.hpp"
35 #include "gc/shared/preservedMarks.inline.hpp"
36 #include "gc/shared/taskqueue.inline.hpp"
37 #include "logging/log.hpp"
38 #include "logging/logStream.hpp"
39 #include "memory/allocation.inline.hpp"
40 #include "memory/iterator.inline.hpp"
41 #include "memory/memRegion.hpp"
42 #include "memory/padded.inline.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "oops/access.inline.hpp"
45 #include "oops/compressedOops.inline.hpp"
46 #include "oops/oopsHierarchy.hpp"
47 #include "utilities/checkedCast.hpp"
48
49 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = nullptr;
50 PSPromotionManager::PSScannerTasksQueueSet* PSPromotionManager::_stack_array_depth = nullptr;
51 PreservedMarksSet* PSPromotionManager::_preserved_marks_set = nullptr;
52 PSOldGen* PSPromotionManager::_old_gen = nullptr;
53 MutableSpace* PSPromotionManager::_young_space = nullptr;
54 PartialArrayStateManager* PSPromotionManager::_partial_array_state_manager = nullptr;
55
56 void PSPromotionManager::initialize() {
57 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
58
59 _old_gen = heap->old_gen();
60 _young_space = heap->young_gen()->to_space();
61
62 const uint promotion_manager_num = ParallelGCThreads;
63
64 assert(_partial_array_state_manager == nullptr, "Attempt to initialize twice");
65 _partial_array_state_manager
66 = new PartialArrayStateManager(promotion_manager_num);
67
241
242 assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity");
243 if (!_old_lab.is_flushed())
244 _old_lab.flush();
245
246 // Let PSScavenge know if we overflowed
247 if (_young_gen_is_full || _young_gen_has_alloc_failure) {
248 PSScavenge::set_survivor_overflow(true);
249 }
250 }
251
252 void PSPromotionManager::process_array_chunk(objArrayOop obj, size_t start, size_t end) {
253 PSPushContentsClosure pcc(this);
254 obj->oop_iterate_elements_range(&pcc,
255 checked_cast<int>(start),
256 checked_cast<int>(end));
257 }
258
259 void PSPromotionManager::process_array_chunk(PartialArrayState* state, bool stolen) {
260 // Access before release by claim().
261 objArrayOop to_array = objArrayOop(state->destination());
262 PartialArraySplitter::Claim claim =
263 _partial_array_splitter.claim(state, &_claimed_stack_depth, stolen);
264 process_array_chunk(to_array, claim._start, claim._end);
265 }
266
267 void PSPromotionManager::push_objArray(oop old_obj, oop new_obj) {
268 assert(old_obj->is_forwarded(), "precondition");
269 assert(old_obj->forwardee() == new_obj, "precondition");
270 assert(new_obj->is_objArray(), "precondition");
271
272 objArrayOop to_array = objArrayOop(new_obj);
273 size_t array_length = to_array->length();
274 size_t initial_chunk_size =
275 // The source array is unused when processing states.
276 _partial_array_splitter.start(&_claimed_stack_depth, nullptr, to_array, array_length);
277
278 process_array_chunk(to_array, 0, initial_chunk_size);
279 }
280
281 oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) {
282 assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
283
284 // Attempt to CAS in the header.
285 // This tests if the header is still the same as when
286 // this started. If it is the same (i.e., no forwarding
287 // pointer has been installed), then this thread owns
288 // it.
289 if (obj->forward_to_self_atomic(obj_mark) == nullptr) {
290 // We won any races, we "own" this object.
|
26 #include "gc/parallel/mutableSpace.hpp"
27 #include "gc/parallel/parallelScavengeHeap.hpp"
28 #include "gc/parallel/psOldGen.hpp"
29 #include "gc/parallel/psPromotionManager.inline.hpp"
30 #include "gc/parallel/psScavenge.hpp"
31 #include "gc/shared/continuationGCSupport.inline.hpp"
32 #include "gc/shared/gcTrace.hpp"
33 #include "gc/shared/partialArraySplitter.inline.hpp"
34 #include "gc/shared/partialArrayState.hpp"
35 #include "gc/shared/preservedMarks.inline.hpp"
36 #include "gc/shared/taskqueue.inline.hpp"
37 #include "logging/log.hpp"
38 #include "logging/logStream.hpp"
39 #include "memory/allocation.inline.hpp"
40 #include "memory/iterator.inline.hpp"
41 #include "memory/memRegion.hpp"
42 #include "memory/padded.inline.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "oops/access.inline.hpp"
45 #include "oops/compressedOops.inline.hpp"
46 #include "oops/flatArrayKlass.inline.hpp"
47 #include "oops/oopCast.inline.hpp"
48 #include "oops/oopsHierarchy.hpp"
49 #include "utilities/checkedCast.hpp"
50 #include "utilities/debug.hpp"
51
52 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = nullptr;
53 PSPromotionManager::PSScannerTasksQueueSet* PSPromotionManager::_stack_array_depth = nullptr;
54 PreservedMarksSet* PSPromotionManager::_preserved_marks_set = nullptr;
55 PSOldGen* PSPromotionManager::_old_gen = nullptr;
56 MutableSpace* PSPromotionManager::_young_space = nullptr;
57 PartialArrayStateManager* PSPromotionManager::_partial_array_state_manager = nullptr;
58
59 void PSPromotionManager::initialize() {
60 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
61
62 _old_gen = heap->old_gen();
63 _young_space = heap->young_gen()->to_space();
64
65 const uint promotion_manager_num = ParallelGCThreads;
66
67 assert(_partial_array_state_manager == nullptr, "Attempt to initialize twice");
68 _partial_array_state_manager
69 = new PartialArrayStateManager(promotion_manager_num);
70
244
245 assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity");
246 if (!_old_lab.is_flushed())
247 _old_lab.flush();
248
249 // Let PSScavenge know if we overflowed
250 if (_young_gen_is_full || _young_gen_has_alloc_failure) {
251 PSScavenge::set_survivor_overflow(true);
252 }
253 }
254
255 void PSPromotionManager::process_array_chunk(objArrayOop obj, size_t start, size_t end) {
256 PSPushContentsClosure pcc(this);
257 obj->oop_iterate_elements_range(&pcc,
258 checked_cast<int>(start),
259 checked_cast<int>(end));
260 }
261
262 void PSPromotionManager::process_array_chunk(PartialArrayState* state, bool stolen) {
263 // Access before release by claim().
264 objArrayOop to_array = oop_cast<objArrayOop>(state->destination());
265 precond(to_array->is_array_with_oops());
266
267 PartialArraySplitter::Claim claim =
268 _partial_array_splitter.claim(state, &_claimed_stack_depth, stolen);
269
270 process_array_chunk(to_array, claim._start, claim._end);
271 }
272
273 void PSPromotionManager::push_objArray(oop old_obj, oop new_obj) {
274 assert(old_obj->is_forwarded(), "precondition");
275 assert(old_obj->forwardee() == new_obj, "precondition");
276 precond(new_obj->is_array_with_oops());
277
278 objArrayOop to_array = objArrayOop(new_obj);
279 size_t array_length = to_array->length();
280 size_t initial_chunk_size =
281 // The source array is unused when processing states.
282 _partial_array_splitter.start(&_claimed_stack_depth, nullptr, to_array, array_length);
283
284 process_array_chunk(to_array, 0, initial_chunk_size);
285 }
286
287 oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) {
288 assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
289
290 // Attempt to CAS in the header.
291 // This tests if the header is still the same as when
292 // this started. If it is the same (i.e., no forwarding
293 // pointer has been installed), then this thread owns
294 // it.
295 if (obj->forward_to_self_atomic(obj_mark) == nullptr) {
296 // We won any races, we "own" this object.
|