3259 size_t bytes_before = capacity();
3260 // No need for an ergo logging here,
3261 // expansion_amount() does this when it returns a value > 0.
3262 double expand_ms;
3263 if (!expand(expand_bytes, _workers, &expand_ms)) {
3264 // We failed to expand the heap. Cannot do anything about it.
3265 }
3266 g1_policy()->phase_times()->record_expand_heap_time(expand_ms);
3267 }
3268 }
3269
3270 // We redo the verification but now wrt to the new CSet which
3271 // has just got initialized after the previous CSet was freed.
3272 _cm->verify_no_cset_oops();
3273
3274 // This timing is only used by the ergonomics to handle our pause target.
3275 // It is unclear why this should not include the full pause. We will
3276 // investigate this in CR 7178365.
3277 double sample_end_time_sec = os::elapsedTime();
3278 double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
3279 size_t total_cards_scanned = per_thread_states.total_cards_scanned();
3280 g1_policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
3281
3282 evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
3283 evacuation_info.set_bytes_copied(g1_policy()->bytes_copied_during_gc());
3284
3285 MemoryService::track_memory_usage();
3286
3287 // In prepare_for_verify() below we'll need to scan the deferred
3288 // update buffers to bring the RSets up-to-date if
3289 // G1HRRSFlushLogBuffersOnVerify has been set. While scanning
3290 // the update buffers we'll probably need to scan cards on the
3291 // regions we just allocated to (i.e., the GC alloc
3292 // regions). However, during the last GC we called
3293 // set_saved_mark() on all the GC alloc regions, so card
3294 // scanning might skip the [saved_mark_word()...top()] area of
3295 // those regions (i.e., the area we allocated objects into
3296 // during the last GC). But it shouldn't. Given that
3297 // saved_mark_word() is conditional on whether the GC time stamp
3298 // on the region is current or not, by incrementing the GC time
3299 // stamp here we invalidate all the GC time stamps on all the
3449
3450 {
3451 ResourceMark rm;
3452 HandleMark hm;
3453
3454 ReferenceProcessor* rp = _g1h->ref_processor_stw();
3455
3456 G1ParScanThreadState* pss = _pss->state_for_worker(worker_id);
3457 pss->set_ref_processor(rp);
3458
3459 double start_strong_roots_sec = os::elapsedTime();
3460
3461 _root_processor->evacuate_roots(pss->closures(), worker_id);
3462
3463 G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, pss);
3464
3465 // We pass a weak code blobs closure to the remembered set scanning because we want to avoid
3466 // treating the nmethods visited to act as roots for concurrent marking.
3467 // We only want to make sure that the oops in the nmethods are adjusted with regard to the
3468 // objects copied by the current evacuation.
3469 size_t cards_scanned = _g1h->g1_rem_set()->oops_into_collection_set_do(&push_heap_rs_cl,
3470 pss->closures()->weak_codeblobs(),
3471 worker_id);
3472
3473 _pss->add_cards_scanned(worker_id, cards_scanned);
3474
3475 double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
3476
3477 double term_sec = 0.0;
3478 size_t evac_term_attempts = 0;
3479 {
3480 double start = os::elapsedTime();
3481 G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, &_terminator);
3482 evac.do_void();
3483
3484 evac_term_attempts = evac.term_attempts();
3485 term_sec = evac.term_time();
3486 double elapsed_sec = os::elapsedTime() - start;
3487 _g1h->g1_policy()->phase_times()->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
3488 _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::Termination, worker_id, term_sec);
3489 _g1h->g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, evac_term_attempts);
3490 }
3491
3492 assert(pss->queue_is_empty(), "should be empty");
3493
|
3259 size_t bytes_before = capacity();
3260 // No need for an ergo logging here,
3261 // expansion_amount() does this when it returns a value > 0.
3262 double expand_ms;
3263 if (!expand(expand_bytes, _workers, &expand_ms)) {
3264 // We failed to expand the heap. Cannot do anything about it.
3265 }
3266 g1_policy()->phase_times()->record_expand_heap_time(expand_ms);
3267 }
3268 }
3269
3270 // We redo the verification but now wrt to the new CSet which
3271 // has just got initialized after the previous CSet was freed.
3272 _cm->verify_no_cset_oops();
3273
3274 // This timing is only used by the ergonomics to handle our pause target.
3275 // It is unclear why this should not include the full pause. We will
3276 // investigate this in CR 7178365.
3277 double sample_end_time_sec = os::elapsedTime();
3278 double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
3279 size_t total_cards_scanned = g1_policy()->phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScannedCards);
3280 g1_policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
3281
3282 evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
3283 evacuation_info.set_bytes_copied(g1_policy()->bytes_copied_during_gc());
3284
3285 MemoryService::track_memory_usage();
3286
3287 // In prepare_for_verify() below we'll need to scan the deferred
3288 // update buffers to bring the RSets up-to-date if
3289 // G1HRRSFlushLogBuffersOnVerify has been set. While scanning
3290 // the update buffers we'll probably need to scan cards on the
3291 // regions we just allocated to (i.e., the GC alloc
3292 // regions). However, during the last GC we called
3293 // set_saved_mark() on all the GC alloc regions, so card
3294 // scanning might skip the [saved_mark_word()...top()] area of
3295 // those regions (i.e., the area we allocated objects into
3296 // during the last GC). But it shouldn't. Given that
3297 // saved_mark_word() is conditional on whether the GC time stamp
3298 // on the region is current or not, by incrementing the GC time
3299 // stamp here we invalidate all the GC time stamps on all the
3449
3450 {
3451 ResourceMark rm;
3452 HandleMark hm;
3453
3454 ReferenceProcessor* rp = _g1h->ref_processor_stw();
3455
3456 G1ParScanThreadState* pss = _pss->state_for_worker(worker_id);
3457 pss->set_ref_processor(rp);
3458
3459 double start_strong_roots_sec = os::elapsedTime();
3460
3461 _root_processor->evacuate_roots(pss->closures(), worker_id);
3462
3463 G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, pss);
3464
3465 // We pass a weak code blobs closure to the remembered set scanning because we want to avoid
3466 // treating the nmethods visited to act as roots for concurrent marking.
3467 // We only want to make sure that the oops in the nmethods are adjusted with regard to the
3468 // objects copied by the current evacuation.
3469 _g1h->g1_rem_set()->oops_into_collection_set_do(&push_heap_rs_cl,
3470 pss->closures()->weak_codeblobs(),
3471 worker_id);
3472
3473 double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
3474
3475 double term_sec = 0.0;
3476 size_t evac_term_attempts = 0;
3477 {
3478 double start = os::elapsedTime();
3479 G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, &_terminator);
3480 evac.do_void();
3481
3482 evac_term_attempts = evac.term_attempts();
3483 term_sec = evac.term_time();
3484 double elapsed_sec = os::elapsedTime() - start;
3485 _g1h->g1_policy()->phase_times()->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
3486 _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::Termination, worker_id, term_sec);
3487 _g1h->g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, evac_term_attempts);
3488 }
3489
3490 assert(pss->queue_is_empty(), "should be empty");
3491
|