105 gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap " |
107 gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap " |
106 SIZE_FORMAT" Maximum heap "SIZE_FORMAT" Min alignment "SIZE_FORMAT" Max alignment "SIZE_FORMAT, |
108 SIZE_FORMAT" Maximum heap "SIZE_FORMAT" Min alignment "SIZE_FORMAT" Max alignment "SIZE_FORMAT, |
107 p->min_heap_byte_size(), p->initial_heap_byte_size(), p->max_heap_byte_size(), |
109 p->min_heap_byte_size(), p->initial_heap_byte_size(), p->max_heap_byte_size(), |
108 p->space_alignment(), p->heap_alignment()); |
110 p->space_alignment(), p->heap_alignment()); |
109 } |
111 } |
|
112 WB_END |
|
113 |
|
114 #ifndef PRODUCT |
|
115 // Forward declaration |
|
116 void TestReservedSpace_test(); |
|
117 void TestReserveMemorySpecial_test(); |
|
118 void TestVirtualSpace_test(); |
|
119 void TestMetaspaceAux_test(); |
|
120 #endif |
|
121 |
|
122 WB_ENTRY(void, WB_RunMemoryUnitTests(JNIEnv* env, jobject o)) |
|
123 #ifndef PRODUCT |
|
124 TestReservedSpace_test(); |
|
125 TestReserveMemorySpecial_test(); |
|
126 TestVirtualSpace_test(); |
|
127 TestMetaspaceAux_test(); |
|
128 #endif |
|
129 WB_END |
|
130 |
|
131 WB_ENTRY(void, WB_ReadFromNoaccessArea(JNIEnv* env, jobject o)) |
|
132 size_t granularity = os::vm_allocation_granularity(); |
|
133 ReservedHeapSpace rhs(100 * granularity, granularity, false, NULL); |
|
134 VirtualSpace vs; |
|
135 vs.initialize(rhs, 50 * granularity); |
|
136 |
|
137 //Check if constraints are complied |
|
138 if (!( UseCompressedOops && rhs.base() != NULL && |
|
139 Universe::narrow_oop_base() != NULL && |
|
140 Universe::narrow_oop_use_implicit_null_checks() )) { |
|
141 tty->print_cr("WB_ReadFromNoaccessArea method is useless:\n " |
|
142 "\tUseCompressedOops is %d\n" |
|
143 "\trhs.base() is "PTR_FORMAT"\n" |
|
144 "\tUniverse::narrow_oop_base() is "PTR_FORMAT"\n" |
|
145 "\tUniverse::narrow_oop_use_implicit_null_checks() is %d", |
|
146 UseCompressedOops, |
|
147 rhs.base(), |
|
148 Universe::narrow_oop_base(), |
|
149 Universe::narrow_oop_use_implicit_null_checks()); |
|
150 return; |
|
151 } |
|
152 tty->print_cr("Reading from no access area... "); |
|
153 tty->print_cr("*(vs.low_boundary() - rhs.noaccess_prefix() / 2 ) = %c", |
|
154 *(vs.low_boundary() - rhs.noaccess_prefix() / 2 )); |
|
155 WB_END |
|
156 |
|
157 static jint wb_stress_virtual_space_resize(size_t reserved_space_size, |
|
158 size_t magnitude, size_t iterations) { |
|
159 size_t granularity = os::vm_allocation_granularity(); |
|
160 ReservedHeapSpace rhs(reserved_space_size * granularity, granularity, false, NULL); |
|
161 VirtualSpace vs; |
|
162 if (!vs.initialize(rhs, 0)) { |
|
163 tty->print_cr("Failed to initialize VirtualSpace. Can't proceed."); |
|
164 return 3; |
|
165 } |
|
166 |
|
167 long seed = os::random(); |
|
168 tty->print_cr("Random seed is %ld", seed); |
|
169 os::init_random(seed); |
|
170 |
|
171 for (size_t i = 0; i < iterations; i++) { |
|
172 |
|
173 // Whether we will shrink or grow |
|
174 bool shrink = os::random() % 2L == 0; |
|
175 |
|
176 // Get random delta to resize virtual space |
|
177 size_t delta = (size_t)os::random() % magnitude; |
|
178 |
|
179 // If we are about to shrink virtual space below zero, then expand instead |
|
180 if (shrink && vs.committed_size() < delta) { |
|
181 shrink = false; |
|
182 } |
|
183 |
|
184 // Resizing by delta |
|
185 if (shrink) { |
|
186 vs.shrink_by(delta); |
|
187 } else { |
|
188 // If expanding fails expand_by will silently return false |
|
189 vs.expand_by(delta, true); |
|
190 } |
|
191 } |
|
192 return 0; |
|
193 } |
|
194 |
|
195 WB_ENTRY(jint, WB_StressVirtualSpaceResize(JNIEnv* env, jobject o, |
|
196 jlong reserved_space_size, jlong magnitude, jlong iterations)) |
|
197 tty->print_cr("reservedSpaceSize="JLONG_FORMAT", magnitude="JLONG_FORMAT", " |
|
198 "iterations="JLONG_FORMAT"\n", reserved_space_size, magnitude, |
|
199 iterations); |
|
200 if (reserved_space_size < 0 || magnitude < 0 || iterations < 0) { |
|
201 tty->print_cr("One of variables printed above is negative. Can't proceed.\n"); |
|
202 return 1; |
|
203 } |
|
204 |
|
205 // sizeof(size_t) depends on whether OS is 32bit or 64bit. sizeof(jlong) is |
|
206 // always 8 byte. That's why we should avoid overflow in case of 32bit platform. |
|
207 if (sizeof(size_t) < sizeof(jlong)) { |
|
208 jlong size_t_max_value = (jlong) SIZE_T_MAX_VALUE; |
|
209 if (reserved_space_size > size_t_max_value || magnitude > size_t_max_value |
|
210 || iterations > size_t_max_value) { |
|
211 tty->print_cr("One of variables printed above overflows size_t. Can't proceed.\n"); |
|
212 return 2; |
|
213 } |
|
214 } |
|
215 |
|
216 return wb_stress_virtual_space_resize((size_t) reserved_space_size, |
|
217 (size_t) magnitude, (size_t) iterations); |
110 WB_END |
218 WB_END |
111 |
219 |
112 #if INCLUDE_ALL_GCS |
220 #if INCLUDE_ALL_GCS |
113 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) |
221 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) |
114 G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
222 G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
443 (void*) &WB_ParseCommandLine |
551 (void*) &WB_ParseCommandLine |
444 }, |
552 }, |
445 {CC"getCompressedOopsMaxHeapSize", CC"()J", |
553 {CC"getCompressedOopsMaxHeapSize", CC"()J", |
446 (void*)&WB_GetCompressedOopsMaxHeapSize}, |
554 (void*)&WB_GetCompressedOopsMaxHeapSize}, |
447 {CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes }, |
555 {CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes }, |
|
556 {CC"runMemoryUnitTests", CC"()V", (void*)&WB_RunMemoryUnitTests}, |
|
557 {CC"readFromNoaccessArea",CC"()V", (void*)&WB_ReadFromNoaccessArea}, |
|
558 {CC"stressVirtualSpaceResize",CC"(JJJ)I", (void*)&WB_StressVirtualSpaceResize}, |
448 #if INCLUDE_ALL_GCS |
559 #if INCLUDE_ALL_GCS |
449 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, |
560 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, |
450 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, |
561 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, |
451 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
562 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
452 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
563 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |