3703
3704 return false;
3705 }
3706
3707 size_t total_humongous() const { return _total_humongous; }
3708 size_t candidate_humongous() const { return _candidate_humongous; }
3709 };
3710
3711 void G1CollectedHeap::register_humongous_regions_with_in_cset_fast_test() {
3712 if (!G1ReclaimDeadHumongousObjectsAtYoungGC) {
3713 g1_policy()->phase_times()->record_fast_reclaim_humongous_stats(0, 0);
3714 return;
3715 }
3716
3717 RegisterHumongousWithInCSetFastTestClosure cl;
3718 heap_region_iterate(&cl);
3719 g1_policy()->phase_times()->record_fast_reclaim_humongous_stats(cl.total_humongous(),
3720 cl.candidate_humongous());
3721 _has_humongous_reclaim_candidates = cl.candidate_humongous() > 0;
3722
3723 if (_has_humongous_reclaim_candidates) {
3724 clear_humongous_is_live_table();
3725 }
3726 }
3727
3728 void
3729 G1CollectedHeap::setup_surviving_young_words() {
3730 assert(_surviving_young_words == NULL, "pre-condition");
3731 uint array_length = g1_policy()->young_cset_region_length();
3732 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
3733 if (_surviving_young_words == NULL) {
3734 vm_exit_out_of_memory(sizeof(size_t) * array_length, OOM_MALLOC_ERROR,
3735 "Not enough space for young surv words summary.");
3736 }
3737 memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
3738 #ifdef ASSERT
3739 for (uint i = 0; i < array_length; ++i) {
3740 assert( _surviving_young_words[i] == 0, "memset above" );
3741 }
3742 #endif // !ASSERT
3743 }
6403 // all objects allocated during that time are considered live.
6404 // SATB marking is even more conservative than the remembered set.
6405 // So if at this point in the collection there is no remembered set entry,
6406 // nobody has a reference to it.
6407 // At the start of collection we flush all refinement logs, and remembered sets
6408 // are completely up-to-date wrt to references to the humongous object.
6409 //
6410 // Other implementation considerations:
6411 // - never consider object arrays: while they are a valid target, they have not
6412 // been observed to be used as temporary objects.
6413 // - they would also pose considerable effort for cleaning up the the remembered
6414 // sets.
6415 // While this cleanup is not strictly necessary to be done (or done instantly),
6416 // given that their occurrence is very low, this saves us this additional
6417 // complexity.
6418 uint region_idx = r->hrm_index();
6419 if (g1h->humongous_is_live(region_idx) ||
6420 g1h->humongous_region_is_always_live(region_idx)) {
6421
6422 if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
6423 gclog_or_tty->print_cr("Live humongous %d region %d with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
6424 r->isHumongous(),
6425 region_idx,
6426 r->rem_set()->occupied(),
6427 r->rem_set()->strong_code_roots_list_length(),
6428 next_bitmap->isMarked(r->bottom()),
6429 g1h->humongous_is_live(region_idx),
6430 obj->is_objArray()
6431 );
6432 }
6433
6434 return false;
6435 }
6436
6437 guarantee(!obj->is_objArray(),
6438 err_msg("Eagerly reclaiming object arrays is not supported, but the object "PTR_FORMAT" is.",
6439 r->bottom()));
6440
6441 if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
6442 gclog_or_tty->print_cr("Reclaim humongous region %d start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
6443 r->isHumongous(),
6444 r->bottom(),
6445 region_idx,
6446 r->region_num(),
6447 r->rem_set()->occupied(),
6448 r->rem_set()->strong_code_roots_list_length(),
6449 next_bitmap->isMarked(r->bottom()),
6450 g1h->humongous_is_live(region_idx),
6451 obj->is_objArray()
6452 );
6453 }
6454 // Need to clear mark bit of the humongous object if already set.
6455 if (next_bitmap->isMarked(r->bottom())) {
6456 next_bitmap->clear(r->bottom());
6457 }
6458 _freed_bytes += r->used();
6459 r->set_containing_set(NULL);
6460 _humongous_regions_removed.increment(1u, r->capacity());
6461 g1h->free_humongous_region(r, _free_region_list, false);
6462
6463 return false;
6464 }
6465
6466 HeapRegionSetCount& humongous_free_count() {
6467 return _humongous_regions_removed;
6468 }
6469
6470 size_t bytes_freed() const {
6471 return _freed_bytes;
6472 }
6473
6474 size_t humongous_reclaimed() const {
6475 return _humongous_regions_removed.length();
6476 }
6477 };
6478
6479 void G1CollectedHeap::eagerly_reclaim_humongous_regions() {
6480 assert_at_safepoint(true);
6481
6482 if (!G1ReclaimDeadHumongousObjectsAtYoungGC || !_has_humongous_reclaim_candidates) {
6483 g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0);
6484 return;
6485 }
6486
6487 double start_time = os::elapsedTime();
6488
6489 FreeRegionList local_cleanup_list("Local Humongous Cleanup List");
6490
6491 G1FreeHumongousRegionClosure cl(&local_cleanup_list);
6492 heap_region_iterate(&cl);
6493
6494 HeapRegionSetCount empty_set;
6495 remove_from_old_sets(empty_set, cl.humongous_free_count());
6496
6497 G1HRPrinter* hr_printer = _g1h->hr_printer();
6498 if (hr_printer->is_active()) {
6499 FreeRegionListIterator iter(&local_cleanup_list);
6500 while (iter.more_available()) {
6501 HeapRegion* hr = iter.get_next();
6502 hr_printer->cleanup(hr);
|
3703
3704 return false;
3705 }
3706
3707 size_t total_humongous() const { return _total_humongous; }
3708 size_t candidate_humongous() const { return _candidate_humongous; }
3709 };
3710
3711 void G1CollectedHeap::register_humongous_regions_with_in_cset_fast_test() {
3712 if (!G1ReclaimDeadHumongousObjectsAtYoungGC) {
3713 g1_policy()->phase_times()->record_fast_reclaim_humongous_stats(0, 0);
3714 return;
3715 }
3716
3717 RegisterHumongousWithInCSetFastTestClosure cl;
3718 heap_region_iterate(&cl);
3719 g1_policy()->phase_times()->record_fast_reclaim_humongous_stats(cl.total_humongous(),
3720 cl.candidate_humongous());
3721 _has_humongous_reclaim_candidates = cl.candidate_humongous() > 0;
3722
3723 if (_has_humongous_reclaim_candidates || G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
3724 clear_humongous_is_live_table();
3725 }
3726 }
3727
3728 void
3729 G1CollectedHeap::setup_surviving_young_words() {
3730 assert(_surviving_young_words == NULL, "pre-condition");
3731 uint array_length = g1_policy()->young_cset_region_length();
3732 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
3733 if (_surviving_young_words == NULL) {
3734 vm_exit_out_of_memory(sizeof(size_t) * array_length, OOM_MALLOC_ERROR,
3735 "Not enough space for young surv words summary.");
3736 }
3737 memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
3738 #ifdef ASSERT
3739 for (uint i = 0; i < array_length; ++i) {
3740 assert( _surviving_young_words[i] == 0, "memset above" );
3741 }
3742 #endif // !ASSERT
3743 }
6403 // all objects allocated during that time are considered live.
6404 // SATB marking is even more conservative than the remembered set.
6405 // So if at this point in the collection there is no remembered set entry,
6406 // nobody has a reference to it.
6407 // At the start of collection we flush all refinement logs, and remembered sets
6408 // are completely up-to-date wrt to references to the humongous object.
6409 //
6410 // Other implementation considerations:
6411 // - never consider object arrays: while they are a valid target, they have not
6412 // been observed to be used as temporary objects.
6413 // - they would also pose considerable effort for cleaning up the the remembered
6414 // sets.
6415 // While this cleanup is not strictly necessary to be done (or done instantly),
6416 // given that their occurrence is very low, this saves us this additional
6417 // complexity.
6418 uint region_idx = r->hrm_index();
6419 if (g1h->humongous_is_live(region_idx) ||
6420 g1h->humongous_region_is_always_live(region_idx)) {
6421
6422 if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
6423 gclog_or_tty->print_cr("Live humongous %d region %d size "SIZE_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
6424 r->isHumongous(),
6425 region_idx,
6426 obj->size()*HeapWordSize,
6427 r->rem_set()->occupied(),
6428 r->rem_set()->strong_code_roots_list_length(),
6429 next_bitmap->isMarked(r->bottom()),
6430 g1h->humongous_is_live(region_idx),
6431 obj->is_objArray()
6432 );
6433 }
6434
6435 return false;
6436 }
6437
6438 guarantee(!obj->is_objArray(),
6439 err_msg("Eagerly reclaiming object arrays is not supported, but the object "PTR_FORMAT" is.",
6440 r->bottom()));
6441
6442 if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
6443 gclog_or_tty->print_cr("Reclaim humongous region %d size "SIZE_FORMAT" start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other ",
6444 r->isHumongous(),
6445 obj->size()*HeapWordSize,
6446 r->bottom(),
6447 region_idx,
6448 r->region_num(),
6449 r->rem_set()->occupied(),
6450 r->rem_set()->strong_code_roots_list_length(),
6451 next_bitmap->isMarked(r->bottom()),
6452 g1h->humongous_is_live(region_idx),
6453 obj->is_objArray()
6454 );
6455 }
6456 // Need to clear mark bit of the humongous object if already set.
6457 if (next_bitmap->isMarked(r->bottom())) {
6458 next_bitmap->clear(r->bottom());
6459 }
6460 _freed_bytes += r->used();
6461 r->set_containing_set(NULL);
6462 _humongous_regions_removed.increment(1u, r->capacity());
6463 g1h->free_humongous_region(r, _free_region_list, false);
6464
6465 return false;
6466 }
6467
6468 HeapRegionSetCount& humongous_free_count() {
6469 return _humongous_regions_removed;
6470 }
6471
6472 size_t bytes_freed() const {
6473 return _freed_bytes;
6474 }
6475
6476 size_t humongous_reclaimed() const {
6477 return _humongous_regions_removed.length();
6478 }
6479 };
6480
6481 void G1CollectedHeap::eagerly_reclaim_humongous_regions() {
6482 assert_at_safepoint(true);
6483
6484 if (!G1ReclaimDeadHumongousObjectsAtYoungGC ||
6485 (!_has_humongous_reclaim_candidates && !G1TraceReclaimDeadHumongousObjectsAtYoungGC)) {
6486 g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0);
6487 return;
6488 }
6489
6490 double start_time = os::elapsedTime();
6491
6492 FreeRegionList local_cleanup_list("Local Humongous Cleanup List");
6493
6494 G1FreeHumongousRegionClosure cl(&local_cleanup_list);
6495 heap_region_iterate(&cl);
6496
6497 HeapRegionSetCount empty_set;
6498 remove_from_old_sets(empty_set, cl.humongous_free_count());
6499
6500 G1HRPrinter* hr_printer = _g1h->hr_printer();
6501 if (hr_printer->is_active()) {
6502 FreeRegionListIterator iter(&local_cleanup_list);
6503 while (iter.more_available()) {
6504 HeapRegion* hr = iter.get_next();
6505 hr_printer->cleanup(hr);
|