< prev index next >

src/hotspot/share/cds/archiveUtils.cpp

Print this page

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










210   expand_top_to(newtop);
211   memset(p, 0, newtop - p);
212   return p;
213 }
214 




215 void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) {
216   assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment");
217   intptr_t *p = (intptr_t*)_top;
218   char* newtop = _top + sizeof(intptr_t);
219   expand_top_to(newtop);
220   *p = n;
221   if (need_to_mark) {
222     ArchivePtrMarker::mark_pointer(p);
223   }
224 }
225 
226 void DumpRegion::print(size_t total_bytes) const {
227   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,
228                  _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()),
229                  p2i(ArchiveBuilder::current()->to_requested(_base)));
230 }
231 
232 void DumpRegion::print_out_of_space_msg(const char* failing_region, size_t needed_bytes) {
233   log_error(cds)("[%-8s] " PTR_FORMAT " - " PTR_FORMAT " capacity =%9d, allocated =%9d",
234                  _name, p2i(_base), p2i(_top), int(_end - _base), int(_top - _base));

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

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

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