969 size_t word_size = curr_range.word_size(); |
969 size_t word_size = curr_range.word_size(); |
970 HeapWord* last_address = curr_range.last(); |
970 HeapWord* last_address = curr_range.last(); |
971 size_t commits = 0; |
971 size_t commits = 0; |
972 |
972 |
973 guarantee(reserved.contains(start_address) && reserved.contains(last_address), |
973 guarantee(reserved.contains(start_address) && reserved.contains(last_address), |
974 err_msg("MemRegion outside of heap [" PTR_FORMAT ", " PTR_FORMAT "]", |
974 "MemRegion outside of heap [" PTR_FORMAT ", " PTR_FORMAT "]", |
975 p2i(start_address), p2i(last_address))); |
975 p2i(start_address), p2i(last_address)); |
976 guarantee(start_address > prev_last_addr, |
976 guarantee(start_address > prev_last_addr, |
977 err_msg("Ranges not in ascending order: " PTR_FORMAT " <= " PTR_FORMAT , |
977 "Ranges not in ascending order: " PTR_FORMAT " <= " PTR_FORMAT , |
978 p2i(start_address), p2i(prev_last_addr))); |
978 p2i(start_address), p2i(prev_last_addr)); |
979 prev_last_addr = last_address; |
979 prev_last_addr = last_address; |
980 |
980 |
981 // Check for ranges that start in the same G1 region in which the previous |
981 // Check for ranges that start in the same G1 region in which the previous |
982 // range ended, and adjust the start address so we don't try to allocate |
982 // range ended, and adjust the start address so we don't try to allocate |
983 // the same region again. If the current range is entirely within that |
983 // the same region again. If the current range is entirely within that |
1015 HeapRegion* last_region = _hrm.addr_to_region(last_address); |
1015 HeapRegion* last_region = _hrm.addr_to_region(last_address); |
1016 prev_last_region = last_region; |
1016 prev_last_region = last_region; |
1017 |
1017 |
1018 while (curr_region != NULL) { |
1018 while (curr_region != NULL) { |
1019 assert(curr_region->is_empty() && !curr_region->is_pinned(), |
1019 assert(curr_region->is_empty() && !curr_region->is_pinned(), |
1020 err_msg("Region already in use (index %u)", curr_region->hrm_index())); |
1020 "Region already in use (index %u)", curr_region->hrm_index()); |
1021 _hr_printer.alloc(curr_region, G1HRPrinter::Archive); |
1021 _hr_printer.alloc(curr_region, G1HRPrinter::Archive); |
1022 curr_region->set_allocation_context(AllocationContext::system()); |
1022 curr_region->set_allocation_context(AllocationContext::system()); |
1023 curr_region->set_archive(); |
1023 curr_region->set_archive(); |
1024 _old_set.add(curr_region); |
1024 _old_set.add(curr_region); |
1025 if (curr_region != last_region) { |
1025 if (curr_region != last_region) { |
1053 for (size_t i = 0; i < count; i++) { |
1053 for (size_t i = 0; i < count; i++) { |
1054 HeapWord* start_address = ranges[i].start(); |
1054 HeapWord* start_address = ranges[i].start(); |
1055 HeapWord* last_address = ranges[i].last(); |
1055 HeapWord* last_address = ranges[i].last(); |
1056 |
1056 |
1057 assert(reserved.contains(start_address) && reserved.contains(last_address), |
1057 assert(reserved.contains(start_address) && reserved.contains(last_address), |
1058 err_msg("MemRegion outside of heap [" PTR_FORMAT ", " PTR_FORMAT "]", |
1058 "MemRegion outside of heap [" PTR_FORMAT ", " PTR_FORMAT "]", |
1059 p2i(start_address), p2i(last_address))); |
1059 p2i(start_address), p2i(last_address)); |
1060 assert(start_address > prev_last_addr, |
1060 assert(start_address > prev_last_addr, |
1061 err_msg("Ranges not in ascending order: " PTR_FORMAT " <= " PTR_FORMAT , |
1061 "Ranges not in ascending order: " PTR_FORMAT " <= " PTR_FORMAT , |
1062 p2i(start_address), p2i(prev_last_addr))); |
1062 p2i(start_address), p2i(prev_last_addr)); |
1063 |
1063 |
1064 HeapRegion* start_region = _hrm.addr_to_region(start_address); |
1064 HeapRegion* start_region = _hrm.addr_to_region(start_address); |
1065 HeapRegion* last_region = _hrm.addr_to_region(last_address); |
1065 HeapRegion* last_region = _hrm.addr_to_region(last_address); |
1066 HeapWord* bottom_address = start_region->bottom(); |
1066 HeapWord* bottom_address = start_region->bottom(); |
1067 |
1067 |
1137 for (size_t i = 0; i < count; i++) { |
1137 for (size_t i = 0; i < count; i++) { |
1138 HeapWord* start_address = ranges[i].start(); |
1138 HeapWord* start_address = ranges[i].start(); |
1139 HeapWord* last_address = ranges[i].last(); |
1139 HeapWord* last_address = ranges[i].last(); |
1140 |
1140 |
1141 assert(reserved.contains(start_address) && reserved.contains(last_address), |
1141 assert(reserved.contains(start_address) && reserved.contains(last_address), |
1142 err_msg("MemRegion outside of heap [" PTR_FORMAT ", " PTR_FORMAT "]", |
1142 "MemRegion outside of heap [" PTR_FORMAT ", " PTR_FORMAT "]", |
1143 p2i(start_address), p2i(last_address))); |
1143 p2i(start_address), p2i(last_address)); |
1144 assert(start_address > prev_last_addr, |
1144 assert(start_address > prev_last_addr, |
1145 err_msg("Ranges not in ascending order: " PTR_FORMAT " <= " PTR_FORMAT , |
1145 "Ranges not in ascending order: " PTR_FORMAT " <= " PTR_FORMAT , |
1146 p2i(start_address), p2i(prev_last_addr))); |
1146 p2i(start_address), p2i(prev_last_addr)); |
1147 size_used += ranges[i].byte_size(); |
1147 size_used += ranges[i].byte_size(); |
1148 prev_last_addr = last_address; |
1148 prev_last_addr = last_address; |
1149 |
1149 |
1150 HeapRegion* start_region = _hrm.addr_to_region(start_address); |
1150 HeapRegion* start_region = _hrm.addr_to_region(start_address); |
1151 HeapRegion* last_region = _hrm.addr_to_region(last_address); |
1151 HeapRegion* last_region = _hrm.addr_to_region(last_address); |
1166 // After verifying that each region was marked as an archive region by |
1166 // After verifying that each region was marked as an archive region by |
1167 // alloc_archive_regions, set it free and empty and uncommit it. |
1167 // alloc_archive_regions, set it free and empty and uncommit it. |
1168 HeapRegion* curr_region = start_region; |
1168 HeapRegion* curr_region = start_region; |
1169 while (curr_region != NULL) { |
1169 while (curr_region != NULL) { |
1170 guarantee(curr_region->is_archive(), |
1170 guarantee(curr_region->is_archive(), |
1171 err_msg("Expected archive region at index %u", curr_region->hrm_index())); |
1171 "Expected archive region at index %u", curr_region->hrm_index()); |
1172 uint curr_index = curr_region->hrm_index(); |
1172 uint curr_index = curr_region->hrm_index(); |
1173 _old_set.remove(curr_region); |
1173 _old_set.remove(curr_region); |
1174 curr_region->set_free(); |
1174 curr_region->set_free(); |
1175 curr_region->set_top(curr_region->bottom()); |
1175 curr_region->set_top(curr_region->bottom()); |
1176 if (curr_region != last_region) { |
1176 if (curr_region != last_region) { |
1753 size_t maximum_desired_capacity = (size_t) maximum_desired_capacity_d; |
1753 size_t maximum_desired_capacity = (size_t) maximum_desired_capacity_d; |
1754 |
1754 |
1755 // This assert only makes sense here, before we adjust them |
1755 // This assert only makes sense here, before we adjust them |
1756 // with respect to the min and max heap size. |
1756 // with respect to the min and max heap size. |
1757 assert(minimum_desired_capacity <= maximum_desired_capacity, |
1757 assert(minimum_desired_capacity <= maximum_desired_capacity, |
1758 err_msg("minimum_desired_capacity = " SIZE_FORMAT ", " |
1758 "minimum_desired_capacity = " SIZE_FORMAT ", " |
1759 "maximum_desired_capacity = " SIZE_FORMAT, |
1759 "maximum_desired_capacity = " SIZE_FORMAT, |
1760 minimum_desired_capacity, maximum_desired_capacity)); |
1760 minimum_desired_capacity, maximum_desired_capacity); |
1761 |
1761 |
1762 // Should not be greater than the heap max size. No need to adjust |
1762 // Should not be greater than the heap max size. No need to adjust |
1763 // it with respect to the heap min size as it's a lower bound (i.e., |
1763 // it with respect to the heap min size as it's a lower bound (i.e., |
1764 // we'll try to make the capacity larger than it, not smaller). |
1764 // we'll try to make the capacity larger than it, not smaller). |
1765 minimum_desired_capacity = MIN2(minimum_desired_capacity, max_heap_size); |
1765 minimum_desired_capacity = MIN2(minimum_desired_capacity, max_heap_size); |
2562 |
2562 |
2563 // This is the case for the inner caller, i.e. a Full GC. |
2563 // This is the case for the inner caller, i.e. a Full GC. |
2564 assert(concurrent || |
2564 assert(concurrent || |
2565 (_old_marking_cycles_started == _old_marking_cycles_completed + 1) || |
2565 (_old_marking_cycles_started == _old_marking_cycles_completed + 1) || |
2566 (_old_marking_cycles_started == _old_marking_cycles_completed + 2), |
2566 (_old_marking_cycles_started == _old_marking_cycles_completed + 2), |
2567 err_msg("for inner caller (Full GC): _old_marking_cycles_started = %u " |
2567 "for inner caller (Full GC): _old_marking_cycles_started = %u " |
2568 "is inconsistent with _old_marking_cycles_completed = %u", |
2568 "is inconsistent with _old_marking_cycles_completed = %u", |
2569 _old_marking_cycles_started, _old_marking_cycles_completed)); |
2569 _old_marking_cycles_started, _old_marking_cycles_completed); |
2570 |
2570 |
2571 // This is the case for the outer caller, i.e. the concurrent cycle. |
2571 // This is the case for the outer caller, i.e. the concurrent cycle. |
2572 assert(!concurrent || |
2572 assert(!concurrent || |
2573 (_old_marking_cycles_started == _old_marking_cycles_completed + 1), |
2573 (_old_marking_cycles_started == _old_marking_cycles_completed + 1), |
2574 err_msg("for outer caller (concurrent cycle): " |
2574 "for outer caller (concurrent cycle): " |
2575 "_old_marking_cycles_started = %u " |
2575 "_old_marking_cycles_started = %u " |
2576 "is inconsistent with _old_marking_cycles_completed = %u", |
2576 "is inconsistent with _old_marking_cycles_completed = %u", |
2577 _old_marking_cycles_started, _old_marking_cycles_completed)); |
2577 _old_marking_cycles_started, _old_marking_cycles_completed); |
2578 |
2578 |
2579 _old_marking_cycles_completed += 1; |
2579 _old_marking_cycles_completed += 1; |
2580 |
2580 |
2581 // We need to clear the "in_progress" flag in the CM thread before |
2581 // We need to clear the "in_progress" flag in the CM thread before |
2582 // we wake up any waiters (especially when ExplicitInvokesConcurrent |
2582 // we wake up any waiters (especially when ExplicitInvokesConcurrent |
4707 } |
4707 } |
4708 } |
4708 } |
4709 |
4709 |
4710 ~G1StringSymbolTableUnlinkTask() { |
4710 ~G1StringSymbolTableUnlinkTask() { |
4711 guarantee(!_process_strings || StringTable::parallel_claimed_index() >= _initial_string_table_size, |
4711 guarantee(!_process_strings || StringTable::parallel_claimed_index() >= _initial_string_table_size, |
4712 err_msg("claim value %d after unlink less than initial string table size %d", |
4712 "claim value %d after unlink less than initial string table size %d", |
4713 StringTable::parallel_claimed_index(), _initial_string_table_size)); |
4713 StringTable::parallel_claimed_index(), _initial_string_table_size); |
4714 guarantee(!_process_symbols || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size, |
4714 guarantee(!_process_symbols || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size, |
4715 err_msg("claim value %d after unlink less than initial symbol table size %d", |
4715 "claim value %d after unlink less than initial symbol table size %d", |
4716 SymbolTable::parallel_claimed_index(), _initial_symbol_table_size)); |
4716 SymbolTable::parallel_claimed_index(), _initial_symbol_table_size); |
4717 |
4717 |
4718 if (G1TraceStringSymbolTableScrubbing) { |
4718 if (G1TraceStringSymbolTableScrubbing) { |
4719 gclog_or_tty->print_cr("Cleaned string and symbol table, " |
4719 gclog_or_tty->print_cr("Cleaned string and symbol table, " |
4720 "strings: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed, " |
4720 "strings: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed, " |
4721 "symbols: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed", |
4721 "symbols: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed", |
5821 } |
5821 } |
5822 |
5822 |
5823 bool G1CollectedHeap::verify_no_bits_over_tams(const char* bitmap_name, CMBitMapRO* bitmap, |
5823 bool G1CollectedHeap::verify_no_bits_over_tams(const char* bitmap_name, CMBitMapRO* bitmap, |
5824 HeapWord* tams, HeapWord* end) { |
5824 HeapWord* tams, HeapWord* end) { |
5825 guarantee(tams <= end, |
5825 guarantee(tams <= end, |
5826 err_msg("tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end))); |
5826 "tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end)); |
5827 HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end); |
5827 HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end); |
5828 if (result < end) { |
5828 if (result < end) { |
5829 gclog_or_tty->cr(); |
5829 gclog_or_tty->cr(); |
5830 gclog_or_tty->print_cr("## wrong marked address on %s bitmap: " PTR_FORMAT, |
5830 gclog_or_tty->print_cr("## wrong marked address on %s bitmap: " PTR_FORMAT, |
5831 bitmap_name, p2i(result)); |
5831 bitmap_name, p2i(result)); |
6629 } |
6628 } |
6630 |
6629 |
6631 if (hr->is_young()) { |
6630 if (hr->is_young()) { |
6632 // TODO |
6631 // TODO |
6633 } else if (hr->is_starts_humongous()) { |
6632 } else if (hr->is_starts_humongous()) { |
6634 assert(hr->containing_set() == _humongous_set, err_msg("Heap region %u is starts humongous but not in humongous set.", hr->hrm_index())); |
6633 assert(hr->containing_set() == _humongous_set, "Heap region %u is starts humongous but not in humongous set.", hr->hrm_index()); |
6635 _humongous_count.increment(1u, hr->capacity()); |
6634 _humongous_count.increment(1u, hr->capacity()); |
6636 } else if (hr->is_empty()) { |
6635 } else if (hr->is_empty()) { |
6637 assert(_hrm->is_free(hr), err_msg("Heap region %u is empty but not on the free list.", hr->hrm_index())); |
6636 assert(_hrm->is_free(hr), "Heap region %u is empty but not on the free list.", hr->hrm_index()); |
6638 _free_count.increment(1u, hr->capacity()); |
6637 _free_count.increment(1u, hr->capacity()); |
6639 } else if (hr->is_old()) { |
6638 } else if (hr->is_old()) { |
6640 assert(hr->containing_set() == _old_set, err_msg("Heap region %u is old but not in the old set.", hr->hrm_index())); |
6639 assert(hr->containing_set() == _old_set, "Heap region %u is old but not in the old set.", hr->hrm_index()); |
6641 _old_count.increment(1u, hr->capacity()); |
6640 _old_count.increment(1u, hr->capacity()); |
6642 } else { |
6641 } else { |
6643 // There are no other valid region types. Check for one invalid |
6642 // There are no other valid region types. Check for one invalid |
6644 // one we can identify: pinned without old or humongous set. |
6643 // one we can identify: pinned without old or humongous set. |
6645 assert(!hr->is_pinned(), err_msg("Heap region %u is pinned but not old (archive) or humongous.", hr->hrm_index())); |
6644 assert(!hr->is_pinned(), "Heap region %u is pinned but not old (archive) or humongous.", hr->hrm_index()); |
6646 ShouldNotReachHere(); |
6645 ShouldNotReachHere(); |
6647 } |
6646 } |
6648 return false; |
6647 return false; |
6649 } |
6648 } |
6650 |
6649 |
6651 void verify_counts(HeapRegionSet* old_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) { |
6650 void verify_counts(HeapRegionSet* old_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) { |
6652 guarantee(old_set->length() == _old_count.length(), err_msg("Old set count mismatch. Expected %u, actual %u.", old_set->length(), _old_count.length())); |
6651 guarantee(old_set->length() == _old_count.length(), "Old set count mismatch. Expected %u, actual %u.", old_set->length(), _old_count.length()); |
6653 guarantee(old_set->total_capacity_bytes() == _old_count.capacity(), err_msg("Old set capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, |
6652 guarantee(old_set->total_capacity_bytes() == _old_count.capacity(), "Old set capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, |
6654 old_set->total_capacity_bytes(), _old_count.capacity())); |
6653 old_set->total_capacity_bytes(), _old_count.capacity()); |
6655 |
6654 |
6656 guarantee(humongous_set->length() == _humongous_count.length(), err_msg("Hum set count mismatch. Expected %u, actual %u.", humongous_set->length(), _humongous_count.length())); |
6655 guarantee(humongous_set->length() == _humongous_count.length(), "Hum set count mismatch. Expected %u, actual %u.", humongous_set->length(), _humongous_count.length()); |
6657 guarantee(humongous_set->total_capacity_bytes() == _humongous_count.capacity(), err_msg("Hum set capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, |
6656 guarantee(humongous_set->total_capacity_bytes() == _humongous_count.capacity(), "Hum set capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, |
6658 humongous_set->total_capacity_bytes(), _humongous_count.capacity())); |
6657 humongous_set->total_capacity_bytes(), _humongous_count.capacity()); |
6659 |
6658 |
6660 guarantee(free_list->num_free_regions() == _free_count.length(), err_msg("Free list count mismatch. Expected %u, actual %u.", free_list->num_free_regions(), _free_count.length())); |
6659 guarantee(free_list->num_free_regions() == _free_count.length(), "Free list count mismatch. Expected %u, actual %u.", free_list->num_free_regions(), _free_count.length()); |
6661 guarantee(free_list->total_capacity_bytes() == _free_count.capacity(), err_msg("Free list capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, |
6660 guarantee(free_list->total_capacity_bytes() == _free_count.capacity(), "Free list capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, |
6662 free_list->total_capacity_bytes(), _free_count.capacity())); |
6661 free_list->total_capacity_bytes(), _free_count.capacity()); |
6663 } |
6662 } |
6664 }; |
6663 }; |
6665 |
6664 |
6666 void G1CollectedHeap::verify_region_sets() { |
6665 void G1CollectedHeap::verify_region_sets() { |
6667 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); |
6666 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); |
6713 T heap_oop = oopDesc::load_heap_oop(p); |
6712 T heap_oop = oopDesc::load_heap_oop(p); |
6714 if (!oopDesc::is_null(heap_oop)) { |
6713 if (!oopDesc::is_null(heap_oop)) { |
6715 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
6714 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
6716 HeapRegion* hr = _g1h->heap_region_containing(obj); |
6715 HeapRegion* hr = _g1h->heap_region_containing(obj); |
6717 assert(!hr->is_continues_humongous(), |
6716 assert(!hr->is_continues_humongous(), |
6718 err_msg("trying to add code root " PTR_FORMAT " in continuation of humongous region " HR_FORMAT |
6717 "trying to add code root " PTR_FORMAT " in continuation of humongous region " HR_FORMAT |
6719 " starting at " HR_FORMAT, |
6718 " starting at " HR_FORMAT, |
6720 p2i(_nm), HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region()))); |
6719 p2i(_nm), HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region())); |
6721 |
6720 |
6722 // HeapRegion::add_strong_code_root_locked() avoids adding duplicate entries. |
6721 // HeapRegion::add_strong_code_root_locked() avoids adding duplicate entries. |
6723 hr->add_strong_code_root_locked(_nm); |
6722 hr->add_strong_code_root_locked(_nm); |
6724 } |
6723 } |
6725 } |
6724 } |
6740 T heap_oop = oopDesc::load_heap_oop(p); |
6739 T heap_oop = oopDesc::load_heap_oop(p); |
6741 if (!oopDesc::is_null(heap_oop)) { |
6740 if (!oopDesc::is_null(heap_oop)) { |
6742 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
6741 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
6743 HeapRegion* hr = _g1h->heap_region_containing(obj); |
6742 HeapRegion* hr = _g1h->heap_region_containing(obj); |
6744 assert(!hr->is_continues_humongous(), |
6743 assert(!hr->is_continues_humongous(), |
6745 err_msg("trying to remove code root " PTR_FORMAT " in continuation of humongous region " HR_FORMAT |
6744 "trying to remove code root " PTR_FORMAT " in continuation of humongous region " HR_FORMAT |
6746 " starting at " HR_FORMAT, |
6745 " starting at " HR_FORMAT, |
6747 p2i(_nm), HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region()))); |
6746 p2i(_nm), HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region())); |
6748 |
6747 |
6749 hr->remove_strong_code_root(_nm); |
6748 hr->remove_strong_code_root(_nm); |
6750 } |
6749 } |
6751 } |
6750 } |
6752 |
6751 |