equal
deleted
inserted
replaced
137 _modified_oops(true), _accumulated_modified_oops(false), |
137 _modified_oops(true), _accumulated_modified_oops(false), |
138 // An unsafe anonymous class loader data doesn't have anything to keep |
138 // An unsafe anonymous class loader data doesn't have anything to keep |
139 // it from being unloaded during parsing of the unsafe anonymous class. |
139 // it from being unloaded during parsing of the unsafe anonymous class. |
140 // The null-class-loader should always be kept alive. |
140 // The null-class-loader should always be kept alive. |
141 _keep_alive((is_unsafe_anonymous || h_class_loader.is_null()) ? 1 : 0), |
141 _keep_alive((is_unsafe_anonymous || h_class_loader.is_null()) ? 1 : 0), |
142 _claimed(0), |
142 _claim(0), |
143 _handles(), |
143 _handles(), |
144 _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), |
144 _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), |
145 _jmethod_ids(NULL), |
145 _jmethod_ids(NULL), |
146 _deallocate_list(NULL), |
146 _deallocate_list(NULL), |
147 _next(NULL), |
147 _next(NULL), |
266 } |
266 } |
267 return false; |
267 return false; |
268 } |
268 } |
269 #endif // PRODUCT |
269 #endif // PRODUCT |
270 |
270 |
271 bool ClassLoaderData::claim() { |
271 bool ClassLoaderData::try_claim(int claim) { |
272 if (_claimed == 1) { |
272 for (;;) { |
273 return false; |
273 int old_claim = Atomic::load(&_claim); |
274 } |
274 if ((old_claim & claim) == claim) { |
275 |
275 return false; |
276 return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0; |
276 } |
|
277 int new_claim = old_claim | claim; |
|
278 if (Atomic::cmpxchg(new_claim, &_claim, old_claim) == old_claim) { |
|
279 return true; |
|
280 } |
|
281 } |
277 } |
282 } |
278 |
283 |
279 // Unsafe anonymous classes have their own ClassLoaderData that is marked to keep alive |
284 // Unsafe anonymous classes have their own ClassLoaderData that is marked to keep alive |
280 // while the class is being parsed, and if the class appears on the module fixup list. |
285 // while the class is being parsed, and if the class appears on the module fixup list. |
281 // Due to the uniqueness that no other class shares the unsafe anonymous class' name or |
286 // Due to the uniqueness that no other class shares the unsafe anonymous class' name or |
293 assert(_keep_alive > 0, "Invalid keep alive decrement count"); |
298 assert(_keep_alive > 0, "Invalid keep alive decrement count"); |
294 _keep_alive--; |
299 _keep_alive--; |
295 } |
300 } |
296 } |
301 } |
297 |
302 |
298 void ClassLoaderData::oops_do(OopClosure* f, bool must_claim, bool clear_mod_oops) { |
303 void ClassLoaderData::oops_do(OopClosure* f, int claim_value, bool clear_mod_oops) { |
299 if (must_claim && !claim()) { |
304 if (claim_value != ClassLoaderData::_claim_none && !try_claim(claim_value)) { |
300 return; |
305 return; |
301 } |
306 } |
302 |
307 |
303 // Only clear modified_oops after the ClassLoaderData is claimed. |
308 // Only clear modified_oops after the ClassLoaderData is claimed. |
304 if (clear_mod_oops) { |
309 if (clear_mod_oops) { |