Skip to content

Commit

Permalink
8265066: Split ReservedSpace constructor to avoid default parameter
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, stefank
  • Loading branch information
kstefanj committed Apr 19, 2021
1 parent c607d12 commit e390e55
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/hotspot/share/memory/heap.cpp
Expand Up @@ -227,7 +227,8 @@ bool CodeHeap::reserve(ReservedSpace rs, size_t committed_size, size_t segment_s
const size_t committed_segments_size = align_to_page_size(_number_of_committed_segments);

// reserve space for _segmap
if (!_segmap.initialize(reserved_segments_size, committed_segments_size)) {
ReservedSpace seg_rs(reserved_segments_size);
if (!_segmap.initialize(seg_rs, committed_segments_size)) {
return false;
}

Expand Down
30 changes: 17 additions & 13 deletions src/hotspot/share/memory/virtualspace.cpp
Expand Up @@ -44,21 +44,25 @@ ReservedSpace::ReservedSpace() : _base(NULL), _size(0), _noaccess_prefix(0),
_alignment(0), _special(false), _fd_for_heap(-1), _executable(false) {
}

ReservedSpace::ReservedSpace(size_t size, size_t preferred_page_size) : _fd_for_heap(-1) {
bool has_preferred_page_size = preferred_page_size != 0;
// Want to use large pages where possible and pad with small pages.
size_t page_size = has_preferred_page_size ? preferred_page_size : os::page_size_for_region_unaligned(size, 1);
ReservedSpace::ReservedSpace(size_t size) : _fd_for_heap(-1) {
// Want to use large pages where possible. If the size is
// not large page aligned the mapping will be a mix of
// large and normal pages.
size_t page_size = os::page_size_for_region_unaligned(size, 1);
size_t alignment = os::vm_allocation_granularity();
bool large_pages = page_size != (size_t)os::vm_page_size();
size_t alignment;
if (large_pages && has_preferred_page_size) {
alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity());
// ReservedSpace initialization requires size to be aligned to the given
// alignment. Align the size up.
initialize(size, alignment, large_pages, NULL, false);
}

ReservedSpace::ReservedSpace(size_t size, size_t preferred_page_size) : _fd_for_heap(-1) {
// When a page size is given we don't want to mix large
// and normal pages. If the size is not a multiple of the
// page size it will be aligned up to achieve this.
size_t alignment = os::vm_allocation_granularity();;
bool large_pages = preferred_page_size != (size_t)os::vm_page_size();
if (large_pages) {
alignment = MAX2(preferred_page_size, alignment);
size = align_up(size, alignment);
} else {
// Don't force the alignment to be large page aligned,
// since that will waste memory.
alignment = os::vm_allocation_granularity();
}
initialize(size, alignment, large_pages, NULL, false);
}
Expand Down
11 changes: 7 additions & 4 deletions src/hotspot/share/memory/virtualspace.hpp
Expand Up @@ -66,11 +66,14 @@ class ReservedSpace {
public:
// Constructor
ReservedSpace();
// Initialize the reserved space with the given size. If preferred_page_size
// is set, use this as minimum page size/alignment. This may waste some space
// if the given size is not aligned to that value, as the reservation will be
// Initialize the reserved space with the given size. Depending on the size
// a suitable page size and alignment will be used.
explicit ReservedSpace(size_t size);
// Initialize the reserved space with the given size. The preferred_page_size
// is used as the minimum page size/alignment. This may waste some space if
// the given size is not aligned to that value, as the reservation will be
// aligned up to the final alignment in this case.
ReservedSpace(size_t size, size_t preferred_page_size = 0);
ReservedSpace(size_t size, size_t preferred_page_size);
ReservedSpace(size_t size, size_t alignment, bool large,
char* requested_address = NULL);

Expand Down

1 comment on commit e390e55

@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.