< prev index next >

src/hotspot/share/classfile/classLoaderData.cpp

CLD claiming v2

CLD claiming

*** 144,154 **** _modified_oops(true), _accumulated_modified_oops(false), // An unsafe anonymous class loader data doesn't have anything to keep // it from being unloaded during parsing of the unsafe anonymous class. // The null-class-loader should always be kept alive. _keep_alive((is_unsafe_anonymous || h_class_loader.is_null()) ? 1 : 0), ! _claimed(0), _handles(), _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), _jmethod_ids(NULL), _deallocate_list(NULL), _next(NULL), --- 144,154 ---- _modified_oops(true), _accumulated_modified_oops(false), // An unsafe anonymous class loader data doesn't have anything to keep // it from being unloaded during parsing of the unsafe anonymous class. // The null-class-loader should always be kept alive. _keep_alive((is_unsafe_anonymous || h_class_loader.is_null()) ? 1 : 0), ! _claim(0), _handles(), _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), _jmethod_ids(NULL), _deallocate_list(NULL), _next(NULL), ***************
*** 272,287 **** } return false; } #endif // PRODUCT ! bool ClassLoaderData::claim() { ! if (_claimed == 1) { ! return false; } - - return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0; } // Unsafe anonymous classes have their own ClassLoaderData that is marked to keep alive // while the class is being parsed, and if the class appears on the module fixup list. // Due to the uniqueness that no other class shares the unsafe anonymous class' name or --- 272,292 ---- } return false; } #endif // PRODUCT ! bool ClassLoaderData::try_claim(int claim) { ! for (;;) { ! int old_claim = Atomic::load(&_claim); ! if ((old_claim & claim) == claim) { ! return false; ! } ! int new_claim = old_claim | claim; ! if (Atomic::cmpxchg(new_claim, &_claim, old_claim) == old_claim) { ! return true; ! } } } // Unsafe anonymous classes have their own ClassLoaderData that is marked to keep alive // while the class is being parsed, and if the class appears on the module fixup list. // Due to the uniqueness that no other class shares the unsafe anonymous class' name or ***************
*** 299,310 **** assert(_keep_alive > 0, "Invalid keep alive decrement count"); _keep_alive--; } } ! void ClassLoaderData::oops_do(OopClosure* f, bool must_claim, bool clear_mod_oops) { ! if (must_claim && !claim()) { return; } // Only clear modified_oops after the ClassLoaderData is claimed. if (clear_mod_oops) { --- 304,315 ---- assert(_keep_alive > 0, "Invalid keep alive decrement count"); _keep_alive--; } } ! void ClassLoaderData::oops_do(OopClosure* f, int claim_value, bool clear_mod_oops) { ! if (claim_value != ClassLoaderData::_claim_none && !try_claim(claim_value)) { return; } // Only clear modified_oops after the ClassLoaderData is claimed. if (clear_mod_oops) { ***************
*** 444,454 **** } void ClassLoaderDataGraph::clear_claimed_marks() { for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { ! cld->clear_claimed(); } } void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) { { --- 449,459 ---- } void ClassLoaderDataGraph::clear_claimed_marks() { for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { ! cld->clear_claim(); } } void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) { {
< prev index next >