Skip to content

Commit 515783b

Browse files
committed
8328166: Epsilon: 'EpsilonHeap::allocate_work' misuses the parameter 'size' as size in bytes
Backport-of: 90ab52e598f74ed872fe404130d57f6596430727
1 parent 7c63791 commit 515783b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/hotspot/share/gc/epsilon/epsilonHeap.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -124,14 +124,15 @@ HeapWord* EpsilonHeap::allocate_work(size_t size, bool verbose) {
124124
}
125125

126126
// Expand and loop back if space is available
127+
size_t size_in_bytes = size * HeapWordSize;
127128
size_t space_left = max_capacity() - capacity();
128-
size_t want_space = MAX2(size, EpsilonMinHeapExpand);
129+
size_t want_space = MAX2(size_in_bytes, EpsilonMinHeapExpand);
129130

130131
if (want_space < space_left) {
131132
// Enough space to expand in bulk:
132133
bool expand = _virtual_space.expand_by(want_space);
133134
assert(expand, "Should be able to expand");
134-
} else if (size < space_left) {
135+
} else if (size_in_bytes < space_left) {
135136
// No space to expand in bulk, and this allocation is still possible,
136137
// take all the remaining space:
137138
bool expand = _virtual_space.expand_by(space_left);

0 commit comments

Comments
 (0)