src/share/vm/classfile/classLoaderData.cpp

Print this page
rev 7903 : fix volatile qualifier ClassLoaderDataGraphKlassIteratorAtomic::next_klass


 885 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) {
 886   Klass* next = klass->next_link();
 887   if (next != NULL) {
 888     return next;
 889   }
 890 
 891   // No more klasses in the current CLD. Time to find a new CLD.
 892   ClassLoaderData* cld = klass->class_loader_data();
 893   while (next == NULL) {
 894     cld = cld->next();
 895     if (cld == NULL) {
 896       break;
 897     }
 898     next = cld->_klasses;
 899   }
 900 
 901   return next;
 902 }
 903 
 904 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
 905   Klass* head = (Klass*)_next_klass;
 906 
 907   while (head != NULL) {
 908     Klass* next = next_klass_in_cldg(head);
 909 
 910     Klass* old_head = (Klass*)Atomic::cmpxchg_ptr(next, &_next_klass, head);
 911 
 912     if (old_head == head) {
 913       return head; // Won the CAS.
 914     }
 915 
 916     head = old_head;
 917   }
 918 
 919   // Nothing more for the iterator to hand out.
 920   assert(head == NULL, err_msg("head is " PTR_FORMAT ", expected not null:", p2i(head)));
 921   return NULL;
 922 }
 923 
 924 ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
 925   _data = ClassLoaderDataGraph::_head;




 885 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) {
 886   Klass* next = klass->next_link();
 887   if (next != NULL) {
 888     return next;
 889   }
 890 
 891   // No more klasses in the current CLD. Time to find a new CLD.
 892   ClassLoaderData* cld = klass->class_loader_data();
 893   while (next == NULL) {
 894     cld = cld->next();
 895     if (cld == NULL) {
 896       break;
 897     }
 898     next = cld->_klasses;
 899   }
 900 
 901   return next;
 902 }
 903 
 904 Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
 905   Klass* head = _next_klass;
 906 
 907   while (head != NULL) {
 908     Klass* next = next_klass_in_cldg(head);
 909 
 910     Klass* old_head = (Klass*)Atomic::cmpxchg_ptr(next, &_next_klass, head);
 911 
 912     if (old_head == head) {
 913       return head; // Won the CAS.
 914     }
 915 
 916     head = old_head;
 917   }
 918 
 919   // Nothing more for the iterator to hand out.
 920   assert(head == NULL, err_msg("head is " PTR_FORMAT ", expected not null:", p2i(head)));
 921   return NULL;
 922 }
 923 
 924 ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
 925   _data = ClassLoaderDataGraph::_head;