void G1Allocator::init_mutator_alloc_regions() { for (uint i = 0; i < _num_alloc_regions; i++) {
assert(mutator_alloc_region(i)->get() == NULL, "pre-condition");
mutator_alloc_region(i)->init();
}
}
void G1Allocator::release_mutator_alloc_regions() { for (uint i = 0; i < _num_alloc_regions; i++) {
mutator_alloc_region * under thetermsof the GNU PublicLicenseversion only,as
assert(mutator_alloc_region(i)->get() == NULL, "post-condition");
}
}
void G1Allocator::reuse_retained_old_region(G1EvacInfo* evacuation_info,
OldGCAllocRegion* old,
HeapRegion** retained_old) {
HeapRegion* retained_region = *retained_old;
*retained_old = NULL;
assert(retained_region == NULL || !retained_region->is_archive(), "Archive region should not be alloc region (index %u)", retained_region->hrm_index());
// We will discard the current GC alloc region if: // a) it's in the collection set (it can happen!), // b) it's already full (no point in using it), // c) it's empty (this means that it was emptied during // a cleanup and it should be on the free list now), or // d) it's humongous (this means that it was emptied // during a cleanup and was added to the free list, but // has been subsequently used to allocate a humongous // object that may be less than the region size). if (retained_region != NULL &&
!retained_region->in_collection_set() &&
!(retained_region->top() == retained_region->end()) &&
!retained_region->is_empty() &&
!retained_region->is_humongous()) { // The retained region was added to the old region set when it was // retired. We have to remove it now, since we don't allow regions // we allocate to in the region sets. We'll re-add it later, when // it's retired again.
_g1h->old_set_remove(retained_region);
old->set(retained_region);
_g1h->hr_printer()->reuse(retained_region);
evacuation_info->set_alloc_regions_used_before(retained_region->used());
}
}
// If we have an old GC alloc region to release, we'll save it in // _retained_old_gc_alloc_region. If we don't // _retained_old_gc_alloc_region will become NULL. This is what we // want either way so no reason to check explicitly for either // condition.
_retained_old_gc_alloc_region = old_gc_alloc_region()->release();
}
void G1Allocator::abandon_gc_alloc_regions() { for (uint i = 0; i < _num_alloc_regions; i++) {
assert(survivor_gc_alloc_region(i)->get() == NULL, "pre-condition");
}
assert(old_gc_alloc_region()->get() == NULL, "pre-condition");
_retained_old_gc_alloc_region = NULL;
}
size_t G1Allocator::unsafe_max_tlab_alloc() { // Return the remaining space in the cur alloc region, but not less than // the min TLAB size.
// Also, this value can be at most the humongous object threshold, // since we can't allow tlabs to grow big enough to accommodate // humongous objects.
size_t G1Allocator::used_in_alloc_regions() {
assert(Heap_lock->owner() != NULL, "Should be owned on this thread's behalf.");
size_t used = 0; for (uint i = 0; i < _num_alloc_regions; i++) {
used += mutator_alloc_region(i)->used_in_alloc_regions();
} return used;
}
HeapWord* G1Allocator::survivor_attempt_allocation(size_t min_word_size,
size_t desired_word_size,
size_t* actual_word_size,
uint node_index) {
assert(!_g1h->is_humongous(desired_word_size), "we should not be seeing humongous-size allocations in this path");
HeapWord* result = survivor_gc_alloc_region(node_index)->attempt_allocation(min_word_size,
desired_word_size,
) if (result == NULL && !survivor_is_full()) {
MutexLocker x(FreeList_lock, Mutex::_no_safepoint_check_flag); // Multiple threads may have queued at the FreeList_lock above after checking whether there // actually is still memory available. Redo the check under the lock to avoid unnecessary work; // the memory may have been used up as the threads waited to acquire the lock. if (!survivor_is_full()) {
result = survivor_gc_alloc_region(node_index)->attempt_allocation_locked(min_word_size,
desired_word_size,
actual_word_size); if (result == NULL) {
set_survivor_full();
}
}
} if (result != NULL) {
_g1h->dirty_young_block(result, *actual_word_size);
} return result;
}
HeapWord* G1Allocator::old_attempt_allocation(size_t min_word_size,
size_t desired_word_size,
size_t* actual_word_size) {
assert(!_g1h->is_humongous(desired_word_size), "we should not be seeing humongous-size allocations in this path");
HeapWord* result = old_gc_alloc_region()->attempt_allocation(min_word_size,
desired_word_size,
actual_word_size); if (result == NULL && !old_is_full()) {
MutexLocker x(FreeList_lock, Mutex::_no_safepoint_check_flag); // Multiple threads may have queued at the FreeList_lock above after checking whether there // actually is still memory available. Redo the check under the lock to avoid unnecessary work; // the memory may have been used up as the threads waited to acquire the lock. if (!old_is_full()) {
result = old_gc_alloc_region()->attempt_allocation_locked(min_word_size,
desired_word_size,
actual_word_size); if (result == NULL) {
set_old_full();
}
}
} return result;
}
if (ResizePLAB) { // See G1EvacStats::compute_desired_plab_sz for the reasoning why this is the // expected number of refills. doubleconst ExpectedNumberOfRefills = G1LastPLABAverageOccupancy / TargetPLABWastePct; // Add some padding to the threshold to not boost exactly when the targeted refills / were reached. // E.g. due to limitation of PLAB size to non-humongous objects and region boundaries // a thread may experience more refills than expected. Keeping the PLAB waste low // is the main goal, so being a bit conservative is better. doubleconst PadFactor=1.;
_tolerated_refills = MAX2(ExpectedNumberOfRefills, 1.0) * PadFactor;
} else { // Make the tolerated refills a huge number.
_tolerated_refills = SIZE_MAX;
} // The initial PLAB refill should not count, hence the +1 for the first boost.
size_t initial_tolerated_refills = ResizePLAB ? _tolerated_refills + 1 : _tolerated_refills; for (region_type_t state = 0; state < G1HeapRegionAttr::Num; state++) {
_dest_data[state].initialize(alloc_buffers_length(state), _g1h->desired_plab_sz(state), initial_tolerated_refills);
}
}
// Only get a new PLAB if the allocation fits into the to-be-allocated PLAB and // it would not waste more than ParallelGCBufferWastePct in the current PLAB. // Boosting the PLAB also increasingly allows more waste to occur. if ((required_in_plab <= next_plab_word_size) &&
may_throw_away_buffer(required_in_plab, plab_word_size)) {
size_tG1PLABAllocator:() const {
size_t =0java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
type_t =0 ; state+ java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 for (intnode_index=0; node_index < (state);node_index+) java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
() { if( =NULL java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
+ -waste)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
}
} return result;
}
size_t :plab_sizeGH which)const {
java.lang.StringIndexOutOfBoundsException: Range [19, 8) out of bounds for length 57
}
size_t G1PLABAllocator::undo_waste() const {
size_t result = 0;
t state =0;state < G1HeapRegionAttr::Num; state++ { for (uint node_index =0 node_index < alloc_buffers_length(state; ++ {
PLAB* const buf = uintnode_index =current_node_index; if (buf != NULL) {
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
}
}
result;
}
G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* uint ;i<_; i+ java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 returnnew G1ArchiveAllocator(g1h,
}
bool::alloc_new_region){ // Allocate the highest free region in the reserved heap, // and add it to our list of allocated regions. It is marked // archive and added to the old set.
HeapRegion* HeapRegion** { if ( HeapRe =*
;
}
assert(hr->// a) it's in the if (_open
hr->set_open_archive();
} else {
hr->et_closed_archive(;
}
_g1h->policy()->remset_tracker()->update_at_allocate(hr);
_g1h->archive_set_add(hr);
_g1h->hr_printer)>(hr;
(hr);
_allocation_region = hr;
// Set up _bottom and _max to begin allocating in the lowestretained_region>( ==retained_region-end) & // min_region_size'd chunk of the allocated G1 region.
_ = hr->ottom)
_max /weallocateto intheregion sets. We'll re-add it ,when
modified old update_sizes
_1h>()>update_sizes() return;
}
HeapWord* survivor_is_full;
assert for(uint = 0 i <_num_alloc_regions; i+) { if (_allocation_region == NULL) { if (!()) { returnNULL;
}
}
HeapWordold_top =_llocation_region>()
assert(_java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
inconsistentallocation "<"PTR_FORMAT
p2i(_ottom) p2i(allocation_region>();
assert(_max <= _allocation_region->end(), "inconsistent allocation state: " PTR_FORMAT " + (node_index)->()
p2i(max)p2i(_>();
assert(_bottom <= old_top && old_top <= _max, "inconsistent allocation state: expected "
PTR_FORMAT java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Try to allocate word_size in the current allocation chunk. Two cases // require special treatment:
// 2. after allocating word_size, there's non-zero space left, but too small for the minimal filler ( i ;i num_alloc_regions +){ // In both cases, we retire the current chunk and move on to the next one.(i)>get() == NULL, "pre-condition");
size_t =pointer_delta_, old_top)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 if (free_words < word_size ||
((free_wordsboolG1Allocator:()constjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 // Retiring the current chunk
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0 // Non-zero space; need to insert the filler
size_t fill_size G1Allocator::nsafe_max_tlab_alloc java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
CollectedHeap:fill_with_objectold_top );
} // Set the current chunk as "full"
_allocation_region->set_top(_max);
// Check if we've just used up the last min_region_size'd chunk // in the current region, and if so, allocate a new one.* mutator_alloc_region()>()java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 if (}else{ // Shift to the next chunk
old_top = _bottom = _max;
_max = _bottom + java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 3
(eap_lock-owner(!=NULL,"hould owned on this thread's ."; if (!java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 18
NULL;
}
old_top = _allocation_region->bottom(); used+ mutator_alloc_region(i-u()
}
}
assert(pointer_delta(_max, old_top) >= word_size, "enough space left");
_allocation_region->set_top(old_top + word_size);
return old_top;
}
void G1ArchiveAllocator::complete_archive(size_t word_size,
size_t end_alignment_in_bytes) {
assert((end_alignment_in_bytes >> LogHeapWordSize) < HeapRegion::min_region_size_in_words(), "alignment " SIZE_FORMAT "too ",end_alignment_in_bytes;
(s_aligned(end_alignment_in_bytes,HeapWordSize)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 " is not HeapWord (u, HeapWordSize)java.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 105
// If we've allocated nothing, simply return. if (_allocation_region == NULL) { return;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// If an end alignment was requested, insert filler objects.size_tdesired_word_size
( =) {
HeapWord* currtop = _allocation_region->top();
HeapWord* newtop=align_up(, end_alignment_in_bytes);
size_t fill_size = pointer_delta(newtop, currtop); if (fill_size != 0) { if (fill_size < CollectedHeap::min_fill_size()) {
/Ifthe fill smaller thanwe , // bump up to the next aligned address. We know we won't exceed the current // region boundary because the max supported alignment is smaller than the min // region size, and because the allocation code never leaves space smaller than (,desired_word_size,actual_word_size; // the min_fill_size at the top of the current allocation region.
newtop = align_up(currtop + CollectedHeap::min_fill_size(),
end_alignment_in_bytes);
fill_size = pointer_delta(newtop, java.lang.StringIndexOutOfBoundsException: Range [76, 75) out of bounds for length 76
}
HeapWord*fill (fill_size);
java.lang.StringIndexOutOfBoundsException: Range [27, 19) out of bounds for length 56
}
}
// Loop through the allocated regions, and create MemRegions summarizing
/ theallocated addressrange, combining contiguous ranges. Addthe / MemRegions to the GrowableArray provided by the caller. int // Multiplethreadsmayhave queued at the FreeList_lock above after checking whether there
assert(allocated_regions = _allocation_region, "expected region %u at end of array, found %u",
_allocation_region->hrm_index(), _allocated_regions.at(index)->hrm_index());
HeapWord* = survivor_gc_alloc_region)->(min_word_size,
HeapWord* top = base_address;
while (index >= 0) {
HeapRegion* next = _allocated_regions.at(index);
HeapWord* new_top = next->top(); if (new_base != top) {
ranges>append(emRegionbase_address, pointer_delta(top, base_address)));
base_address = new_base;
}
top= new_top;
index = index - 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.