@@ -1478,55 +1478,6 @@ HeapWord* ShenandoahFreeSet::try_allocate_from_mutator(ShenandoahAllocRequest& r
14781478 return nullptr ;
14791479}
14801480
1481- // This work method takes an argument corresponding to the number of bytes
1482- // free in a region, and returns the largest amount in heapwords that can be allocated
1483- // such that both of the following conditions are satisfied:
1484- //
1485- // 1. it is a multiple of card size
1486- // 2. any remaining shard may be filled with a filler object
1487- //
1488- // The idea is that the allocation starts and ends at card boundaries. Because
1489- // a region ('s end) is card-aligned, the remainder shard that must be filled is
1490- // at the start of the free space.
1491- //
1492- // This is merely a helper method to use for the purpose of such a calculation.
1493- size_t ShenandoahFreeSet::get_usable_free_words (size_t free_bytes) const {
1494- // e.g. card_size is 512, card_shift is 9, min_fill_size() is 8
1495- // free is 514
1496- // usable_free is 512, which is decreased to 0
1497- size_t usable_free = (free_bytes / CardTable::card_size ()) << CardTable::card_shift ();
1498- assert (usable_free <= free_bytes, " Sanity check" );
1499- if ((free_bytes != usable_free) && (free_bytes - usable_free < ShenandoahHeap::min_fill_size () * HeapWordSize)) {
1500- // After aligning to card multiples, the remainder would be smaller than
1501- // the minimum filler object, so we'll need to take away another card's
1502- // worth to construct a filler object.
1503- if (usable_free >= CardTable::card_size ()) {
1504- usable_free -= CardTable::card_size ();
1505- } else {
1506- assert (usable_free == 0 , " usable_free is a multiple of card_size and card_size > min_fill_size" );
1507- }
1508- }
1509-
1510- return usable_free / HeapWordSize;
1511- }
1512-
1513- // Given a size argument, which is a multiple of card size, a request struct
1514- // for a PLAB, and an old region, return a pointer to the allocated space for
1515- // a PLAB which is card-aligned and where any remaining shard in the region
1516- // has been suitably filled by a filler object.
1517- // It is assumed (and assertion-checked) that such an allocation is always possible.
1518- HeapWord* ShenandoahFreeSet::allocate_aligned_plab (size_t size, ShenandoahAllocRequest& req, ShenandoahHeapRegion* r) {
1519- assert (_heap->mode ()->is_generational (), " PLABs are only for generational mode" );
1520- assert (r->is_old (), " All PLABs reside in old-gen" );
1521- assert (!req.is_mutator_alloc (), " PLABs should not be allocated by mutators." );
1522- assert (is_aligned (size, CardTable::card_size_in_words ()), " Align by design" );
1523-
1524- HeapWord* result = r->allocate_aligned (size, req, CardTable::card_size ());
1525- assert (result != nullptr , " Allocation cannot fail" );
1526- assert (r->top () <= r->end (), " Allocation cannot span end of region" );
1527- assert (is_aligned (result, CardTable::card_size_in_words ()), " Align by design" );
1528- return result;
1529- }
15301481
15311482HeapWord* ShenandoahFreeSet::try_allocate_in (ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool & in_new_region) {
15321483 assert (has_alloc_capacity (r), " Performance: should avoid full regions on this path: %zu" , r->index ());
@@ -1578,44 +1529,17 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
15781529 // req.size() is in words, r->free() is in bytes.
15791530 if (req.is_lab_alloc ()) {
15801531 size_t adjusted_size = req.size ();
1581- size_t free = r->free (); // free represents bytes available within region r
1582- if (req.is_old ()) {
1583- // This is a PLAB allocation(lab alloc in old gen)
1584- assert (_heap->mode ()->is_generational (), " PLABs are only for generational mode" );
1585- assert (_partitions.in_free_set (ShenandoahFreeSetPartitionId::OldCollector, r->index ()),
1586- " PLABS must be allocated in old_collector_free regions" );
1587-
1588- // Need to assure that plabs are aligned on multiple of card region
1589- // Convert free from unaligned bytes to aligned number of words
1590- size_t usable_free = get_usable_free_words (free);
1591- if (adjusted_size > usable_free) {
1592- adjusted_size = usable_free;
1593- }
1594- adjusted_size = align_down (adjusted_size, CardTable::card_size_in_words ());
1595- if (adjusted_size >= req.min_size ()) {
1596- result = allocate_aligned_plab (adjusted_size, req, r);
1597- assert (result != nullptr , " allocate must succeed" );
1598- req.set_actual_size (adjusted_size);
1599- } else {
1600- // Otherwise, leave result == nullptr because the adjusted size is smaller than min size.
1601- log_trace (gc, free)(" Failed to shrink PLAB request (%zu) in region %zu to %zu"
1602- " because min_size() is %zu" , req.size (), r->index (), adjusted_size, req.min_size ());
1603- }
1532+ size_t free = align_down (r->free () >> LogHeapWordSize, MinObjAlignment);
1533+ if (adjusted_size > free) {
1534+ adjusted_size = free;
1535+ }
1536+ if (adjusted_size >= req.min_size ()) {
1537+ result = r->allocate (adjusted_size, req);
1538+ assert (result != nullptr , " Allocation must succeed: free %zu, actual %zu" , free, adjusted_size);
1539+ req.set_actual_size (adjusted_size);
16041540 } else {
1605- // This is a GCLAB or a TLAB allocation
1606- // Convert free from unaligned bytes to aligned number of words
1607- free = align_down (free >> LogHeapWordSize, MinObjAlignment);
1608- if (adjusted_size > free) {
1609- adjusted_size = free;
1610- }
1611- if (adjusted_size >= req.min_size ()) {
1612- result = r->allocate (adjusted_size, req);
1613- assert (result != nullptr , " Allocation must succeed: free %zu, actual %zu" , free, adjusted_size);
1614- req.set_actual_size (adjusted_size);
1615- } else {
1616- log_trace (gc, free)(" Failed to shrink TLAB or GCLAB request (%zu) in region %zu to %zu"
1617- " because min_size() is %zu" , req.size (), r->index (), adjusted_size, req.min_size ());
1618- }
1541+ log_trace (gc, free)(" Failed to shrink LAB request (%zu) in region %zu to %zu"
1542+ " because min_size() is %zu" , req.size (), r->index (), adjusted_size, req.min_size ());
16191543 }
16201544 } else {
16211545 size_t size = req.size ();
0 commit comments