Skip to content

Commit

Permalink
8302661: Parallel: Remove PSVirtualSpace::is_aligned
Browse files Browse the repository at this point in the history
Reviewed-by: stefank, tschatzl
  • Loading branch information
albertnetymk committed Feb 17, 2023
1 parent edf238b commit ea5bfea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
29 changes: 8 additions & 21 deletions src/hotspot/share/gc/parallel/psVirtualspace.cpp
Expand Up @@ -26,6 +26,7 @@
#include "gc/parallel/psVirtualspace.hpp"
#include "memory/virtualspace.hpp"
#include "runtime/os.hpp"
#include "utilities/align.hpp"

// PSVirtualSpace

Expand Down Expand Up @@ -68,7 +69,7 @@ void PSVirtualSpace::release() {
}

bool PSVirtualSpace::expand_by(size_t bytes) {
assert(is_aligned(bytes), "arg not aligned");
assert(is_aligned(bytes, _alignment), "arg not aligned");
DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

if (uncommitted_size() < bytes) {
Expand All @@ -86,7 +87,7 @@ bool PSVirtualSpace::expand_by(size_t bytes) {
}

bool PSVirtualSpace::shrink_by(size_t bytes) {
assert(is_aligned(bytes), "arg not aligned");
assert(is_aligned(bytes, _alignment), "arg not aligned");
DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));

if (committed_size() < bytes) {
Expand All @@ -103,26 +104,12 @@ bool PSVirtualSpace::shrink_by(size_t bytes) {
}

#ifndef PRODUCT
bool PSVirtualSpace::is_aligned(size_t value, size_t align) {
const size_t tmp_value = value + align - 1;
const size_t mask = ~(align - 1);
return (tmp_value & mask) == value;
}

bool PSVirtualSpace::is_aligned(size_t value) const {
return is_aligned(value, alignment());
}

bool PSVirtualSpace::is_aligned(char* value) const {
return is_aligned((size_t)value);
}

void PSVirtualSpace::verify() const {
assert(is_aligned(alignment(), os::vm_page_size()), "bad alignment");
assert(is_aligned(reserved_low_addr()), "bad reserved_low_addr");
assert(is_aligned(reserved_high_addr()), "bad reserved_high_addr");
assert(is_aligned(committed_low_addr()), "bad committed_low_addr");
assert(is_aligned(committed_high_addr()), "bad committed_high_addr");
assert(is_aligned(_alignment, os::vm_page_size()), "bad alignment");
assert(is_aligned(reserved_low_addr(), _alignment), "bad reserved_low_addr");
assert(is_aligned(reserved_high_addr(), _alignment), "bad reserved_high_addr");
assert(is_aligned(committed_low_addr(), _alignment), "bad committed_low_addr");
assert(is_aligned(committed_high_addr(), _alignment), "bad committed_high_addr");

// Reserved region must be non-empty or both addrs must be 0.
assert(reserved_low_addr() < reserved_high_addr() ||
Expand Down
7 changes: 2 additions & 5 deletions src/hotspot/share/gc/parallel/psVirtualspace.hpp
Expand Up @@ -35,7 +35,7 @@

class PSVirtualSpace : public CHeapObj<mtGC> {
friend class VMStructs;
protected:

// The space is committed/uncommitted in chunks of size _alignment. The
// ReservedSpace passed to initialize() must be aligned to this value.
const size_t _alignment;
Expand Down Expand Up @@ -94,10 +94,7 @@ class PSVirtualSpace : public CHeapObj<mtGC> {

#ifndef PRODUCT
// Debugging
static bool is_aligned(size_t val, size_t align);
bool is_aligned(size_t val) const;
bool is_aligned(char* val) const;
void verify() const;
void verify() const;

// Helper class to verify a space when entering/leaving a block.
class PSVirtualSpaceVerifier: public StackObj {
Expand Down

1 comment on commit ea5bfea

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