< prev index next >
src/share/vm/gc/g1/g1CollectedHeap.cpp
Print this page
rev 9416 : dihop-changes
rev 9418 : imported patch erik-jmasa-review
*** 400,419 ****
}
return new_obj;
}
// If could fit into free regions w/o expansion, try.
// Otherwise, if can expand, do so.
// Otherwise, if using ex regions might help, try with ex given back.
HeapWord* G1CollectedHeap::humongous_obj_allocate(size_t word_size, AllocationContext_t context) {
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
verify_region_sets_optional();
uint first = G1_NO_HRM_INDEX;
! uint obj_regions = (uint)(align_size_up_(word_size, HeapRegion::GrainWords) / HeapRegion::GrainWords);
if (obj_regions == 1) {
// Only one region to allocate, try to use a fast path by directly allocating
// from the free lists. Do not try to expand here, we will potentially do that
// later.
--- 400,424 ----
}
return new_obj;
}
+ size_t G1CollectedHeap::humongous_obj_size_in_regions(size_t word_size) {
+ assert(is_humongous(word_size), "Object of size " SIZE_FORMAT " must be humongous here", word_size);
+ return align_size_up_(word_size, HeapRegion::GrainWords) / HeapRegion::GrainWords;
+ }
+
// If could fit into free regions w/o expansion, try.
// Otherwise, if can expand, do so.
// Otherwise, if using ex regions might help, try with ex given back.
HeapWord* G1CollectedHeap::humongous_obj_allocate(size_t word_size, AllocationContext_t context) {
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
verify_region_sets_optional();
uint first = G1_NO_HRM_INDEX;
! uint obj_regions = (uint) humongous_obj_size_in_regions(word_size);
if (obj_regions == 1) {
// Only one region to allocate, try to use a fast path by directly allocating
// from the free lists. Do not try to expand here, we will potentially do that
// later.
*** 1009,1018 ****
--- 1014,1024 ----
// Given that humongous objects are not allocated in young
// regions, we'll first try to do the allocation without doing a
// collection hoping that there's enough space in the heap.
result = humongous_obj_allocate(word_size, AllocationContext::current());
if (result != NULL) {
+ g1_policy()->add_last_old_allocated_bytes(humongous_obj_size_in_regions(word_size) * HeapRegion::GrainBytes);
return result;
}
if (GC_locker::is_active_and_needs_gc()) {
should_try_gc = false;
*** 5242,5251 ****
--- 5248,5259 ----
DerivedPointerTable::update_pointers();
#endif
}
void G1CollectedHeap::record_obj_copy_mem_stats() {
+ g1_policy()->add_last_old_allocated_bytes(_old_evac_stats.allocated() * HeapWordSize);
+
_gc_tracer_stw->report_evacuation_statistics(create_g1_evac_summary(&_survivor_evac_stats),
create_g1_evac_summary(&_old_evac_stats));
}
void G1CollectedHeap::free_region(HeapRegion* hr,
*** 5626,5635 ****
--- 5634,5651 ----
cur->uninstall_surv_rate_group();
if (cur->is_young()) {
cur->set_young_index_in_cset(-1);
}
cur->set_evacuation_failed(false);
+ // When moving a young gen region to old gen, we "allocate" that whole region
+ // there. This is in addition to any already evacuated objects. Notify the
+ // policy about that.
+ // Old gen regions do not cause an additional allocation: both the objects
+ // still in the region and the ones already moved are accounted for elsewhere.
+ if (cur->is_young()) {
+ policy->add_last_old_allocated_bytes(HeapRegion::GrainBytes);
+ }
// The region is now considered to be old.
cur->set_old();
// Do some allocation statistics accounting. Regions that failed evacuation
// are always made old, so there is no need to update anything in the young
// gen statistics, but we need to update old gen statistics.
< prev index next >