Skip to content

Commit

Permalink
8328166: Epsilon: 'EpsilonHeap::allocate_work' misuses the parameter …
Browse files Browse the repository at this point in the history
…'size' as size in bytes

Reviewed-by: shade, tschatzl
  • Loading branch information
lgxbslgx committed Mar 15, 2024
1 parent bf990c8 commit 90ab52e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/hotspot/share/gc/epsilon/epsilonHeap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. 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.
*
Expand Down Expand Up @@ -124,14 +124,15 @@ HeapWord* EpsilonHeap::allocate_work(size_t size, bool verbose) {
}

// 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);
Expand Down

3 comments on commit 90ab52e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@shipilev
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on 90ab52e Apr 19, 2024

Choose a reason for hiding this comment

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

@shipilev the backport was successfully created on the branch backport-shipilev-90ab52e5 in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 90ab52e5 from the openjdk/jdk repository.

The commit being backported was authored by Guoxiong Li on 15 Mar 2024 and was reviewed by Aleksey Shipilev and Thomas Schatzl.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-shipilev-90ab52e5:backport-shipilev-90ab52e5
$ git checkout backport-shipilev-90ab52e5
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-shipilev-90ab52e5

Please sign in to comment.