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