664 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
665 Klass* head = _next_klass;
666
667 while (head != NULL) {
668 Klass* next = next_klass_in_cldg(head);
669
670 Klass* old_head = Atomic::cmpxchg(next, &_next_klass, head);
671
672 if (old_head == head) {
673 return head; // Won the CAS.
674 }
675
676 head = old_head;
677 }
678
679 // Nothing more for the iterator to hand out.
680 assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head));
681 return NULL;
682 }
683
684 ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
685 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
686 _data = ClassLoaderDataGraph::_head;
687 }
688
689 ClassLoaderDataGraphMetaspaceIterator::~ClassLoaderDataGraphMetaspaceIterator() {}
690
691 ClassLoaderMetaspace* ClassLoaderDataGraphMetaspaceIterator::get_next() {
692 assert(_data != NULL, "Should not be NULL in call to the iterator");
693 ClassLoaderMetaspace* result = _data->metaspace_or_null();
694 _data = _data->next();
695 // This result might be NULL for class loaders without metaspace
696 // yet. It would be nice to return only non-null results but
697 // there is no guarantee that there will be a non-null result
698 // down the list so the caller is going to have to check.
699 return result;
700 }
701
702 #ifndef PRODUCT
703 // callable from debugger
704 extern "C" int print_loader_data_graph() {
705 ResourceMark rm;
706 ClassLoaderDataGraph::print_on(tty);
707 return 0;
708 }
709
710 void ClassLoaderDataGraph::verify() {
711 ClassLoaderDataGraphIterator iter;
712 while (ClassLoaderData* cld = iter.get_next()) {
713 cld->verify();
714 }
715 }
716
717 void ClassLoaderDataGraph::print_on(outputStream * const out) {
718 ClassLoaderDataGraphIterator iter;
719 while (ClassLoaderData* cld = iter.get_next()) {
720 cld->print_on(out);
721 }
|
664 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
665 Klass* head = _next_klass;
666
667 while (head != NULL) {
668 Klass* next = next_klass_in_cldg(head);
669
670 Klass* old_head = Atomic::cmpxchg(next, &_next_klass, head);
671
672 if (old_head == head) {
673 return head; // Won the CAS.
674 }
675
676 head = old_head;
677 }
678
679 // Nothing more for the iterator to hand out.
680 assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head));
681 return NULL;
682 }
683
684 #ifndef PRODUCT
685 // callable from debugger
686 extern "C" int print_loader_data_graph() {
687 ResourceMark rm;
688 ClassLoaderDataGraph::print_on(tty);
689 return 0;
690 }
691
692 void ClassLoaderDataGraph::verify() {
693 ClassLoaderDataGraphIterator iter;
694 while (ClassLoaderData* cld = iter.get_next()) {
695 cld->verify();
696 }
697 }
698
699 void ClassLoaderDataGraph::print_on(outputStream * const out) {
700 ClassLoaderDataGraphIterator iter;
701 while (ClassLoaderData* cld = iter.get_next()) {
702 cld->print_on(out);
703 }
|