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()),
334
335 void ReadClosure::do_u4(u4* p) {
336 intptr_t obj = nextPtr();
337 *p = (u4)(uintx(obj));
338 }
339
340 void ReadClosure::do_int(int* p) {
341 intptr_t obj = nextPtr();
342 *p = (int)(intx(obj));
343 }
344
345 void ReadClosure::do_bool(bool* p) {
346 intptr_t obj = nextPtr();
347 *p = (bool)(uintx(obj));
348 }
349
350 void ReadClosure::do_tag(int tag) {
351 int old_tag;
352 old_tag = (int)(intptr_t)nextPtr();
353 // do_int(&old_tag);
354 assert(tag == old_tag, "old tag doesn't match");
355 FileMapInfo::assert_mark(tag == old_tag);
356 }
357
358 void ReadClosure::do_region(u_char* start, size_t size) {
359 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
360 assert(size % sizeof(intptr_t) == 0, "bad size");
361 do_tag((int)size);
362 while (size > 0) {
363 *(intptr_t*)start = nextPtr();
364 start += sizeof(intptr_t);
365 size -= sizeof(intptr_t);
366 }
367 }
368
369 void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
370 if (ClassListWriter::is_enabled()) {
371 if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
372 const constantPoolHandle& pool = bootstrap_specifier->pool();
373 if (SystemDictionaryShared::is_builtin_loader(pool->pool_holder()->class_loader_data())) {
374 // Currently lambda proxy classes are supported only for the built-in loaders.
|
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()),
335
336 void ReadClosure::do_u4(u4* p) {
337 intptr_t obj = nextPtr();
338 *p = (u4)(uintx(obj));
339 }
340
341 void ReadClosure::do_int(int* p) {
342 intptr_t obj = nextPtr();
343 *p = (int)(intx(obj));
344 }
345
346 void ReadClosure::do_bool(bool* p) {
347 intptr_t obj = nextPtr();
348 *p = (bool)(uintx(obj));
349 }
350
351 void ReadClosure::do_tag(int tag) {
352 int old_tag;
353 old_tag = (int)(intptr_t)nextPtr();
354 // do_int(&old_tag);
355 assert(tag == old_tag, "tag doesn't match (%d, expected %d)", old_tag, tag);
356 FileMapInfo::assert_mark(tag == old_tag);
357 }
358
359 void ReadClosure::do_region(u_char* start, size_t size) {
360 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
361 assert(size % sizeof(intptr_t) == 0, "bad size");
362 do_tag((int)size);
363 while (size > 0) {
364 *(intptr_t*)start = nextPtr();
365 start += sizeof(intptr_t);
366 size -= sizeof(intptr_t);
367 }
368 }
369
370 void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
371 if (ClassListWriter::is_enabled()) {
372 if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
373 const constantPoolHandle& pool = bootstrap_specifier->pool();
374 if (SystemDictionaryShared::is_builtin_loader(pool->pool_holder()->class_loader_data())) {
375 // Currently lambda proxy classes are supported only for the built-in loaders.
|