From 6716ccb0d9a52070e7e1842e442821f434f66858 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 22 Apr 2024 10:26:25 +0200 Subject: [PATCH] Backport 90ab52e598f74ed872fe404130d57f6596430727 --- src/hotspot/share/gc/epsilon/epsilonHeap.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp index b4cc8dd8a79..34c4a862348 100644 --- a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,14 +127,15 @@ HeapWord* EpsilonHeap::allocate_work(size_t size) { } // Expand and loop back if space is available + size_t size_in_bytes = size * HeapWordSize; size_t space_left = max_capacity() - capacity(); - size_t want_space = MAX2(size, EpsilonMinHeapExpand); + size_t want_space = MAX2(size_in_bytes, EpsilonMinHeapExpand); if (want_space < space_left) { // Enough space to expand in bulk: bool expand = _virtual_space.expand_by(want_space); assert(expand, "Should be able to expand"); - } else if (size < space_left) { + } else if (size_in_bytes < space_left) { // No space to expand in bulk, and this allocation is still possible, // take all the remaining space: bool expand = _virtual_space.expand_by(space_left);