RFR: 8311248: Refactor CodeCache::initialize_heaps to simplify adding new CodeCache segments [v4]

Evgeny Astigeevich eastigeevich at openjdk.org
Mon Jan 22 19:29:28 UTC 2024


On Thu, 18 Jan 2024 17:08:29 GMT, Boris Ulasevich <bulasevich at openjdk.org> wrote:

>> These changes clean up the logic and the code of allocating codecache segments and add more testing of it, to open a door for further optimization of code cache segmentation.  The goal was to keep the behavior as close to the existing behavior as possible, even if it's not quite logical.
>> 
>> Also, these changes better account for alignment - PrintFlagsFinal shows the final aligned segment sizes, and the segments fill the ReservedCodeCacheSize without gaps caused by alignment.
>
> Boris Ulasevich has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
> 
>   apply suggestions

src/hotspot/share/code/codeCache.cpp line 260:

> 258:     non_profiled.set = true;
> 259:     non_profiled.enabled = false;
> 260:   }

It can be rewritten to the shorter version:

// If either heap1 or heap2 is not available, its size is added to the size of the available heap.
static void reuse_unavailable_heap_size(CodeHeapInfo *heap1, CodeHeapInfo *heap2) {
   assert(CodeCache::heap_available(heap1->type) || CodeCache::heap_available(heap2->type), "At least one code heap must be available");
   if (!CodeCache::heap_available(heap1->type)) {
     swap(heap1, heap2);
   } else if (CodeCache::heap_available(heap2->type)) {
     // Both code heaps are available. Nothing needs to be done.
     return;
   }
   heap1->size += heap2->size;
   heap2->size = 0;
   heap2->set = true;
   heap2->enable = false;
}


Now we can replace those two IFs with:

// For compatibility we add the size of an unavailable code heap to the size of the available heap.
reuse_unavailable_heap_size(&non_profiled, &profiled);

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17244#discussion_r1462310190


More information about the hotspot-dev mailing list