From 7876905bfffe57bbe7a71ef2621ae006120af400 Mon Sep 17 00:00:00 2001 From: sjohanss Date: Tue, 26 Nov 2013 14:35:38 +0100 Subject: [PATCH] 8027675: Full collections with Serial slower in JDK 8 compared to 7u40 Summary: Reduced the number of calls to follow_class_loader and instead marked and pushed the klass holder directly. Also removed unneeded calls to adjust_klass. Reviewed-by: coleenp, jmasa, mgerdin, tschatzl --- .../vm/gc_implementation/shared/markSweep.cpp | 19 ------------------- .../vm/gc_implementation/shared/markSweep.hpp | 2 -- .../shared/markSweep.inline.hpp | 5 +++++ src/share/vm/oops/instanceKlass.cpp | 1 - src/share/vm/oops/instanceMirrorKlass.cpp | 19 +++++++------------ src/share/vm/oops/objArrayKlass.cpp | 1 - 6 files changed, 12 insertions(+), 35 deletions(-) diff --git a/src/share/vm/gc_implementation/shared/markSweep.cpp b/src/share/vm/gc_implementation/shared/markSweep.cpp index 7bdcd55f5..1bc3ea46a 100644 --- a/src/share/vm/gc_implementation/shared/markSweep.cpp +++ b/src/share/vm/gc_implementation/shared/markSweep.cpp @@ -66,29 +66,10 @@ void MarkSweep::AdjustKlassClosure::do_klass(Klass* klass) { klass->oops_do(&MarkSweep::adjust_pointer_closure); } -void MarkSweep::follow_klass(Klass* klass) { - ClassLoaderData* cld = klass->class_loader_data(); - // The actual processing of the klass is done when we - // traverse the list of Klasses in the class loader data. - MarkSweep::follow_class_loader(cld); -} - -void MarkSweep::adjust_klass(Klass* klass) { - ClassLoaderData* cld = klass->class_loader_data(); - // The actual processing of the klass is done when we - // traverse the list of Klasses in the class loader data. - MarkSweep::adjust_class_loader(cld); -} - void MarkSweep::follow_class_loader(ClassLoaderData* cld) { cld->oops_do(&MarkSweep::mark_and_push_closure, &MarkSweep::follow_klass_closure, true); } -void MarkSweep::adjust_class_loader(ClassLoaderData* cld) { - cld->oops_do(&MarkSweep::adjust_pointer_closure, &MarkSweep::adjust_klass_closure, true); -} - - void MarkSweep::follow_stack() { do { while (!_marking_stack.is_empty()) { diff --git a/src/share/vm/gc_implementation/shared/markSweep.hpp b/src/share/vm/gc_implementation/shared/markSweep.hpp index 2c08a6897..38fc8e705 100644 --- a/src/share/vm/gc_implementation/shared/markSweep.hpp +++ b/src/share/vm/gc_implementation/shared/markSweep.hpp @@ -172,10 +172,8 @@ class MarkSweep : AllStatic { static void follow_stack(); // Empty marking stack. static void follow_klass(Klass* klass); - static void adjust_klass(Klass* klass); static void follow_class_loader(ClassLoaderData* cld); - static void adjust_class_loader(ClassLoaderData* cld); static void preserve_mark(oop p, markOop mark); // Save the mark word so it can be restored later diff --git a/src/share/vm/gc_implementation/shared/markSweep.inline.hpp b/src/share/vm/gc_implementation/shared/markSweep.inline.hpp index 8ffe0f782..e70e3af1b 100644 --- a/src/share/vm/gc_implementation/shared/markSweep.inline.hpp +++ b/src/share/vm/gc_implementation/shared/markSweep.inline.hpp @@ -44,6 +44,11 @@ inline void MarkSweep::mark_object(oop obj) { } } +inline void MarkSweep::follow_klass(Klass* klass) { + oop op = klass->klass_holder(); + MarkSweep::mark_and_push(&op); +} + template inline void MarkSweep::follow_root(T* p) { assert(!Universe::heap()->is_in_reserved(p), "roots shouldn't be things within the heap"); diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp index ae7ea8048..8f0df25a0 100644 --- a/src/share/vm/oops/instanceKlass.cpp +++ b/src/share/vm/oops/instanceKlass.cpp @@ -2157,7 +2157,6 @@ int InstanceKlass::oop_adjust_pointers(oop obj) { obj, \ MarkSweep::adjust_pointer(p), \ assert_is_in) - MarkSweep::adjust_klass(obj->klass()); return size; } diff --git a/src/share/vm/oops/instanceMirrorKlass.cpp b/src/share/vm/oops/instanceMirrorKlass.cpp index 3eabba70a..825633247 100644 --- a/src/share/vm/oops/instanceMirrorKlass.cpp +++ b/src/share/vm/oops/instanceMirrorKlass.cpp @@ -155,7 +155,13 @@ void InstanceMirrorKlass::oop_follow_contents(oop obj) { // Follow the klass field in the mirror. Klass* klass = java_lang_Class::as_Klass(obj); if (klass != NULL) { - MarkSweep::follow_klass(klass); + // For anonymous classes we need to handle the class loader data, + // otherwise it won't be claimed and can be unloaded. + if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { + MarkSweep::follow_class_loader(klass->class_loader_data()); + } else { + MarkSweep::follow_klass(klass); + } } else { // If klass is NULL then this a mirror for a primitive type. // We don't have to follow them, since they are handled as strong @@ -196,17 +202,6 @@ int InstanceMirrorKlass::oop_adjust_pointers(oop obj) { int size = oop_size(obj); InstanceKlass::oop_adjust_pointers(obj); - // Follow the klass field in the mirror. - Klass* klass = java_lang_Class::as_Klass(obj); - if (klass != NULL) { - MarkSweep::adjust_klass(klass); - } else { - // If klass is NULL then this a mirror for a primitive type. - // We don't have to follow them, since they are handled as strong - // roots in Universe::oops_do. - assert(java_lang_Class::is_primitive(obj), "Sanity check"); - } - InstanceMirrorKlass_OOP_ITERATE( \ start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj), \ MarkSweep::adjust_pointer(p), \ diff --git a/src/share/vm/oops/objArrayKlass.cpp b/src/share/vm/oops/objArrayKlass.cpp index f2f349106..94c990a72 100644 --- a/src/share/vm/oops/objArrayKlass.cpp +++ b/src/share/vm/oops/objArrayKlass.cpp @@ -569,7 +569,6 @@ int ObjArrayKlass::oop_adjust_pointers(oop obj) { // Get size before changing pointers. // Don't call size() or oop_size() since that is a virtual call. int size = a->object_size(); - MarkSweep::adjust_klass(a->klass()); ObjArrayKlass_OOP_ITERATE(a, p, MarkSweep::adjust_pointer(p)) return size; } -- GitLab