< prev index next >

src/hotspot/share/cds/archiveUtils.cpp

Print this page

185   size_t commit = MAX2(min_bytes, preferred_bytes);
186   commit = MIN2(commit, uncommitted);
187   assert(commit <= uncommitted, "sanity");
188 
189   if (!_vs->expand_by(commit, false)) {
190     vm_exit_during_initialization(err_msg("Failed to expand shared space to " SIZE_FORMAT " bytes",
191                                           need_committed_size));
192   }
193 
194   const char* which;
195   if (_rs->base() == (char*)MetaspaceShared::symbol_rs_base()) {
196     which = "symbol";
197   } else {
198     which = "shared";
199   }
200   log_debug(cds)("Expanding %s spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9)  " bytes ending at %p]",
201                  which, commit, _vs->actual_committed_size(), _vs->high());
202 }
203 
204 
205 char* DumpRegion::allocate(size_t num_bytes) {
206   char* p = (char*)align_up(_top, (size_t)SharedSpaceObjectAlignment);
207   char* newtop = p + align_up(num_bytes, (size_t)SharedSpaceObjectAlignment);










208   expand_top_to(newtop);
209   memset(p, 0, newtop - p);
210   return p;
211 }
212 




213 void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) {
214   assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment");
215   intptr_t *p = (intptr_t*)_top;
216   char* newtop = _top + sizeof(intptr_t);
217   expand_top_to(newtop);
218   *p = n;
219   if (need_to_mark) {
220     ArchivePtrMarker::mark_pointer(p);
221   }
222 }
223 
224 void DumpRegion::print(size_t total_bytes) const {
225   log_debug(cds)("%-3s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT,
226                  _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()),
227                  p2i(ArchiveBuilder::current()->to_requested(_base)));
228 }
229 
230 void DumpRegion::print_out_of_space_msg(const char* failing_region, size_t needed_bytes) {
231   log_error(cds)("[%-8s] " PTR_FORMAT " - " PTR_FORMAT " capacity =%9d, allocated =%9d",
232                  _name, p2i(_base), p2i(_top), int(_end - _base), int(_top - _base));

284   intptr_t obj = nextPtr();
285   assert((intptr_t)obj >= 0 || (intptr_t)obj < -100,
286          "hit tag while initializing ptrs.");
287   *p = (void*)obj;
288 }
289 
290 void ReadClosure::do_u4(u4* p) {
291   intptr_t obj = nextPtr();
292   *p = (u4)(uintx(obj));
293 }
294 
295 void ReadClosure::do_bool(bool* p) {
296   intptr_t obj = nextPtr();
297   *p = (bool)(uintx(obj));
298 }
299 
300 void ReadClosure::do_tag(int tag) {
301   int old_tag;
302   old_tag = (int)(intptr_t)nextPtr();
303   // do_int(&old_tag);
304   assert(tag == old_tag, "old tag doesn't match");
305   FileMapInfo::assert_mark(tag == old_tag);
306 }
307 
308 void ReadClosure::do_oop(oop *p) {
309   narrowOop o = CompressedOops::narrow_oop_cast(nextPtr());
310   if (CompressedOops::is_null(o) || !HeapShared::is_fully_available()) {
311     *p = NULL;
312   } else {
313     assert(HeapShared::can_use(), "sanity");
314     assert(HeapShared::is_fully_available(), "must be");
315     *p = HeapShared::decode_from_archive(o);
316   }
317 }
318 
319 void ReadClosure::do_region(u_char* start, size_t size) {
320   assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
321   assert(size % sizeof(intptr_t) == 0, "bad size");
322   do_tag((int)size);
323   while (size > 0) {
324     *(intptr_t*)start = nextPtr();

185   size_t commit = MAX2(min_bytes, preferred_bytes);
186   commit = MIN2(commit, uncommitted);
187   assert(commit <= uncommitted, "sanity");
188 
189   if (!_vs->expand_by(commit, false)) {
190     vm_exit_during_initialization(err_msg("Failed to expand shared space to " SIZE_FORMAT " bytes",
191                                           need_committed_size));
192   }
193 
194   const char* which;
195   if (_rs->base() == (char*)MetaspaceShared::symbol_rs_base()) {
196     which = "symbol";
197   } else {
198     which = "shared";
199   }
200   log_debug(cds)("Expanding %s spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9)  " bytes ending at %p]",
201                  which, commit, _vs->actual_committed_size(), _vs->high());
202 }
203 
204 
205 char* DumpRegion::allocate(size_t num_bytes, size_t alignment) {
206   // We align the starting address of each allocation.
207   char* p = (char*)align_up(_top, alignment);
208   char* newtop = p + num_bytes;
209   // Leave _top always SharedSpaceObjectAlignment aligned. But not more -
210   //  if we allocate with large alignments, lets not waste the gaps.
211   // Ideally we would not need to align _top to anything here but CDS has
212   //  a number of implicit alignment assumptions. Leaving this unaligned
213   //  here will trip of at least ReadClosure (assuming word alignment) and
214   //  DumpAllocStats (will get confused about counting bytes on 32-bit
215   //  platforms if we align to anything less than SharedSpaceObjectAlignment
216   //  here).
217   newtop = align_up(newtop, SharedSpaceObjectAlignment);
218   expand_top_to(newtop);
219   memset(p, 0, newtop - p); // todo: needed? debug_only?
220   return p;
221 }
222 
223 char* DumpRegion::allocate(size_t num_bytes) {
224   return allocate(num_bytes, SharedSpaceObjectAlignment);
225 }
226 
227 void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) {
228   assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment");
229   intptr_t *p = (intptr_t*)_top;
230   char* newtop = _top + sizeof(intptr_t);
231   expand_top_to(newtop);
232   *p = n;
233   if (need_to_mark) {
234     ArchivePtrMarker::mark_pointer(p);
235   }
236 }
237 
238 void DumpRegion::print(size_t total_bytes) const {
239   log_debug(cds)("%-3s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT,
240                  _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()),
241                  p2i(ArchiveBuilder::current()->to_requested(_base)));
242 }
243 
244 void DumpRegion::print_out_of_space_msg(const char* failing_region, size_t needed_bytes) {
245   log_error(cds)("[%-8s] " PTR_FORMAT " - " PTR_FORMAT " capacity =%9d, allocated =%9d",
246                  _name, p2i(_base), p2i(_top), int(_end - _base), int(_top - _base));

298   intptr_t obj = nextPtr();
299   assert((intptr_t)obj >= 0 || (intptr_t)obj < -100,
300          "hit tag while initializing ptrs.");
301   *p = (void*)obj;
302 }
303 
304 void ReadClosure::do_u4(u4* p) {
305   intptr_t obj = nextPtr();
306   *p = (u4)(uintx(obj));
307 }
308 
309 void ReadClosure::do_bool(bool* p) {
310   intptr_t obj = nextPtr();
311   *p = (bool)(uintx(obj));
312 }
313 
314 void ReadClosure::do_tag(int tag) {
315   int old_tag;
316   old_tag = (int)(intptr_t)nextPtr();
317   // do_int(&old_tag);
318   assert(tag == old_tag, "tag doesn't match (%d, expected %d)", old_tag, tag);
319   FileMapInfo::assert_mark(tag == old_tag);
320 }
321 
322 void ReadClosure::do_oop(oop *p) {
323   narrowOop o = CompressedOops::narrow_oop_cast(nextPtr());
324   if (CompressedOops::is_null(o) || !HeapShared::is_fully_available()) {
325     *p = NULL;
326   } else {
327     assert(HeapShared::can_use(), "sanity");
328     assert(HeapShared::is_fully_available(), "must be");
329     *p = HeapShared::decode_from_archive(o);
330   }
331 }
332 
333 void ReadClosure::do_region(u_char* start, size_t size) {
334   assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
335   assert(size % sizeof(intptr_t) == 0, "bad size");
336   do_tag((int)size);
337   while (size > 0) {
338     *(intptr_t*)start = nextPtr();
< prev index next >