< prev index next >
src/hotspot/share/classfile/classLoaderData.cpp
Print this page
*** 96,106 ****
// it from being unloaded during parsing of the anonymous class.
// The null-class-loader should always be kept alive.
_keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
_metaspace(NULL), _unloading(false), _klasses(NULL),
_modules(NULL), _packages(NULL),
! _claimed(0), _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
_next(NULL), _dependencies(dependencies),
_metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
Monitor::_safepoint_check_never)) {
// A ClassLoaderData created solely for an anonymous class should never have a
--- 96,106 ----
// it from being unloaded during parsing of the anonymous class.
// The null-class-loader should always be kept alive.
_keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
_metaspace(NULL), _unloading(false), _klasses(NULL),
_modules(NULL), _packages(NULL),
! _claimed(0), _modified_oops(1), _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
_next(NULL), _dependencies(dependencies),
_metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
Monitor::_safepoint_check_never)) {
// A ClassLoaderData created solely for an anonymous class should never have a
*** 205,215 ****
bool ClassLoaderData::ChunkedHandleList::contains(oop* p) {
VerifyContainsOopClosure cl(p);
oops_do(&cl);
return cl.found();
}
! #endif
bool ClassLoaderData::claim() {
if (_claimed == 1) {
return false;
}
--- 205,215 ----
bool ClassLoaderData::ChunkedHandleList::contains(oop* p) {
VerifyContainsOopClosure cl(p);
oops_do(&cl);
return cl.found();
}
! #endif // ASSERT
bool ClassLoaderData::claim() {
if (_claimed == 1) {
return false;
}
*** 234,256 ****
assert(_keep_alive > 0, "Invalid keep alive decrement count");
_keep_alive--;
}
}
! void ClassLoaderData::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
if (must_claim && !claim()) {
return;
}
f->do_oop(&_class_loader);
_dependencies.oops_do(f);
-
_handles.oops_do(f);
-
- if (klass_closure != NULL) {
- classes_do(klass_closure);
- }
}
void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
f->do_oop((oop*)&_list_head);
}
--- 234,256 ----
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) {
+ clear_modified_oops();
+ }
+
f->do_oop(&_class_loader);
_dependencies.oops_do(f);
_handles.oops_do(f);
}
void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
f->do_oop((oop*)&_list_head);
}
*** 366,375 ****
--- 366,378 ----
// It's a dependency we won't find through GC, add it. This is relatively rare
// Must handle over GC point.
Handle dependency(THREAD, to);
from_cld->_dependencies.add(dependency, CHECK);
+
+ // Added a potentially young gen oop to the ClassLoaderData
+ record_modified_oops();
}
void ClassLoaderData::Dependencies::add(Handle dependency, TRAPS) {
// Check first if this dependency is already in the list.
*** 762,771 ****
--- 765,775 ----
return metaspace;
}
OopHandle ClassLoaderData::add_handle(Handle h) {
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
+ record_modified_oops();
return OopHandle(_handles.add(h()));
}
void ClassLoaderData::remove_handle(OopHandle h) {
oop* ptr = h.ptr_raw();
*** 779,788 ****
--- 783,793 ----
oop obj = *ptr;
if (obj != NULL) {
G1SATBCardTableModRefBS::enqueue(obj);
}
}
+ record_modified_oops(); // necessary?
#endif
*ptr = NULL;
}
}
*** 873,884 ****
#ifdef CLD_DUMP_KLASSES
if (Verbose) {
Klass* k = _klasses;
while (k != NULL) {
! out->print_cr("klass " PTR_FORMAT ", %s, CT: %d, MUT: %d", k, k->name()->as_C_string(),
! k->has_modified_oops(), k->has_accumulated_modified_oops());
assert(k != k->next_link(), "no loops!");
k = k->next_link();
}
}
#endif // CLD_DUMP_KLASSES
--- 878,888 ----
#ifdef CLD_DUMP_KLASSES
if (Verbose) {
Klass* k = _klasses;
while (k != NULL) {
! out->print_cr("klass " PTR_FORMAT ", %s", k, k->name()->as_C_string());
assert(k != k->next_link(), "no loops!");
k = k->next_link();
}
}
#endif // CLD_DUMP_KLASSES
*** 1001,1029 ****
}
out->cr();
}
! void ClassLoaderDataGraph::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
! cld->oops_do(f, klass_closure, must_claim);
}
}
! void ClassLoaderDataGraph::keep_alive_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
if (cld->keep_alive()) {
! cld->oops_do(f, klass_closure, must_claim);
}
}
}
! void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
if (ClassUnloading) {
! keep_alive_oops_do(f, klass_closure, must_claim);
} else {
! oops_do(f, klass_closure, must_claim);
}
}
void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
--- 1005,1033 ----
}
out->cr();
}
! void ClassLoaderDataGraph::oops_do(OopClosure* f, bool must_claim) {
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
! cld->oops_do(f, must_claim);
}
}
! void ClassLoaderDataGraph::keep_alive_oops_do(OopClosure* f, bool must_claim) {
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
if (cld->keep_alive()) {
! cld->oops_do(f, must_claim);
}
}
}
! void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, bool must_claim) {
if (ClassUnloading) {
! keep_alive_oops_do(f, must_claim);
} else {
! oops_do(f, must_claim);
}
}
void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
< prev index next >