comparison src/share/vm/classfile/classLoaderData.cpp @ 17935:7384f6a12fc1

8038212: Method::is_valid_method() check has performance regression impact for stackwalking Summary: Only prune metaspace virtual spaces at safepoint so walking them is safe outside a safepoint. Reviewed-by: mgerdin, mgronlun, hseigel, stefank
author coleenp
date Thu, 15 May 2014 18:23:26 -0400
parents 85318d1fe8fe
children 78bbf4d43a14
comparison
equal deleted inserted replaced
17934:366c198c896d 17935:7384f6a12fc1
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.
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;