40 #include "runtime/orderAccess.inline.hpp" |
40 #include "runtime/orderAccess.inline.hpp" |
41 #include "trace/traceMacros.hpp" |
41 #include "trace/traceMacros.hpp" |
42 #include "utilities/stack.hpp" |
42 #include "utilities/stack.hpp" |
43 #include "utilities/macros.hpp" |
43 #include "utilities/macros.hpp" |
44 #if INCLUDE_ALL_GCS |
44 #if INCLUDE_ALL_GCS |
|
45 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
45 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" |
46 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" |
46 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" |
47 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" |
47 #include "gc_implementation/parallelScavenge/psScavenge.hpp" |
48 #include "gc_implementation/parallelScavenge/psScavenge.hpp" |
48 #endif // INCLUDE_ALL_GCS |
49 #endif // INCLUDE_ALL_GCS |
49 |
50 |
157 set_secondary_supers(NULL); |
158 set_secondary_supers(NULL); |
158 set_secondary_super_cache(NULL); |
159 set_secondary_super_cache(NULL); |
159 _primary_supers[0] = k; |
160 _primary_supers[0] = k; |
160 set_super_check_offset(in_bytes(primary_supers_offset())); |
161 set_super_check_offset(in_bytes(primary_supers_offset())); |
161 |
162 |
162 set_java_mirror(NULL); |
163 // The constructor is used from init_self_patching_vtbl_list, |
|
164 // which doesn't zero out the memory before calling the constructor. |
|
165 // Need to set the field explicitly to not hit an assert that the field |
|
166 // should be NULL before setting it. |
|
167 _java_mirror = NULL; |
|
168 |
163 set_modifier_flags(0); |
169 set_modifier_flags(0); |
164 set_layout_helper(Klass::_lh_neutral_value); |
170 set_layout_helper(Klass::_lh_neutral_value); |
165 set_name(NULL); |
171 set_name(NULL); |
166 AccessFlags af; |
172 AccessFlags af; |
167 af.set_flags(0); |
173 af.set_flags(0); |
389 assert(!mirror_alive || loader_alive, "loader must be alive if the mirror is" |
395 assert(!mirror_alive || loader_alive, "loader must be alive if the mirror is" |
390 " but not the other way around with anonymous classes"); |
396 " but not the other way around with anonymous classes"); |
391 return mirror_alive; |
397 return mirror_alive; |
392 } |
398 } |
393 |
399 |
394 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) { |
400 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses) { |
395 if (!ClassUnloading) { |
401 if (!ClassUnloading) { |
396 return; |
402 return; |
397 } |
403 } |
398 |
404 |
399 Klass* root = SystemDictionary::Object_klass(); |
405 Klass* root = SystemDictionary::Object_klass(); |
434 if (sibling != NULL) { |
440 if (sibling != NULL) { |
435 stack.push(sibling); |
441 stack.push(sibling); |
436 } |
442 } |
437 |
443 |
438 // Clean the implementors list and method data. |
444 // Clean the implementors list and method data. |
439 if (current->oop_is_instance()) { |
445 if (clean_alive_klasses && current->oop_is_instance()) { |
440 InstanceKlass* ik = InstanceKlass::cast(current); |
446 InstanceKlass* ik = InstanceKlass::cast(current); |
441 ik->clean_implementors_list(is_alive); |
447 ik->clean_implementors_list(is_alive); |
442 ik->clean_method_data(is_alive); |
448 ik->clean_method_data(is_alive); |
443 } |
449 } |
444 } |
450 } |
446 |
452 |
447 void Klass::klass_update_barrier_set(oop v) { |
453 void Klass::klass_update_barrier_set(oop v) { |
448 record_modified_oops(); |
454 record_modified_oops(); |
449 } |
455 } |
450 |
456 |
451 void Klass::klass_update_barrier_set_pre(void* p, oop v) { |
457 // This barrier is used by G1 to remember the old oop values, so |
452 // This barrier used by G1, where it's used remember the old oop values, |
458 // that we don't forget any objects that were live at the snapshot at |
453 // so that we don't forget any objects that were live at the snapshot at |
459 // the beginning. This function is only used when we write oops into Klasses. |
454 // the beginning. This function is only used when we write oops into |
460 void Klass::klass_update_barrier_set_pre(oop* p, oop v) { |
455 // Klasses. Since the Klasses are used as roots in G1, we don't have to |
461 #if INCLUDE_ALL_GCS |
456 // do anything here. |
462 if (UseG1GC) { |
|
463 oop obj = *p; |
|
464 if (obj != NULL) { |
|
465 G1SATBCardTableModRefBS::enqueue(obj); |
|
466 } |
|
467 } |
|
468 #endif |
457 } |
469 } |
458 |
470 |
459 void Klass::klass_oop_store(oop* p, oop v) { |
471 void Klass::klass_oop_store(oop* p, oop v) { |
460 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
472 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
461 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
473 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
462 |
474 |
463 // do the store |
475 // do the store |
464 if (always_do_update_barrier) { |
476 if (always_do_update_barrier) { |
465 klass_oop_store((volatile oop*)p, v); |
477 klass_oop_store((volatile oop*)p, v); |
466 } else { |
478 } else { |
467 klass_update_barrier_set_pre((void*)p, v); |
479 klass_update_barrier_set_pre(p, v); |
468 *p = v; |
480 *p = v; |
469 klass_update_barrier_set(v); |
481 klass_update_barrier_set(v); |
470 } |
482 } |
471 } |
483 } |
472 |
484 |
473 void Klass::klass_oop_store(volatile oop* p, oop v) { |
485 void Klass::klass_oop_store(volatile oop* p, oop v) { |
474 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
486 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
475 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
487 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
476 |
488 |
477 klass_update_barrier_set_pre((void*)p, v); |
489 klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile. |
478 OrderAccess::release_store_ptr(p, v); |
490 OrderAccess::release_store_ptr(p, v); |
479 klass_update_barrier_set(v); |
491 klass_update_barrier_set(v); |
480 } |
492 } |
481 |
493 |
482 void Klass::oops_do(OopClosure* cl) { |
494 void Klass::oops_do(OopClosure* cl) { |