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
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.
|
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 #include "utilities/debug.hpp"
49
50 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = nullptr;
51 PSPromotionManager::PSScannerTasksQueueSet* PSPromotionManager::_stack_array_depth = nullptr;
52 PreservedMarksSet* PSPromotionManager::_preserved_marks_set = nullptr;
53 PSOldGen* PSPromotionManager::_old_gen = nullptr;
54 MutableSpace* PSPromotionManager::_young_space = nullptr;
55 PartialArrayStateManager* PSPromotionManager::_partial_array_state_manager = nullptr;
56
57 void PSPromotionManager::initialize() {
58 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
59
60 _old_gen = heap->old_gen();
61 _young_space = heap->young_gen()->to_space();
62
63 const uint promotion_manager_num = ParallelGCThreads;
64
65 assert(_partial_array_state_manager == nullptr, "Attempt to initialize twice");
66 _partial_array_state_manager
67 = new PartialArrayStateManager(promotion_manager_num);
68
243 assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity");
244 if (!_old_lab.is_flushed())
245 _old_lab.flush();
246
247 // Let PSScavenge know if we overflowed
248 if (_young_gen_is_full || _young_gen_has_alloc_failure) {
249 PSScavenge::set_survivor_overflow(true);
250 }
251 }
252
253 void PSPromotionManager::process_array_chunk(objArrayOop obj, size_t start, size_t end) {
254 PSPushContentsClosure pcc(this);
255 obj->oop_iterate_elements_range(&pcc,
256 checked_cast<int>(start),
257 checked_cast<int>(end));
258 }
259
260 void PSPromotionManager::process_array_chunk(PartialArrayState* state, bool stolen) {
261 // Access before release by claim().
262 objArrayOop to_array = objArrayOop(state->destination());
263 precond(to_array->is_array_with_oops());
264
265 PartialArraySplitter::Claim claim =
266 _partial_array_splitter.claim(state, &_claimed_stack_depth, stolen);
267
268 process_array_chunk(to_array, claim._start, claim._end);
269 }
270
271 void PSPromotionManager::push_objArray(oop old_obj, oop new_obj) {
272 assert(old_obj->is_forwarded(), "precondition");
273 assert(old_obj->forwardee() == new_obj, "precondition");
274 precond(new_obj->is_array_with_oops());
275
276 objArrayOop to_array = objArrayOop(new_obj);
277 size_t array_length = to_array->length();
278 size_t initial_chunk_size =
279 // The source array is unused when processing states.
280 _partial_array_splitter.start(&_claimed_stack_depth, nullptr, to_array, array_length);
281
282 process_array_chunk(to_array, 0, initial_chunk_size);
283 }
284
285 oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) {
286 assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
287
288 // Attempt to CAS in the header.
289 // This tests if the header is still the same as when
290 // this started. If it is the same (i.e., no forwarding
291 // pointer has been installed), then this thread owns
292 // it.
293 if (obj->forward_to_self_atomic(obj_mark) == nullptr) {
294 // We won any races, we "own" this object.
|