220 }
221 return result;
222 }
223
224 G1PLABAllocator::G1PLABAllocator(G1Allocator* allocator) :
225 _g1h(G1CollectedHeap::heap()),
226 _allocator(allocator),
227 _survivor_alignment_bytes(calc_survivor_alignment_bytes()) {
228 for (size_t i = 0; i < ARRAY_SIZE(_direct_allocated); i++) {
229 _direct_allocated[i] = 0;
230 }
231 }
232
233 bool G1PLABAllocator::may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const {
234 return (allocation_word_sz * 100 < buffer_size * ParallelGCBufferWastePct);
235 }
236
237 HeapWord* G1PLABAllocator::allocate_direct_or_new_plab(InCSetState dest,
238 size_t word_sz,
239 bool* plab_refill_failed) {
240 size_t plab_word_size = G1CollectedHeap::heap()->desired_plab_sz(dest);
241 size_t required_in_plab = PLAB::size_required_for_allocation(word_sz);
242
243 // Only get a new PLAB if the allocation fits and it would not waste more than
244 // ParallelGCBufferWastePct in the existing buffer.
245 if ((required_in_plab <= plab_word_size) &&
246 may_throw_away_buffer(required_in_plab, plab_word_size)) {
247
248 PLAB* alloc_buf = alloc_buffer(dest);
249 alloc_buf->retire();
250
251 size_t actual_plab_size = 0;
252 HeapWord* buf = _allocator->par_allocate_during_gc(dest,
253 required_in_plab,
254 plab_word_size,
255 &actual_plab_size);
256
257 assert(buf == NULL || ((actual_plab_size >= required_in_plab) && (actual_plab_size <= plab_word_size)),
258 "Requested at minimum " SIZE_FORMAT ", desired " SIZE_FORMAT " words, but got " SIZE_FORMAT " at " PTR_FORMAT,
259 required_in_plab, plab_word_size, actual_plab_size, p2i(buf));
260
|
220 }
221 return result;
222 }
223
224 G1PLABAllocator::G1PLABAllocator(G1Allocator* allocator) :
225 _g1h(G1CollectedHeap::heap()),
226 _allocator(allocator),
227 _survivor_alignment_bytes(calc_survivor_alignment_bytes()) {
228 for (size_t i = 0; i < ARRAY_SIZE(_direct_allocated); i++) {
229 _direct_allocated[i] = 0;
230 }
231 }
232
233 bool G1PLABAllocator::may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const {
234 return (allocation_word_sz * 100 < buffer_size * ParallelGCBufferWastePct);
235 }
236
237 HeapWord* G1PLABAllocator::allocate_direct_or_new_plab(InCSetState dest,
238 size_t word_sz,
239 bool* plab_refill_failed) {
240 size_t plab_word_size = _g1h->desired_plab_sz(dest);
241 size_t required_in_plab = PLAB::size_required_for_allocation(word_sz);
242
243 // Only get a new PLAB if the allocation fits and it would not waste more than
244 // ParallelGCBufferWastePct in the existing buffer.
245 if ((required_in_plab <= plab_word_size) &&
246 may_throw_away_buffer(required_in_plab, plab_word_size)) {
247
248 PLAB* alloc_buf = alloc_buffer(dest);
249 alloc_buf->retire();
250
251 size_t actual_plab_size = 0;
252 HeapWord* buf = _allocator->par_allocate_during_gc(dest,
253 required_in_plab,
254 plab_word_size,
255 &actual_plab_size);
256
257 assert(buf == NULL || ((actual_plab_size >= required_in_plab) && (actual_plab_size <= plab_word_size)),
258 "Requested at minimum " SIZE_FORMAT ", desired " SIZE_FORMAT " words, but got " SIZE_FORMAT " at " PTR_FORMAT,
259 required_in_plab, plab_word_size, actual_plab_size, p2i(buf));
260
|