Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classLoaderData.cpp @ 18009:f73af4455d7d
Merge
author | asaha |
---|---|
date | Thu, 29 May 2014 09:56:06 -0700 |
parents | 78bbf4d43a14 |
children | e4a6e7f1b90b |
comparison
equal
deleted
inserted
replaced
18008:da65bbf6f89e | 18009:f73af4455d7d |
---|---|
267 | 267 |
268 if (TraceClassLoaderData && Verbose && k->class_loader_data() != NULL) { | 268 if (TraceClassLoaderData && Verbose && k->class_loader_data() != NULL) { |
269 ResourceMark rm; | 269 ResourceMark rm; |
270 tty->print_cr("[TraceClassLoaderData] Adding k: " PTR_FORMAT " %s to CLD: " | 270 tty->print_cr("[TraceClassLoaderData] Adding k: " PTR_FORMAT " %s to CLD: " |
271 PTR_FORMAT " loader: " PTR_FORMAT " %s", | 271 PTR_FORMAT " loader: " PTR_FORMAT " %s", |
272 k, | 272 p2i(k), |
273 k->external_name(), | 273 k->external_name(), |
274 k->class_loader_data(), | 274 p2i(k->class_loader_data()), |
275 (void *)k->class_loader(), | 275 p2i((void *)k->class_loader()), |
276 loader_name()); | 276 loader_name()); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 // This is called by InstanceKlass::deallocate_contents() to remove the | 280 // This is called by InstanceKlass::deallocate_contents() to remove the |
305 // Tell serviceability tools these classes are unloading | 305 // Tell serviceability tools these classes are unloading |
306 classes_do(InstanceKlass::notify_unload_class); | 306 classes_do(InstanceKlass::notify_unload_class); |
307 | 307 |
308 if (TraceClassLoaderData) { | 308 if (TraceClassLoaderData) { |
309 ResourceMark rm; | 309 ResourceMark rm; |
310 tty->print("[ClassLoaderData: unload loader data "PTR_FORMAT, this); | 310 tty->print("[ClassLoaderData: unload loader data " INTPTR_FORMAT, p2i(this)); |
311 tty->print(" for instance "PTR_FORMAT" of %s", (void *)class_loader(), | 311 tty->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()), |
312 loader_name()); | 312 loader_name()); |
313 if (is_anonymous()) { | 313 if (is_anonymous()) { |
314 tty->print(" for anonymous class "PTR_FORMAT " ", _klasses); | 314 tty->print(" for anonymous class " INTPTR_FORMAT " ", p2i(_klasses)); |
315 } | 315 } |
316 tty->print_cr("]"); | 316 tty->print_cr("]"); |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
467 #undef CLD_DUMP_KLASSES | 467 #undef CLD_DUMP_KLASSES |
468 | 468 |
469 void ClassLoaderData::dump(outputStream * const out) { | 469 void ClassLoaderData::dump(outputStream * const out) { |
470 ResourceMark rm; | 470 ResourceMark rm; |
471 out->print("ClassLoaderData CLD: "PTR_FORMAT", loader: "PTR_FORMAT", loader_klass: "PTR_FORMAT" %s {", | 471 out->print("ClassLoaderData CLD: "PTR_FORMAT", loader: "PTR_FORMAT", loader_klass: "PTR_FORMAT" %s {", |
472 this, (void *)class_loader(), | 472 p2i(this), p2i((void *)class_loader()), |
473 class_loader() != NULL ? class_loader()->klass() : NULL, loader_name()); | 473 p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name()); |
474 if (claimed()) out->print(" claimed "); | 474 if (claimed()) out->print(" claimed "); |
475 if (is_unloading()) out->print(" unloading "); | 475 if (is_unloading()) out->print(" unloading "); |
476 out->print(" handles " INTPTR_FORMAT, handles()); | 476 out->print(" handles " INTPTR_FORMAT, p2i(handles())); |
477 out->cr(); | 477 out->cr(); |
478 if (metaspace_or_null() != NULL) { | 478 if (metaspace_or_null() != NULL) { |
479 out->print_cr("metaspace: " PTR_FORMAT, metaspace_or_null()); | 479 out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null())); |
480 metaspace_or_null()->dump(out); | 480 metaspace_or_null()->dump(out); |
481 } else { | 481 } else { |
482 out->print_cr("metaspace: NULL"); | 482 out->print_cr("metaspace: NULL"); |
483 } | 483 } |
484 | 484 |
531 // GC root of class loader data created. | 531 // GC root of class loader data created. |
532 ClassLoaderData* ClassLoaderDataGraph::_head = NULL; | 532 ClassLoaderData* ClassLoaderDataGraph::_head = NULL; |
533 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL; | 533 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL; |
534 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL; | 534 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL; |
535 | 535 |
536 bool ClassLoaderDataGraph::_should_purge = false; | |
537 | |
536 // Add a new class loader data node to the list. Assign the newly created | 538 // Add a new class loader data node to the list. Assign the newly created |
537 // ClassLoaderData into the java/lang/ClassLoader object as a hidden field | 539 // ClassLoaderData into the java/lang/ClassLoader object as a hidden field |
538 ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous, TRAPS) { | 540 ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous, TRAPS) { |
539 // We need to allocate all the oops for the ClassLoaderData before allocating the | 541 // We need to allocate all the oops for the ClassLoaderData before allocating the |
540 // actual ClassLoaderData object. | 542 // actual ClassLoaderData object. |
568 ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next); | 570 ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next); |
569 if (exchanged == next) { | 571 if (exchanged == next) { |
570 if (TraceClassLoaderData) { | 572 if (TraceClassLoaderData) { |
571 ResourceMark rm; | 573 ResourceMark rm; |
572 tty->print("[ClassLoaderData: "); | 574 tty->print("[ClassLoaderData: "); |
573 tty->print("create class loader data "PTR_FORMAT, cld); | 575 tty->print("create class loader data " INTPTR_FORMAT, p2i(cld)); |
574 tty->print(" for instance "PTR_FORMAT" of %s", (void *)cld->class_loader(), | 576 tty->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()), |
575 cld->loader_name()); | 577 cld->loader_name()); |
576 tty->print_cr("]"); | 578 tty->print_cr("]"); |
577 } | 579 } |
578 return cld; | 580 return cld; |
579 } | 581 } |
651 | 653 |
652 curr = curr->_next; | 654 curr = curr->_next; |
653 } | 655 } |
654 | 656 |
655 return array; | 657 return array; |
656 } | |
657 | |
658 // For profiling and hsfind() only. Otherwise, this is unsafe (and slow). This | |
659 // is done lock free to avoid lock inversion problems. It is safe because | |
660 // new ClassLoaderData are added to the end of the CLDG, and only removed at | |
661 // safepoint. The _unloading list can be deallocated concurrently with CMS so | |
662 // this doesn't look in metaspace for classes that have been unloaded. | |
663 bool ClassLoaderDataGraph::contains(const void* x) { | |
664 if (DumpSharedSpaces) { | |
665 // There are only two metaspaces to worry about. | |
666 ClassLoaderData* ncld = ClassLoaderData::the_null_class_loader_data(); | |
667 return (ncld->ro_metaspace()->contains(x) || ncld->rw_metaspace()->contains(x)); | |
668 } | |
669 | |
670 if (UseSharedSpaces && MetaspaceShared::is_in_shared_space(x)) { | |
671 return true; | |
672 } | |
673 | |
674 for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { | |
675 if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) { | |
676 return true; | |
677 } | |
678 } | |
679 | |
680 // Do not check unloading list because deallocation can be concurrent. | |
681 return false; | |
682 } | 658 } |
683 | 659 |
684 #ifndef PRODUCT | 660 #ifndef PRODUCT |
685 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { | 661 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { |
686 for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { | 662 for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { |
737 | 713 |
738 return seen_dead_loader; | 714 return seen_dead_loader; |
739 } | 715 } |
740 | 716 |
741 void ClassLoaderDataGraph::purge() { | 717 void ClassLoaderDataGraph::purge() { |
718 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); | |
742 ClassLoaderData* list = _unloading; | 719 ClassLoaderData* list = _unloading; |
743 _unloading = NULL; | 720 _unloading = NULL; |
744 ClassLoaderData* next = list; | 721 ClassLoaderData* next = list; |
745 while (next != NULL) { | 722 while (next != NULL) { |
746 ClassLoaderData* purge_me = next; | 723 ClassLoaderData* purge_me = next; |
825 | 802 |
826 void ClassLoaderData::print_value_on(outputStream* out) const { | 803 void ClassLoaderData::print_value_on(outputStream* out) const { |
827 if (class_loader() == NULL) { | 804 if (class_loader() == NULL) { |
828 out->print("NULL class_loader"); | 805 out->print("NULL class_loader"); |
829 } else { | 806 } else { |
830 out->print("class loader "PTR_FORMAT, this); | 807 out->print("class loader " INTPTR_FORMAT, p2i(this)); |
831 class_loader()->print_value_on(out); | 808 class_loader()->print_value_on(out); |
832 } | 809 } |
833 } | 810 } |
834 | 811 |
835 #if INCLUDE_TRACE | 812 #if INCLUDE_TRACE |