77 CompiledMethod* first; 78 CompiledMethodIterator last(CompiledMethodIterator::only_alive); 79 80 do { 81 *num_claimed_nmethods = 0; 82 83 first = _claimed_nmethod; 84 last = CompiledMethodIterator(CompiledMethodIterator::only_alive, first); 85 86 if (first != NULL) { 87 88 for (int i = 0; i < MaxClaimNmethods; i++) { 89 if (!last.next()) { 90 break; 91 } 92 claimed_nmethods[i] = last.method(); 93 (*num_claimed_nmethods)++; 94 } 95 } 96 97 } while (Atomic::cmpxchg(last.method(), &_claimed_nmethod, first) != first); 98 } 99 100 void CodeCacheUnloadingTask::work(uint worker_id) { 101 // The first nmethods is claimed by the first worker. 102 if (worker_id == 0 && _first_nmethod != NULL) { 103 _first_nmethod->do_unloading(_unloading_occurred); 104 _first_nmethod = NULL; 105 } 106 107 int num_claimed_nmethods; 108 CompiledMethod* claimed_nmethods[MaxClaimNmethods]; 109 110 while (true) { 111 claim_nmethods(claimed_nmethods, &num_claimed_nmethods); 112 113 if (num_claimed_nmethods == 0) { 114 break; 115 } 116 117 for (int i = 0; i < num_claimed_nmethods; i++) { 118 claimed_nmethods[i]->do_unloading(_unloading_occurred); 119 } 120 } 121 } 122 123 KlassCleaningTask::KlassCleaningTask() : 124 _clean_klass_tree_claimed(0), 125 _klass_iterator() { 126 } 127 128 bool KlassCleaningTask::claim_clean_klass_tree_task() { 129 if (_clean_klass_tree_claimed) { 130 return false; 131 } 132 133 return Atomic::cmpxchg(1, &_clean_klass_tree_claimed, 0) == 0; 134 } 135 136 InstanceKlass* KlassCleaningTask::claim_next_klass() { 137 Klass* klass; 138 do { 139 klass =_klass_iterator.next_klass(); 140 } while (klass != NULL && !klass->is_instance_klass()); 141 142 // this can be null so don't call InstanceKlass::cast 143 return static_cast<InstanceKlass*>(klass); 144 } 145 146 void KlassCleaningTask::work() { 147 ResourceMark rm; 148 149 // One worker will clean the subklass/sibling klass tree. 150 if (claim_clean_klass_tree_task()) { 151 Klass::clean_subklass_tree(); 152 } 153 | 77 CompiledMethod* first; 78 CompiledMethodIterator last(CompiledMethodIterator::only_alive); 79 80 do { 81 *num_claimed_nmethods = 0; 82 83 first = _claimed_nmethod; 84 last = CompiledMethodIterator(CompiledMethodIterator::only_alive, first); 85 86 if (first != NULL) { 87 88 for (int i = 0; i < MaxClaimNmethods; i++) { 89 if (!last.next()) { 90 break; 91 } 92 claimed_nmethods[i] = last.method(); 93 (*num_claimed_nmethods)++; 94 } 95 } 96 97 } while (Atomic::cmpxchg(&_claimed_nmethod, first, last.method()) != first); 98 } 99 100 void CodeCacheUnloadingTask::work(uint worker_id) { 101 // The first nmethods is claimed by the first worker. 102 if (worker_id == 0 && _first_nmethod != NULL) { 103 _first_nmethod->do_unloading(_unloading_occurred); 104 _first_nmethod = NULL; 105 } 106 107 int num_claimed_nmethods; 108 CompiledMethod* claimed_nmethods[MaxClaimNmethods]; 109 110 while (true) { 111 claim_nmethods(claimed_nmethods, &num_claimed_nmethods); 112 113 if (num_claimed_nmethods == 0) { 114 break; 115 } 116 117 for (int i = 0; i < num_claimed_nmethods; i++) { 118 claimed_nmethods[i]->do_unloading(_unloading_occurred); 119 } 120 } 121 } 122 123 KlassCleaningTask::KlassCleaningTask() : 124 _clean_klass_tree_claimed(0), 125 _klass_iterator() { 126 } 127 128 bool KlassCleaningTask::claim_clean_klass_tree_task() { 129 if (_clean_klass_tree_claimed) { 130 return false; 131 } 132 133 return Atomic::cmpxchg(&_clean_klass_tree_claimed, 0, 1) == 0; 134 } 135 136 InstanceKlass* KlassCleaningTask::claim_next_klass() { 137 Klass* klass; 138 do { 139 klass =_klass_iterator.next_klass(); 140 } while (klass != NULL && !klass->is_instance_klass()); 141 142 // this can be null so don't call InstanceKlass::cast 143 return static_cast<InstanceKlass*>(klass); 144 } 145 146 void KlassCleaningTask::work() { 147 ResourceMark rm; 148 149 // One worker will clean the subklass/sibling klass tree. 150 if (claim_clean_klass_tree_task()) { 151 Klass::clean_subklass_tree(); 152 } 153 |