1814
1815 if (_hr_printer.is_active()) {
1816 HeapWord* curr = mr.start();
1817 while (curr < mr.end()) {
1818 HeapWord* curr_end = curr + HeapRegion::GrainWords;
1819 _hr_printer.commit(curr, curr_end);
1820 curr = curr_end;
1821 }
1822 assert(curr == mr.end(), "post-condition");
1823 }
1824 g1_policy()->record_new_heap_size(n_regions());
1825 } else {
1826 ergo_verbose0(ErgoHeapSizing,
1827 "did not expand the heap",
1828 ergo_format_reason("heap expansion operation failed"));
1829 // The expansion of the virtual storage space was unsuccessful.
1830 // Let's see if it was because we ran out of swap.
1831 if (G1ExitOnExpansionFailure &&
1832 _g1_storage.uncommitted_size() >= aligned_expand_bytes) {
1833 // We had head room...
1834 vm_exit_out_of_memory(aligned_expand_bytes, "G1 heap expansion");
1835 }
1836 }
1837 return successful;
1838 }
1839
1840 void G1CollectedHeap::shrink_helper(size_t shrink_bytes) {
1841 size_t old_mem_size = _g1_storage.committed_size();
1842 size_t aligned_shrink_bytes =
1843 ReservedSpace::page_align_size_down(shrink_bytes);
1844 aligned_shrink_bytes = align_size_down(aligned_shrink_bytes,
1845 HeapRegion::GrainBytes);
1846 uint num_regions_deleted = 0;
1847 MemRegion mr = _hrs.shrink_by(aligned_shrink_bytes, &num_regions_deleted);
1848 HeapWord* old_end = (HeapWord*) _g1_storage.high();
1849 assert(mr.end() == old_end, "post-condition");
1850
1851 ergo_verbose3(ErgoHeapSizing,
1852 "shrink the heap",
1853 ergo_format_byte("requested shrinking amount")
1854 ergo_format_byte("aligned shrinking amount")
3597 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
3598 size_t buffer_size = dcqs.buffer_size();
3599 size_t buffer_num = dcqs.completed_buffers_num();
3600
3601 // PtrQueueSet::buffer_size() and PtrQueue:size() return sizes
3602 // in bytes - not the number of 'entries'. We need to convert
3603 // into a number of cards.
3604 return (buffer_size * buffer_num + extra_cards) / oopSize;
3605 }
3606
3607 size_t G1CollectedHeap::cards_scanned() {
3608 return g1_rem_set()->cardsScanned();
3609 }
3610
3611 void
3612 G1CollectedHeap::setup_surviving_young_words() {
3613 assert(_surviving_young_words == NULL, "pre-condition");
3614 uint array_length = g1_policy()->young_cset_region_length();
3615 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
3616 if (_surviving_young_words == NULL) {
3617 vm_exit_out_of_memory(sizeof(size_t) * array_length,
3618 "Not enough space for young surv words summary.");
3619 }
3620 memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
3621 #ifdef ASSERT
3622 for (uint i = 0; i < array_length; ++i) {
3623 assert( _surviving_young_words[i] == 0, "memset above" );
3624 }
3625 #endif // !ASSERT
3626 }
3627
3628 void
3629 G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) {
3630 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
3631 uint array_length = g1_policy()->young_cset_region_length();
3632 for (uint i = 0; i < array_length; ++i) {
3633 _surviving_young_words[i] += surv_young_words[i];
3634 }
3635 }
3636
3637 void
4380 _ct_bs((CardTableModRefBS*)_g1h->barrier_set()),
4381 _g1_rem(g1h->g1_rem_set()),
4382 _hash_seed(17), _queue_num(queue_num),
4383 _term_attempts(0),
4384 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
4385 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
4386 _age_table(false),
4387 _strong_roots_time(0), _term_time(0),
4388 _alloc_buffer_waste(0), _undo_waste(0) {
4389 // we allocate G1YoungSurvRateNumRegions plus one entries, since
4390 // we "sacrifice" entry 0 to keep track of surviving bytes for
4391 // non-young regions (where the age is -1)
4392 // We also add a few elements at the beginning and at the end in
4393 // an attempt to eliminate cache contention
4394 uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
4395 uint array_length = PADDING_ELEM_NUM +
4396 real_length +
4397 PADDING_ELEM_NUM;
4398 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
4399 if (_surviving_young_words_base == NULL)
4400 vm_exit_out_of_memory(array_length * sizeof(size_t),
4401 "Not enough space for young surv histo.");
4402 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
4403 memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
4404
4405 _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
4406 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer;
4407
4408 _start = os::elapsedTime();
4409 }
4410
4411 void
4412 G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st)
4413 {
4414 st->print_raw_cr("GC Termination Stats");
4415 st->print_raw_cr(" elapsed --strong roots-- -------termination-------"
4416 " ------waste (KiB)------");
4417 st->print_raw_cr("thr ms ms % ms % attempts"
4418 " total alloc undo");
4419 st->print_raw_cr("--- --------- --------- ------ --------- ------ --------"
4420 " ------- ------- -------");
|
1814
1815 if (_hr_printer.is_active()) {
1816 HeapWord* curr = mr.start();
1817 while (curr < mr.end()) {
1818 HeapWord* curr_end = curr + HeapRegion::GrainWords;
1819 _hr_printer.commit(curr, curr_end);
1820 curr = curr_end;
1821 }
1822 assert(curr == mr.end(), "post-condition");
1823 }
1824 g1_policy()->record_new_heap_size(n_regions());
1825 } else {
1826 ergo_verbose0(ErgoHeapSizing,
1827 "did not expand the heap",
1828 ergo_format_reason("heap expansion operation failed"));
1829 // The expansion of the virtual storage space was unsuccessful.
1830 // Let's see if it was because we ran out of swap.
1831 if (G1ExitOnExpansionFailure &&
1832 _g1_storage.uncommitted_size() >= aligned_expand_bytes) {
1833 // We had head room...
1834 vm_exit_out_of_memory(aligned_expand_bytes, OOM_MMAP_ERROR, "G1 heap expansion");
1835 }
1836 }
1837 return successful;
1838 }
1839
1840 void G1CollectedHeap::shrink_helper(size_t shrink_bytes) {
1841 size_t old_mem_size = _g1_storage.committed_size();
1842 size_t aligned_shrink_bytes =
1843 ReservedSpace::page_align_size_down(shrink_bytes);
1844 aligned_shrink_bytes = align_size_down(aligned_shrink_bytes,
1845 HeapRegion::GrainBytes);
1846 uint num_regions_deleted = 0;
1847 MemRegion mr = _hrs.shrink_by(aligned_shrink_bytes, &num_regions_deleted);
1848 HeapWord* old_end = (HeapWord*) _g1_storage.high();
1849 assert(mr.end() == old_end, "post-condition");
1850
1851 ergo_verbose3(ErgoHeapSizing,
1852 "shrink the heap",
1853 ergo_format_byte("requested shrinking amount")
1854 ergo_format_byte("aligned shrinking amount")
3597 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
3598 size_t buffer_size = dcqs.buffer_size();
3599 size_t buffer_num = dcqs.completed_buffers_num();
3600
3601 // PtrQueueSet::buffer_size() and PtrQueue:size() return sizes
3602 // in bytes - not the number of 'entries'. We need to convert
3603 // into a number of cards.
3604 return (buffer_size * buffer_num + extra_cards) / oopSize;
3605 }
3606
3607 size_t G1CollectedHeap::cards_scanned() {
3608 return g1_rem_set()->cardsScanned();
3609 }
3610
3611 void
3612 G1CollectedHeap::setup_surviving_young_words() {
3613 assert(_surviving_young_words == NULL, "pre-condition");
3614 uint array_length = g1_policy()->young_cset_region_length();
3615 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
3616 if (_surviving_young_words == NULL) {
3617 vm_exit_out_of_memory(sizeof(size_t) * array_length, OOM_MALLOC_ERROR,
3618 "Not enough space for young surv words summary.");
3619 }
3620 memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
3621 #ifdef ASSERT
3622 for (uint i = 0; i < array_length; ++i) {
3623 assert( _surviving_young_words[i] == 0, "memset above" );
3624 }
3625 #endif // !ASSERT
3626 }
3627
3628 void
3629 G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) {
3630 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
3631 uint array_length = g1_policy()->young_cset_region_length();
3632 for (uint i = 0; i < array_length; ++i) {
3633 _surviving_young_words[i] += surv_young_words[i];
3634 }
3635 }
3636
3637 void
4380 _ct_bs((CardTableModRefBS*)_g1h->barrier_set()),
4381 _g1_rem(g1h->g1_rem_set()),
4382 _hash_seed(17), _queue_num(queue_num),
4383 _term_attempts(0),
4384 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
4385 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
4386 _age_table(false),
4387 _strong_roots_time(0), _term_time(0),
4388 _alloc_buffer_waste(0), _undo_waste(0) {
4389 // we allocate G1YoungSurvRateNumRegions plus one entries, since
4390 // we "sacrifice" entry 0 to keep track of surviving bytes for
4391 // non-young regions (where the age is -1)
4392 // We also add a few elements at the beginning and at the end in
4393 // an attempt to eliminate cache contention
4394 uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
4395 uint array_length = PADDING_ELEM_NUM +
4396 real_length +
4397 PADDING_ELEM_NUM;
4398 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
4399 if (_surviving_young_words_base == NULL)
4400 vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR,
4401 "Not enough space for young surv histo.");
4402 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
4403 memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
4404
4405 _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
4406 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer;
4407
4408 _start = os::elapsedTime();
4409 }
4410
4411 void
4412 G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st)
4413 {
4414 st->print_raw_cr("GC Termination Stats");
4415 st->print_raw_cr(" elapsed --strong roots-- -------termination-------"
4416 " ------waste (KiB)------");
4417 st->print_raw_cr("thr ms ms % ms % attempts"
4418 " total alloc undo");
4419 st->print_raw_cr("--- --------- --------- ------ --------- ------ --------"
4420 " ------- ------- -------");
|