< prev index next >

src/share/vm/gc_implementation/g1/g1Allocator.cpp

Print this page
rev 7471 : 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
Summary: Evaluate and improve object copy time by micro-optimizations and splitting out slow and fast paths aggressively.
Reviewed-by:
Contributed-by: Tony Printezis <tprintezis@twitter.com>, Thomas Schatzl <thomas.schatzl@oracle.com>


  96   _retained_old_gc_alloc_region = old_gc_alloc_region(context)->release();
  97   if (_retained_old_gc_alloc_region != NULL) {
  98     _retained_old_gc_alloc_region->record_retained_region();
  99   }
 100 
 101   if (ResizePLAB) {
 102     _g1h->_survivor_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
 103     _g1h->_old_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
 104   }
 105 }
 106 
 107 void G1DefaultAllocator::abandon_gc_alloc_regions() {
 108   assert(survivor_gc_alloc_region(AllocationContext::current())->get() == NULL, "pre-condition");
 109   assert(old_gc_alloc_region(AllocationContext::current())->get() == NULL, "pre-condition");
 110   _retained_old_gc_alloc_region = NULL;
 111 }
 112 
 113 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
 114   ParGCAllocBuffer(gclab_word_size), _retired(true) { }
 115 
 116 HeapWord* G1ParGCAllocator::allocate_slow(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context) {
 117   HeapWord* obj = NULL;
 118   size_t gclab_word_size = _g1h->desired_plab_sz(purpose);

 119   if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
 120     G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose, context);
 121     add_to_alloc_buffer_waste(alloc_buf->words_remaining());
 122     alloc_buf->retire(false /* end_of_gc */, false /* retain */);
 123 
 124     HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size, context);
 125     if (buf == NULL) {
 126       return NULL; // Let caller handle allocation failure.
 127     }
 128     // Otherwise.
 129     alloc_buf->set_word_size(gclab_word_size);
 130     alloc_buf->set_buf(buf);
 131 
 132     obj = alloc_buf->allocate(word_sz);
 133     assert(obj != NULL, "buffer was definitely big enough...");

 134   } else {
 135     obj = _g1h->par_allocate_during_gc(purpose, word_sz, context);
 136   }
 137   return obj;
 138 }
 139 
 140 G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) :
 141             G1ParGCAllocator(g1h),
 142             _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
 143             _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)) {
 144 
 145   _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
 146   _alloc_buffers[GCAllocForTenured]  = &_tenured_alloc_buffer;
 147 

 148 }
 149 
 150 void G1DefaultParGCAllocator::retire_alloc_buffers() {
 151   for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
 152     size_t waste = _alloc_buffers[ap]->words_remaining();
 153     add_to_alloc_buffer_waste(waste);
 154     _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap),

 155                                                true /* end_of_gc */,
 156                                                false /* retain */);

 157   }
 158 }


  96   _retained_old_gc_alloc_region = old_gc_alloc_region(context)->release();
  97   if (_retained_old_gc_alloc_region != NULL) {
  98     _retained_old_gc_alloc_region->record_retained_region();
  99   }
 100 
 101   if (ResizePLAB) {
 102     _g1h->_survivor_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
 103     _g1h->_old_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
 104   }
 105 }
 106 
 107 void G1DefaultAllocator::abandon_gc_alloc_regions() {
 108   assert(survivor_gc_alloc_region(AllocationContext::current())->get() == NULL, "pre-condition");
 109   assert(old_gc_alloc_region(AllocationContext::current())->get() == NULL, "pre-condition");
 110   _retained_old_gc_alloc_region = NULL;
 111 }
 112 
 113 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
 114   ParGCAllocBuffer(gclab_word_size), _retired(true) { }
 115 
 116 HeapWord* G1ParGCAllocator::allocate_direct_or_new_plab(in_cset_state_t dest,
 117                                                         size_t word_sz,
 118                                                         AllocationContext_t context) {
 119   size_t gclab_word_size = _g1h->desired_plab_sz(dest);
 120   if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
 121     G1ParGCAllocBuffer* alloc_buf = alloc_buffer(dest, context);
 122     add_to_alloc_buffer_waste(alloc_buf->words_remaining());
 123     alloc_buf->retire(false /* end_of_gc */, false /* retain */);
 124 
 125     HeapWord* buf = _g1h->par_allocate_during_gc(dest, gclab_word_size, context);
 126     if (buf == NULL) {
 127       return NULL; // Let caller handle allocation failure.
 128     }
 129     // Otherwise.
 130     alloc_buf->set_word_size(gclab_word_size);
 131     alloc_buf->set_buf(buf);
 132 
 133     HeapWord* const obj = alloc_buf->allocate(word_sz);
 134     assert(obj != NULL, "buffer was definitely big enough...");
 135     return obj;
 136   } else {
 137     return _g1h->par_allocate_during_gc(dest, word_sz, context);
 138   }

 139 }
 140 
 141 G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) :
 142   G1ParGCAllocator(g1h),
 143   _surviving_alloc_buffer(g1h->desired_plab_sz(InCSetState::Young)),
 144   _tenured_alloc_buffer(g1h->desired_plab_sz(InCSetState::Old)) {
 145   for (uint i = 0; i < InCSetState::Num; i += 1) {
 146     _alloc_buffers[i] = NULL;
 147   }
 148   _alloc_buffers[InCSetState::Young] = &_surviving_alloc_buffer;
 149   _alloc_buffers[InCSetState::Old]  = &_tenured_alloc_buffer;
 150 }
 151 
 152 void G1DefaultParGCAllocator::retire_alloc_buffers() {
 153   for (uint i = 0; i < InCSetState::Num; i += 1) {
 154     G1ParGCAllocBuffer* const buf = _alloc_buffers[i];
 155     if (buf != NULL) {
 156       add_to_alloc_buffer_waste(buf->words_remaining());
 157       buf->flush_stats_and_retire(_g1h->alloc_buffer_stats(i),
 158                                   true /* end_of_gc */,
 159                                   false /* retain */);
 160     }
 161   }
 162 }
< prev index next >