77 }
78
79 void PSPromotionManager::pre_scavenge() {
80 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
81 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
82
83 _young_space = heap->young_gen()->to_space();
84
85 for(uint i=0; i<ParallelGCThreads+1; i++) {
86 manager_array(i)->reset();
87 }
88 }
89
90 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
91 bool promotion_failure_occurred = false;
92
93 TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats());
94 for (uint i = 0; i < ParallelGCThreads + 1; i++) {
95 PSPromotionManager* manager = manager_array(i);
96 assert(manager->claimed_stack_depth()->is_empty(), "should be empty");
97 if (manager->_promotion_failed_info.promotion_failed()) {
98 gc_tracer.report_promotion_failed(manager->_promotion_failed_info);
99 promotion_failure_occurred = true;
100 }
101 manager->flush_labs();
102 }
103 return promotion_failure_occurred;
104 }
105
106 #if TASKQUEUE_STATS
107 void
108 PSPromotionManager::print_taskqueue_stats(uint i) const {
109 tty->print("%3u ", i);
110 _claimed_stack_depth.stats.print();
111 tty->cr();
112 }
113
114 void
115 PSPromotionManager::print_local_stats(uint i) const {
116 #define FMT " " SIZE_FORMAT_W(10)
117 tty->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals,
299
300 if (UseCompressedOops) {
301 process_array_chunk_work<narrowOop>(obj, start, end);
302 } else {
303 process_array_chunk_work<oop>(obj, start, end);
304 }
305 }
306
307 oop PSPromotionManager::oop_promotion_failed(oop obj, markOop obj_mark) {
308 assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
309
310 // Attempt to CAS in the header.
311 // This tests if the header is still the same as when
312 // this started. If it is the same (i.e., no forwarding
313 // pointer has been installed), then this thread owns
314 // it.
315 if (obj->cas_forward_to(obj, obj_mark)) {
316 // We won any races, we "own" this object.
317 assert(obj == obj->forwardee(), "Sanity");
318
319 _promotion_failed_info.register_promotion_failed(obj->size());
320
321 obj->push_contents(this);
322
323 // Save the mark if needed
324 PSScavenge::oop_promotion_failed(obj, obj_mark);
325 } else {
326 // We lost, someone else "owns" this object
327 guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed.");
328
329 // No unallocation to worry about.
330 obj = obj->forwardee();
331 }
332
333 #ifdef DEBUG
334 if (TraceScavenge) {
335 gclog_or_tty->print_cr("{%s %s 0x%x (%d)}",
336 "promotion-failure",
337 obj->blueprint()->internal_name(),
338 obj, obj->size());
339
|
77 }
78
79 void PSPromotionManager::pre_scavenge() {
80 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
81 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
82
83 _young_space = heap->young_gen()->to_space();
84
85 for(uint i=0; i<ParallelGCThreads+1; i++) {
86 manager_array(i)->reset();
87 }
88 }
89
90 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
91 bool promotion_failure_occurred = false;
92
93 TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats());
94 for (uint i = 0; i < ParallelGCThreads + 1; i++) {
95 PSPromotionManager* manager = manager_array(i);
96 assert(manager->claimed_stack_depth()->is_empty(), "should be empty");
97 if (manager->_promotion_failed_info.has_failed()) {
98 gc_tracer.report_promotion_failed(manager->_promotion_failed_info);
99 promotion_failure_occurred = true;
100 }
101 manager->flush_labs();
102 }
103 return promotion_failure_occurred;
104 }
105
106 #if TASKQUEUE_STATS
107 void
108 PSPromotionManager::print_taskqueue_stats(uint i) const {
109 tty->print("%3u ", i);
110 _claimed_stack_depth.stats.print();
111 tty->cr();
112 }
113
114 void
115 PSPromotionManager::print_local_stats(uint i) const {
116 #define FMT " " SIZE_FORMAT_W(10)
117 tty->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals,
299
300 if (UseCompressedOops) {
301 process_array_chunk_work<narrowOop>(obj, start, end);
302 } else {
303 process_array_chunk_work<oop>(obj, start, end);
304 }
305 }
306
307 oop PSPromotionManager::oop_promotion_failed(oop obj, markOop obj_mark) {
308 assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
309
310 // Attempt to CAS in the header.
311 // This tests if the header is still the same as when
312 // this started. If it is the same (i.e., no forwarding
313 // pointer has been installed), then this thread owns
314 // it.
315 if (obj->cas_forward_to(obj, obj_mark)) {
316 // We won any races, we "own" this object.
317 assert(obj == obj->forwardee(), "Sanity");
318
319 _promotion_failed_info.register_copy_failure(obj->size());
320
321 obj->push_contents(this);
322
323 // Save the mark if needed
324 PSScavenge::oop_promotion_failed(obj, obj_mark);
325 } else {
326 // We lost, someone else "owns" this object
327 guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed.");
328
329 // No unallocation to worry about.
330 obj = obj->forwardee();
331 }
332
333 #ifdef DEBUG
334 if (TraceScavenge) {
335 gclog_or_tty->print_cr("{%s %s 0x%x (%d)}",
336 "promotion-failure",
337 obj->blueprint()->internal_name(),
338 obj, obj->size());
339
|