Skip to content

Commit

Permalink
8308766: TLAB initialization may cause div by zero
Browse files Browse the repository at this point in the history
Backport-of: 96ed1392d1c5062063b1f8b5f1bd30d2d17ce3fe
  • Loading branch information
shipilev committed Jul 5, 2023
1 parent 4d261ef commit 90345a4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ void ThreadLocalAllocBuffer::initialize() {
set_desired_size(initial_desired_size());

size_t capacity = Universe::heap()->tlab_capacity(thread()) / HeapWordSize;
// Keep alloc_frac as float and not double to avoid the double to float conversion
float alloc_frac = desired_size() * target_refills() / (float) capacity;
_allocation_fraction.sample(alloc_frac);
if (capacity > 0) {
// Keep alloc_frac as float and not double to avoid the double to float conversion
float alloc_frac = desired_size() * target_refills() / (float)capacity;
_allocation_fraction.sample(alloc_frac);
}

set_refill_waste_limit(initial_refill_waste_limit());

Expand Down

1 comment on commit 90345a4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.