8329840: Fix ZPhysicalMemorySegment::_end type
Reviewed-by: stefank, eosterlund
This commit is contained in:
parent
dfaf11a3d8
commit
b4ddddeff1
src/hotspot/share/gc/z
test/hotspot/gtest/gc/z
@ -133,6 +133,10 @@ inline bool operator<(zoffset first, zoffset_end second) {
|
||||
return untype(first) < untype(second);
|
||||
}
|
||||
|
||||
inline bool operator<=(zoffset_end first, zoffset second) {
|
||||
return untype(first) <= untype(second);
|
||||
}
|
||||
|
||||
inline bool operator>(zoffset first, zoffset_end second) {
|
||||
return untype(first) > untype(second);
|
||||
}
|
||||
|
@ -32,16 +32,16 @@
|
||||
|
||||
class ZPhysicalMemorySegment : public CHeapObj<mtGC> {
|
||||
private:
|
||||
zoffset _start;
|
||||
zoffset _end;
|
||||
bool _committed;
|
||||
zoffset _start;
|
||||
zoffset_end _end;
|
||||
bool _committed;
|
||||
|
||||
public:
|
||||
ZPhysicalMemorySegment();
|
||||
ZPhysicalMemorySegment(zoffset start, size_t size, bool committed);
|
||||
|
||||
zoffset start() const;
|
||||
zoffset end() const;
|
||||
zoffset_end end() const;
|
||||
size_t size() const;
|
||||
|
||||
bool is_committed() const;
|
||||
|
@ -31,19 +31,19 @@
|
||||
|
||||
inline ZPhysicalMemorySegment::ZPhysicalMemorySegment()
|
||||
: _start(zoffset(UINTPTR_MAX)),
|
||||
_end(zoffset(UINTPTR_MAX)),
|
||||
_end(zoffset_end(UINTPTR_MAX)),
|
||||
_committed(false) {}
|
||||
|
||||
inline ZPhysicalMemorySegment::ZPhysicalMemorySegment(zoffset start, size_t size, bool committed)
|
||||
: _start(start),
|
||||
_end(start + size),
|
||||
_end(to_zoffset_end(start, size)),
|
||||
_committed(committed) {}
|
||||
|
||||
inline zoffset ZPhysicalMemorySegment::start() const {
|
||||
return _start;
|
||||
}
|
||||
|
||||
inline zoffset ZPhysicalMemorySegment::end() const {
|
||||
inline zoffset_end ZPhysicalMemorySegment::end() const {
|
||||
return _end;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,27 @@
|
||||
#include "gc/z/zPhysicalMemory.inline.hpp"
|
||||
#include "unittest.hpp"
|
||||
|
||||
class ZAddressOffsetMaxSetter {
|
||||
private:
|
||||
const size_t _old_max;
|
||||
const size_t _old_mask;
|
||||
|
||||
public:
|
||||
ZAddressOffsetMaxSetter()
|
||||
: _old_max(ZAddressOffsetMax),
|
||||
_old_mask(ZAddressOffsetMask) {
|
||||
ZAddressOffsetMax = size_t(16) * G * 1024;
|
||||
ZAddressOffsetMask = ZAddressOffsetMax - 1;
|
||||
}
|
||||
~ZAddressOffsetMaxSetter() {
|
||||
ZAddressOffsetMax = _old_max;
|
||||
ZAddressOffsetMask = _old_mask;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(ZPhysicalMemoryTest, copy) {
|
||||
ZAddressOffsetMaxSetter setter;
|
||||
|
||||
const ZPhysicalMemorySegment seg0(zoffset(0), 100, true);
|
||||
const ZPhysicalMemorySegment seg1(zoffset(200), 100, true);
|
||||
|
||||
@ -52,6 +72,8 @@ TEST(ZPhysicalMemoryTest, copy) {
|
||||
}
|
||||
|
||||
TEST(ZPhysicalMemoryTest, add) {
|
||||
ZAddressOffsetMaxSetter setter;
|
||||
|
||||
const ZPhysicalMemorySegment seg0(zoffset(0), 1, true);
|
||||
const ZPhysicalMemorySegment seg1(zoffset(1), 1, true);
|
||||
const ZPhysicalMemorySegment seg2(zoffset(2), 1, true);
|
||||
@ -114,6 +136,8 @@ TEST(ZPhysicalMemoryTest, add) {
|
||||
}
|
||||
|
||||
TEST(ZPhysicalMemoryTest, remove) {
|
||||
ZAddressOffsetMaxSetter setter;
|
||||
|
||||
ZPhysicalMemory pmem;
|
||||
|
||||
pmem.add_segment(ZPhysicalMemorySegment(zoffset(10), 10, true));
|
||||
@ -130,6 +154,8 @@ TEST(ZPhysicalMemoryTest, remove) {
|
||||
}
|
||||
|
||||
TEST(ZPhysicalMemoryTest, split) {
|
||||
ZAddressOffsetMaxSetter setter;
|
||||
|
||||
ZPhysicalMemory pmem;
|
||||
|
||||
pmem.add_segment(ZPhysicalMemorySegment(zoffset(0), 10, true));
|
||||
@ -158,6 +184,8 @@ TEST(ZPhysicalMemoryTest, split) {
|
||||
}
|
||||
|
||||
TEST(ZPhysicalMemoryTest, split_committed) {
|
||||
ZAddressOffsetMaxSetter setter;
|
||||
|
||||
ZPhysicalMemory pmem0;
|
||||
pmem0.add_segment(ZPhysicalMemorySegment(zoffset(0), 10, true));
|
||||
pmem0.add_segment(ZPhysicalMemorySegment(zoffset(10), 10, false));
|
||||
@ -172,3 +200,20 @@ TEST(ZPhysicalMemoryTest, split_committed) {
|
||||
EXPECT_EQ(pmem1.nsegments(), 2);
|
||||
EXPECT_EQ(pmem1.size(), 20u);
|
||||
}
|
||||
|
||||
TEST(ZPhysicalMemoryTest, limits) {
|
||||
ZAddressOffsetMaxSetter setter;
|
||||
|
||||
const size_t HalfZAddressOffsetMax = ZAddressOffsetMax >> 1;
|
||||
ZPhysicalMemory pmem0;
|
||||
pmem0.add_segment(ZPhysicalMemorySegment(zoffset(0), HalfZAddressOffsetMax, true));
|
||||
pmem0.add_segment(ZPhysicalMemorySegment(zoffset(HalfZAddressOffsetMax), HalfZAddressOffsetMax, false));
|
||||
EXPECT_EQ(pmem0.nsegments(), 2);
|
||||
EXPECT_EQ(pmem0.size(), ZAddressOffsetMax);
|
||||
|
||||
ZPhysicalMemory pmem1 = pmem0.split_committed();
|
||||
EXPECT_EQ(pmem0.nsegments(), 1);
|
||||
EXPECT_EQ(pmem0.size(), HalfZAddressOffsetMax);
|
||||
EXPECT_EQ(pmem1.nsegments(), 1);
|
||||
EXPECT_EQ(pmem1.size(), HalfZAddressOffsetMax);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user