< prev index next >

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

Print this page

3111   ShenandoahFreeSetPartitionId p =
3112     r->is_old()? ShenandoahFreeSetPartitionId::OldCollector: ShenandoahFreeSetPartitionId::Mutator;
3113   _partitions.decrease_humongous_waste(p, waste);
3114   if (waste >= PLAB::min_size() * HeapWordSize) {
3115     _partitions.decrease_used(p, waste);
3116     _partitions.unretire_to_partition(r, p);
3117     if (r->is_old()) {
3118       recompute_total_used</* UsedByMutatorChanged */ false,
3119                            /* UsedByCollectorChanged */ false, /* UsedByOldCollectorChanged */ true>();
3120     } else {
3121       recompute_total_used</* UsedByMutatorChanged */ true,
3122                            /* UsedByCollectorChanged */ false, /* UsedByOldCollectorChanged */ false>();
3123     }
3124   }
3125   _total_humongous_waste -= waste;
3126 }
3127 
3128 
3129 HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_region) {
3130   shenandoah_assert_heaplocked();
3131   if (ShenandoahHeapRegion::requires_humongous(req.size())) {












3132     switch (req.type()) {
3133       case ShenandoahAllocRequest::_alloc_shared:
3134       case ShenandoahAllocRequest::_alloc_shared_gc:
3135         in_new_region = true;
3136         return allocate_contiguous(req, /* is_humongous = */ true);
3137       case ShenandoahAllocRequest::_alloc_cds:
3138         in_new_region = true;
3139         return allocate_contiguous(req, /* is_humongous = */ false);
3140       case ShenandoahAllocRequest::_alloc_plab:
3141       case ShenandoahAllocRequest::_alloc_gclab:
3142       case ShenandoahAllocRequest::_alloc_tlab:
3143         in_new_region = false;
3144         assert(false, "Trying to allocate TLAB in humongous region: %zu", req.size());
3145         return nullptr;
3146       default:
3147         ShouldNotReachHere();
3148         return nullptr;
3149     }
3150   } else {
3151     return allocate_single(req, in_new_region);

3111   ShenandoahFreeSetPartitionId p =
3112     r->is_old()? ShenandoahFreeSetPartitionId::OldCollector: ShenandoahFreeSetPartitionId::Mutator;
3113   _partitions.decrease_humongous_waste(p, waste);
3114   if (waste >= PLAB::min_size() * HeapWordSize) {
3115     _partitions.decrease_used(p, waste);
3116     _partitions.unretire_to_partition(r, p);
3117     if (r->is_old()) {
3118       recompute_total_used</* UsedByMutatorChanged */ false,
3119                            /* UsedByCollectorChanged */ false, /* UsedByOldCollectorChanged */ true>();
3120     } else {
3121       recompute_total_used</* UsedByMutatorChanged */ true,
3122                            /* UsedByCollectorChanged */ false, /* UsedByOldCollectorChanged */ false>();
3123     }
3124   }
3125   _total_humongous_waste -= waste;
3126 }
3127 
3128 
3129 HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_region) {
3130   shenandoah_assert_heaplocked();
3131   // A freshly allocated mutator object is not yet hashed and may grow by one word
3132   // when an identity hash-code is injected during a future GC copy. Classify it by
3133   // its potential expanded size so an object that could outgrow a region is placed
3134   // as humongous from the start, rather than allocated as a regular object and then
3135   // needing to become humongous after it grows. Every other request carries an
3136   // already-final size:
3137   //  - a GC copy (_alloc_shared_gc*) uses an already-expanded copy_size(),
3138   //  - a CDS allocation (_alloc_cds) requests a raw archive range; its objects are
3139   //    written at their final, already hash-expanded size (copy_size_cds) and are
3140   //    not grown at load time,
3141   //  - a LAB buffer (TLAB/GCLAB/PLAB, bounded by max_tlab_size_words()) never grows.
3142   const bool may_expand_for_hash = (req.type() == ShenandoahAllocRequest::_alloc_shared);
3143   if (ShenandoahHeapRegion::requires_humongous(req.size(), may_expand_for_hash)) {
3144     switch (req.type()) {
3145       case ShenandoahAllocRequest::_alloc_shared:
3146       case ShenandoahAllocRequest::_alloc_shared_gc:
3147         in_new_region = true;
3148         return allocate_contiguous(req, /* is_humongous = */ true);
3149       case ShenandoahAllocRequest::_alloc_cds:
3150         in_new_region = true;
3151         return allocate_contiguous(req, /* is_humongous = */ false);
3152       case ShenandoahAllocRequest::_alloc_plab:
3153       case ShenandoahAllocRequest::_alloc_gclab:
3154       case ShenandoahAllocRequest::_alloc_tlab:
3155         in_new_region = false;
3156         assert(false, "Trying to allocate TLAB in humongous region: %zu", req.size());
3157         return nullptr;
3158       default:
3159         ShouldNotReachHere();
3160         return nullptr;
3161     }
3162   } else {
3163     return allocate_single(req, in_new_region);
< prev index next >