< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp

Print this page




 131           if (is_mutator_free(idx)) {
 132             HeapWord* result = try_allocate_in(_heap->get_region(idx), req, in_new_region);
 133             if (result != NULL) {
 134               return result;
 135             }
 136           }
 137         }
 138       }
 139       break;
 140     }
 141     default:
 142       ShouldNotReachHere();
 143   }
 144 
 145   return NULL;
 146 }
 147 
 148 HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) {
 149   assert (!has_no_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->region_number());
 150 





 151   try_recycle_trashed(r);
 152 
 153   in_new_region = r->is_empty();
 154 
 155   HeapWord* result = NULL;
 156   size_t size = req.size();
 157 
 158   if (ShenandoahElasticTLAB && req.is_lab_alloc()) {
 159     size_t free = align_down(r->free() >> LogHeapWordSize, MinObjAlignment);
 160     if (size > free) {
 161       size = free;
 162     }
 163     if (size >= req.min_size()) {
 164       result = r->allocate(size, req.type());
 165       assert (result != NULL, "Allocation must succeed: free " SIZE_FORMAT ", actual " SIZE_FORMAT, free, size);
 166     }
 167   } else {
 168     result = r->allocate(size, req.type());
 169   }
 170 




 131           if (is_mutator_free(idx)) {
 132             HeapWord* result = try_allocate_in(_heap->get_region(idx), req, in_new_region);
 133             if (result != NULL) {
 134               return result;
 135             }
 136           }
 137         }
 138       }
 139       break;
 140     }
 141     default:
 142       ShouldNotReachHere();
 143   }
 144 
 145   return NULL;
 146 }
 147 
 148 HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) {
 149   assert (!has_no_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->region_number());
 150 
 151   if (_heap->is_concurrent_root_in_progress() &&
 152       r->is_trash()) {
 153     return NULL;
 154   }
 155 
 156   try_recycle_trashed(r);
 157 
 158   in_new_region = r->is_empty();
 159 
 160   HeapWord* result = NULL;
 161   size_t size = req.size();
 162 
 163   if (ShenandoahElasticTLAB && req.is_lab_alloc()) {
 164     size_t free = align_down(r->free() >> LogHeapWordSize, MinObjAlignment);
 165     if (size > free) {
 166       size = free;
 167     }
 168     if (size >= req.min_size()) {
 169       result = r->allocate(size, req.type());
 170       assert (result != NULL, "Allocation must succeed: free " SIZE_FORMAT ", actual " SIZE_FORMAT, free, size);
 171     }
 172   } else {
 173     result = r->allocate(size, req.type());
 174   }
 175 


< prev index next >