4153 FreeRegionList _local_free_list;
4154 public:
4155 G1SerialFreeCollectionSetClosure(G1EvacuationInfo* evacuation_info, const size_t* surviving_young_words) :
4156 HeapRegionClosure(),
4157 _evacuation_info(evacuation_info),
4158 _surviving_young_words(surviving_young_words),
4159 _before_used_bytes(0),
4160 _after_used_bytes(0),
4161 _bytes_allocated_in_old_since_last_gc(0),
4162 _failure_used_words(0),
4163 _failure_waste_words(0),
4164 _local_free_list("Local Region List for CSet Freeing") {
4165 }
4166
4167 virtual bool do_heap_region(HeapRegion* r) {
4168 G1CollectedHeap* g1h = G1CollectedHeap::heap();
4169
4170 assert(r->in_collection_set(), "Region %u should be in collection set.", r->hrm_index());
4171 g1h->clear_region_attr(r);
4172
4173 if (r->is_young()) {
4174 assert(r->young_index_in_cset() != 0 && (uint)r->young_index_in_cset() <= g1h->collection_set()->young_region_length(),
4175 "Young index %u is wrong for region %u of type %s with %u young regions",
4176 r->young_index_in_cset(),
4177 r->hrm_index(),
4178 r->get_type_str(),
4179 g1h->collection_set()->young_region_length());
4180 size_t words_survived = _surviving_young_words[r->young_index_in_cset()];
4181 r->record_surv_words_in_group(words_survived);
4182 }
4183
4184 if (!r->evacuation_failed()) {
4185 assert(!r->is_empty(), "Region %u is an empty region in the collection set.", r->hrm_index());
4186 _before_used_bytes += r->used();
4187 g1h->free_region(r,
4188 &_local_free_list,
4189 true, /* skip_remset */
4190 true, /* skip_hot_card_cache */
4191 true /* locked */);
4192 } else {
4193 r->uninstall_surv_rate_group();
4194 r->clear_young_index_in_cset();
4818 new_alloc_region->set_old();
4819 _verifier->check_bitmaps("Old Region Allocation", new_alloc_region);
4820 }
4821 _policy->remset_tracker()->update_at_allocate(new_alloc_region);
4822 register_region_with_region_attr(new_alloc_region);
4823 _hr_printer.alloc(new_alloc_region);
4824 return new_alloc_region;
4825 }
4826 return NULL;
4827 }
4828
4829 void G1CollectedHeap::retire_gc_alloc_region(HeapRegion* alloc_region,
4830 size_t allocated_bytes,
4831 G1HeapRegionAttr dest) {
4832 _bytes_used_during_gc += allocated_bytes;
4833 if (dest.is_old()) {
4834 old_set_add(alloc_region);
4835 } else {
4836 assert(dest.is_young(), "Retiring alloc region should be young (%d)", dest.type());
4837 _survivor.add_used_bytes(allocated_bytes);
4838 }
4839
4840 bool const during_im = collector_state()->in_initial_mark_gc();
4841 if (during_im && allocated_bytes > 0) {
4842 _cm->root_regions()->add(alloc_region->next_top_at_mark_start(), alloc_region->top());
4843 }
4844 _hr_printer.retire(alloc_region);
4845 }
4846
4847 HeapRegion* G1CollectedHeap::alloc_highest_free_region() {
4848 bool expanded = false;
4849 uint index = _hrm->find_highest_free(&expanded);
4850
4851 if (index != G1_NO_HRM_INDEX) {
4852 if (expanded) {
4853 log_debug(gc, ergo, heap)("Attempt heap expansion (requested address range outside heap bounds). region size: " SIZE_FORMAT "B",
4854 HeapRegion::GrainWords * HeapWordSize);
4855 }
4856 _hrm->allocate_free_regions_starting_at(index, 1);
4857 return region_at(index);
|
4153 FreeRegionList _local_free_list;
4154 public:
4155 G1SerialFreeCollectionSetClosure(G1EvacuationInfo* evacuation_info, const size_t* surviving_young_words) :
4156 HeapRegionClosure(),
4157 _evacuation_info(evacuation_info),
4158 _surviving_young_words(surviving_young_words),
4159 _before_used_bytes(0),
4160 _after_used_bytes(0),
4161 _bytes_allocated_in_old_since_last_gc(0),
4162 _failure_used_words(0),
4163 _failure_waste_words(0),
4164 _local_free_list("Local Region List for CSet Freeing") {
4165 }
4166
4167 virtual bool do_heap_region(HeapRegion* r) {
4168 G1CollectedHeap* g1h = G1CollectedHeap::heap();
4169
4170 assert(r->in_collection_set(), "Region %u should be in collection set.", r->hrm_index());
4171 g1h->clear_region_attr(r);
4172
4173 if (r->young_index_in_cset() != 0) {
4174 assert(r->is_eden(), "must be but region %u is %s", r->hrm_index(), r->get_type_str());
4175 assert(r->young_index_in_cset() <= g1h->collection_set()->young_region_length(),
4176 "Young index %u is wrong for region %u of type %s with %u young regions",
4177 r->young_index_in_cset(),
4178 r->hrm_index(),
4179 r->get_type_str(),
4180 g1h->collection_set()->young_region_length());
4181 size_t words_survived = _surviving_young_words[r->young_index_in_cset()];
4182 r->record_surv_words_in_group(words_survived);
4183 }
4184
4185 if (!r->evacuation_failed()) {
4186 assert(!r->is_empty(), "Region %u is an empty region in the collection set.", r->hrm_index());
4187 _before_used_bytes += r->used();
4188 g1h->free_region(r,
4189 &_local_free_list,
4190 true, /* skip_remset */
4191 true, /* skip_hot_card_cache */
4192 true /* locked */);
4193 } else {
4194 r->uninstall_surv_rate_group();
4195 r->clear_young_index_in_cset();
4819 new_alloc_region->set_old();
4820 _verifier->check_bitmaps("Old Region Allocation", new_alloc_region);
4821 }
4822 _policy->remset_tracker()->update_at_allocate(new_alloc_region);
4823 register_region_with_region_attr(new_alloc_region);
4824 _hr_printer.alloc(new_alloc_region);
4825 return new_alloc_region;
4826 }
4827 return NULL;
4828 }
4829
4830 void G1CollectedHeap::retire_gc_alloc_region(HeapRegion* alloc_region,
4831 size_t allocated_bytes,
4832 G1HeapRegionAttr dest) {
4833 _bytes_used_during_gc += allocated_bytes;
4834 if (dest.is_old()) {
4835 old_set_add(alloc_region);
4836 } else {
4837 assert(dest.is_young(), "Retiring alloc region should be young (%d)", dest.type());
4838 _survivor.add_used_bytes(allocated_bytes);
4839 alloc_region->set_survivor_bytes(allocated_bytes);
4840 }
4841
4842 bool const during_im = collector_state()->in_initial_mark_gc();
4843 if (during_im && allocated_bytes > 0) {
4844 _cm->root_regions()->add(alloc_region->next_top_at_mark_start(), alloc_region->top());
4845 }
4846 _hr_printer.retire(alloc_region);
4847 }
4848
4849 HeapRegion* G1CollectedHeap::alloc_highest_free_region() {
4850 bool expanded = false;
4851 uint index = _hrm->find_highest_free(&expanded);
4852
4853 if (index != G1_NO_HRM_INDEX) {
4854 if (expanded) {
4855 log_debug(gc, ergo, heap)("Attempt heap expansion (requested address range outside heap bounds). region size: " SIZE_FORMAT "B",
4856 HeapRegion::GrainWords * HeapWordSize);
4857 }
4858 _hrm->allocate_free_regions_starting_at(index, 1);
4859 return region_at(index);
|