26
26
#include " gc/z/zAddress.inline.hpp"
27
27
#include " gc/z/zGlobals.hpp"
28
28
#include " gc/z/zList.inline.hpp"
29
+ #include " gc/z/zMapper_windows.hpp"
29
30
#include " gc/z/zMemory.inline.hpp"
30
31
#include " gc/z/zSyscall_windows.hpp"
31
32
#include " gc/z/zVirtualMemory.hpp"
@@ -43,7 +44,9 @@ class ZMapperTest : public Test {
43
44
static bool _initialized;
44
45
static ZMemoryManager* _va;
45
46
46
- ZVirtualMemoryManager* _vmm;
47
+ static ZVirtualMemoryManager* _vmm;
48
+
49
+ static bool _has_unreserved;
47
50
48
51
public:
49
52
bool reserve_for_test () {
@@ -87,6 +90,7 @@ class ZMapperTest : public Test {
87
90
}
88
91
89
92
_initialized = true ;
93
+ _has_unreserved = false ;
90
94
}
91
95
92
96
virtual void TearDown () {
@@ -95,12 +99,26 @@ class ZMapperTest : public Test {
95
99
return ;
96
100
}
97
101
98
- if (_initialized) {
102
+ if (_initialized && !_has_unreserved ) {
99
103
_vmm->pd_unreserve (ZOffset::address_unsafe (zoffset (0 )), 0 );
100
104
}
101
105
os::free (_vmm);
102
106
}
103
107
108
+ static void test_unreserve () {
109
+ zoffset bottom = _va->alloc_low_address (ZGranuleSize);
110
+ zoffset top = _va->alloc_high_address (ZGranuleSize);
111
+
112
+ // Unreserve the middle part
113
+ ZMapper::unreserve (ZOffset::address_unsafe (bottom + ZGranuleSize), ZGranuleSize);
114
+
115
+ // Make sure that we still can unreserve the memory before and after
116
+ ZMapper::unreserve (ZOffset::address_unsafe (bottom), ZGranuleSize);
117
+ ZMapper::unreserve (ZOffset::address_unsafe (top), ZGranuleSize);
118
+
119
+ _has_unreserved = true ;
120
+ }
121
+
104
122
static void test_alloc_low_address () {
105
123
// Verify that we get placeholder for first granule
106
124
zoffset bottom = _va->alloc_low_address (ZGranuleSize);
@@ -170,6 +188,12 @@ class ZMapperTest : public Test {
170
188
171
189
bool ZMapperTest::_initialized = false ;
172
190
ZMemoryManager* ZMapperTest::_va = nullptr ;
191
+ ZVirtualMemoryManager* ZMapperTest::_vmm = nullptr ;
192
+ bool ZMapperTest::_has_unreserved;
193
+
194
+ TEST_VM_F (ZMapperTest, test_unreserve) {
195
+ test_unreserve ();
196
+ }
173
197
174
198
TEST_VM_F (ZMapperTest, test_alloc_low_address) {
175
199
test_alloc_low_address ();
0 commit comments