Skip to content

Commit bcc83cd

Browse files
committed
8328166: Epsilon: 'EpsilonHeap::allocate_work' misuses the parameter 'size' as size in bytes
Reviewed-by: stuefe Backport-of: 90ab52e598f74ed872fe404130d57f6596430727
1 parent b13cb2f commit bcc83cd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
56
* This code is free software; you can redistribute it and/or modify it
@@ -126,14 +127,15 @@ HeapWord* EpsilonHeap::allocate_work(size_t size) {
126127
}
127128

128129
// Expand and loop back if space is available
130+
size_t size_in_bytes = size * HeapWordSize;
129131
size_t space_left = max_capacity() - capacity();
130-
size_t want_space = MAX2(size, EpsilonMinHeapExpand);
132+
size_t want_space = MAX2(size_in_bytes, EpsilonMinHeapExpand);
131133

132134
if (want_space < space_left) {
133135
// Enough space to expand in bulk:
134136
bool expand = _virtual_space.expand_by(want_space);
135137
assert(expand, "Should be able to expand");
136-
} else if (size < space_left) {
138+
} else if (size_in_bytes < space_left) {
137139
// No space to expand in bulk, and this allocation is still possible,
138140
// take all the remaining space:
139141
bool expand = _virtual_space.expand_by(space_left);

0 commit comments

Comments
 (0)