comparison src/share/vm/oops/instanceMirrorKlass.cpp @ 13438:ad72068ac41e

8028993: Full collections with ParallelScavenge slower in JDK 8 compared to 7u40 Summary: Reducing the number of calls to follow_class_loader to speed up the marking phase. Also removed some unnecessary calls to adjust_klass. Reviewed-by: stefank, jmasa, mgerdin
author sjohanss
date Tue, 10 Dec 2013 10:31:00 +0100
parents 55a0da3d420b
children de6a9e811145
comparison
equal deleted inserted replaced
13437:1de8e5356754 13438:ad72068ac41e
153 InstanceKlass::oop_follow_contents(obj); 153 InstanceKlass::oop_follow_contents(obj);
154 154
155 // Follow the klass field in the mirror. 155 // Follow the klass field in the mirror.
156 Klass* klass = java_lang_Class::as_Klass(obj); 156 Klass* klass = java_lang_Class::as_Klass(obj);
157 if (klass != NULL) { 157 if (klass != NULL) {
158 // For anonymous classes we need to handle the class loader data, 158 // An anonymous class doesn't have its own class loader, so the call
159 // otherwise it won't be claimed and can be unloaded. 159 // to follow_klass will mark and push its java mirror instead of the
160 // class loader. When handling the java mirror for an anonymous class
161 // we need to make sure its class loader data is claimed, this is done
162 // by calling follow_class_loader explicitly. For non-anonymous classes
163 // the call to follow_class_loader is made when the class loader itself
164 // is handled.
160 if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { 165 if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) {
161 MarkSweep::follow_class_loader(klass->class_loader_data()); 166 MarkSweep::follow_class_loader(klass->class_loader_data());
162 } else { 167 } else {
163 MarkSweep::follow_klass(klass); 168 MarkSweep::follow_klass(klass);
164 } 169 }
181 InstanceKlass::oop_follow_contents(cm, obj); 186 InstanceKlass::oop_follow_contents(cm, obj);
182 187
183 // Follow the klass field in the mirror. 188 // Follow the klass field in the mirror.
184 Klass* klass = java_lang_Class::as_Klass(obj); 189 Klass* klass = java_lang_Class::as_Klass(obj);
185 if (klass != NULL) { 190 if (klass != NULL) {
186 PSParallelCompact::follow_klass(cm, klass); 191 // An anonymous class doesn't have its own class loader, so the call
192 // to follow_klass will mark and push its java mirror instead of the
193 // class loader. When handling the java mirror for an anonymous class
194 // we need to make sure its class loader data is claimed, this is done
195 // by calling follow_class_loader explicitly. For non-anonymous classes
196 // the call to follow_class_loader is made when the class loader itself
197 // is handled.
198 if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) {
199 PSParallelCompact::follow_class_loader(cm, klass->class_loader_data());
200 } else {
201 PSParallelCompact::follow_klass(cm, klass);
202 }
187 } else { 203 } else {
188 // If klass is NULL then this a mirror for a primitive type. 204 // If klass is NULL then this a mirror for a primitive type.
189 // We don't have to follow them, since they are handled as strong 205 // We don't have to follow them, since they are handled as strong
190 // roots in Universe::oops_do. 206 // roots in Universe::oops_do.
191 assert(java_lang_Class::is_primitive(obj), "Sanity check"); 207 assert(java_lang_Class::is_primitive(obj), "Sanity check");
330 346
331 int InstanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { 347 int InstanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
332 int size = oop_size(obj); 348 int size = oop_size(obj);
333 InstanceKlass::oop_update_pointers(cm, obj); 349 InstanceKlass::oop_update_pointers(cm, obj);
334 350
335 // Follow the klass field in the mirror.
336 Klass* klass = java_lang_Class::as_Klass(obj);
337 if (klass != NULL) {
338 PSParallelCompact::adjust_klass(cm, klass);
339 } else {
340 // If klass is NULL then this a mirror for a primitive type.
341 // We don't have to follow them, since they are handled as strong
342 // roots in Universe::oops_do.
343 assert(java_lang_Class::is_primitive(obj), "Sanity check");
344 }
345
346 InstanceMirrorKlass_OOP_ITERATE( \ 351 InstanceMirrorKlass_OOP_ITERATE( \
347 start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\ 352 start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
348 PSParallelCompact::adjust_pointer(p), \ 353 PSParallelCompact::adjust_pointer(p), \
349 assert_nothing) 354 assert_nothing)
350 return size; 355 return size;