659 // No more klasses in the current CLD. Time to find a new CLD.
660 ClassLoaderData* cld = klass->class_loader_data();
661 assert_locked_or_safepoint(cld->metaspace_lock());
662 while (next == NULL) {
663 cld = cld->next();
664 if (cld == NULL) {
665 break;
666 }
667 next = cld->_klasses;
668 }
669
670 return next;
671 }
672
673 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
674 Klass* head = _next_klass;
675
676 while (head != NULL) {
677 Klass* next = next_klass_in_cldg(head);
678
679 Klass* old_head = Atomic::cmpxchg(next, &_next_klass, head);
680
681 if (old_head == head) {
682 return head; // Won the CAS.
683 }
684
685 head = old_head;
686 }
687
688 // Nothing more for the iterator to hand out.
689 assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head));
690 return NULL;
691 }
692
693 ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
694 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
695 _data = ClassLoaderDataGraph::_head;
696 }
697
698 ClassLoaderDataGraphMetaspaceIterator::~ClassLoaderDataGraphMetaspaceIterator() {}
699
|
659 // No more klasses in the current CLD. Time to find a new CLD.
660 ClassLoaderData* cld = klass->class_loader_data();
661 assert_locked_or_safepoint(cld->metaspace_lock());
662 while (next == NULL) {
663 cld = cld->next();
664 if (cld == NULL) {
665 break;
666 }
667 next = cld->_klasses;
668 }
669
670 return next;
671 }
672
673 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
674 Klass* head = _next_klass;
675
676 while (head != NULL) {
677 Klass* next = next_klass_in_cldg(head);
678
679 Klass* old_head = Atomic::cmpxchg(&_next_klass, head, next);
680
681 if (old_head == head) {
682 return head; // Won the CAS.
683 }
684
685 head = old_head;
686 }
687
688 // Nothing more for the iterator to hand out.
689 assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head));
690 return NULL;
691 }
692
693 ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
694 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
695 _data = ClassLoaderDataGraph::_head;
696 }
697
698 ClassLoaderDataGraphMetaspaceIterator::~ClassLoaderDataGraphMetaspaceIterator() {}
699
|