224 size_t commit = MAX2(min_bytes, preferred_bytes);
225 commit = MIN2(commit, uncommitted);
226 assert(commit <= uncommitted, "sanity");
227
228 if (!_vs->expand_by(commit, false)) {
229 log_error(cds)("Failed to expand shared space to " SIZE_FORMAT " bytes",
230 need_committed_size);
231 MetaspaceShared::unrecoverable_writing_error();
232 }
233
234 const char* which;
235 if (_rs->base() == (char*)MetaspaceShared::symbol_rs_base()) {
236 which = "symbol";
237 } else {
238 which = "shared";
239 }
240 log_debug(cds)("Expanding %s spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9) " bytes ending at %p]",
241 which, commit, _vs->actual_committed_size(), _vs->high());
242 }
243
244
245 char* DumpRegion::allocate(size_t num_bytes) {
246 char* p = (char*)align_up(_top, (size_t)SharedSpaceObjectAlignment);
247 char* newtop = p + align_up(num_bytes, (size_t)SharedSpaceObjectAlignment);
248 expand_top_to(newtop);
249 memset(p, 0, newtop - p);
250 return p;
251 }
252
253 void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) {
254 assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment");
255 intptr_t *p = (intptr_t*)_top;
256 char* newtop = _top + sizeof(intptr_t);
257 expand_top_to(newtop);
258 *p = n;
259 if (need_to_mark) {
260 ArchivePtrMarker::mark_pointer(p);
261 }
262 }
263
264 void DumpRegion::print(size_t total_bytes) const {
265 log_debug(cds)("%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT,
266 _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()),
327
328 void ReadClosure::do_u4(u4* p) {
329 intptr_t obj = nextPtr();
330 *p = (u4)(uintx(obj));
331 }
332
333 void ReadClosure::do_int(int* p) {
334 intptr_t obj = nextPtr();
335 *p = (int)(intx(obj));
336 }
337
338 void ReadClosure::do_bool(bool* p) {
339 intptr_t obj = nextPtr();
340 *p = (bool)(uintx(obj));
341 }
342
343 void ReadClosure::do_tag(int tag) {
344 int old_tag;
345 old_tag = (int)(intptr_t)nextPtr();
346 // do_int(&old_tag);
347 assert(tag == old_tag, "old tag doesn't match");
348 FileMapInfo::assert_mark(tag == old_tag);
349 }
350
351 void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
352 if (ClassListWriter::is_enabled()) {
353 if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
354 const constantPoolHandle& pool = bootstrap_specifier->pool();
355 if (SystemDictionaryShared::is_builtin_loader(pool->pool_holder()->class_loader_data())) {
356 // Currently lambda proxy classes are supported only for the built-in loaders.
357 ResourceMark rm(THREAD);
358 int pool_index = bootstrap_specifier->bss_index();
359 ClassListWriter w;
360 w.stream()->print("%s %s", ClassListParser::lambda_proxy_tag(), pool->pool_holder()->name()->as_C_string());
361 CDSIndyInfo cii;
362 ClassListParser::populate_cds_indy_info(pool, pool_index, &cii, CHECK);
363 GrowableArray<const char*>* indy_items = cii.items();
364 for (int i = 0; i < indy_items->length(); i++) {
365 w.stream()->print(" %s", indy_items->at(i));
366 }
367 w.stream()->cr();
|
224 size_t commit = MAX2(min_bytes, preferred_bytes);
225 commit = MIN2(commit, uncommitted);
226 assert(commit <= uncommitted, "sanity");
227
228 if (!_vs->expand_by(commit, false)) {
229 log_error(cds)("Failed to expand shared space to " SIZE_FORMAT " bytes",
230 need_committed_size);
231 MetaspaceShared::unrecoverable_writing_error();
232 }
233
234 const char* which;
235 if (_rs->base() == (char*)MetaspaceShared::symbol_rs_base()) {
236 which = "symbol";
237 } else {
238 which = "shared";
239 }
240 log_debug(cds)("Expanding %s spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9) " bytes ending at %p]",
241 which, commit, _vs->actual_committed_size(), _vs->high());
242 }
243
244 char* DumpRegion::allocate(size_t num_bytes, size_t alignment) {
245 // Always align to at least minimum alignment
246 alignment = MAX2(SharedSpaceObjectAlignment, alignment);
247 char* p = (char*)align_up(_top, alignment);
248 char* newtop = p + align_up(num_bytes, (size_t)SharedSpaceObjectAlignment);
249 expand_top_to(newtop);
250 memset(p, 0, newtop - p);
251 return p;
252 }
253
254 void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) {
255 assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment");
256 intptr_t *p = (intptr_t*)_top;
257 char* newtop = _top + sizeof(intptr_t);
258 expand_top_to(newtop);
259 *p = n;
260 if (need_to_mark) {
261 ArchivePtrMarker::mark_pointer(p);
262 }
263 }
264
265 void DumpRegion::print(size_t total_bytes) const {
266 log_debug(cds)("%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT,
267 _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()),
328
329 void ReadClosure::do_u4(u4* p) {
330 intptr_t obj = nextPtr();
331 *p = (u4)(uintx(obj));
332 }
333
334 void ReadClosure::do_int(int* p) {
335 intptr_t obj = nextPtr();
336 *p = (int)(intx(obj));
337 }
338
339 void ReadClosure::do_bool(bool* p) {
340 intptr_t obj = nextPtr();
341 *p = (bool)(uintx(obj));
342 }
343
344 void ReadClosure::do_tag(int tag) {
345 int old_tag;
346 old_tag = (int)(intptr_t)nextPtr();
347 // do_int(&old_tag);
348 assert(tag == old_tag, "tag doesn't match (%d, expected %d)", old_tag, tag);
349 FileMapInfo::assert_mark(tag == old_tag);
350 }
351
352 void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
353 if (ClassListWriter::is_enabled()) {
354 if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
355 const constantPoolHandle& pool = bootstrap_specifier->pool();
356 if (SystemDictionaryShared::is_builtin_loader(pool->pool_holder()->class_loader_data())) {
357 // Currently lambda proxy classes are supported only for the built-in loaders.
358 ResourceMark rm(THREAD);
359 int pool_index = bootstrap_specifier->bss_index();
360 ClassListWriter w;
361 w.stream()->print("%s %s", ClassListParser::lambda_proxy_tag(), pool->pool_holder()->name()->as_C_string());
362 CDSIndyInfo cii;
363 ClassListParser::populate_cds_indy_info(pool, pool_index, &cii, CHECK);
364 GrowableArray<const char*>* indy_items = cii.items();
365 for (int i = 0; i < indy_items->length(); i++) {
366 w.stream()->print(" %s", indy_items->at(i));
367 }
368 w.stream()->cr();
|