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); |
381 assert(!mirror_alive || loader_alive, "loader must be alive if the mirror is" |
387 assert(!mirror_alive || loader_alive, "loader must be alive if the mirror is" |
382 " but not the other way around with anonymous classes"); |
388 " but not the other way around with anonymous classes"); |
383 return mirror_alive; |
389 return mirror_alive; |
384 } |
390 } |
385 |
391 |
386 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) { |
392 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses) { |
387 if (!ClassUnloading) { |
393 if (!ClassUnloading) { |
388 return; |
394 return; |
389 } |
395 } |
390 |
396 |
391 Klass* root = SystemDictionary::Object_klass(); |
397 Klass* root = SystemDictionary::Object_klass(); |
426 if (sibling != NULL) { |
432 if (sibling != NULL) { |
427 stack.push(sibling); |
433 stack.push(sibling); |
428 } |
434 } |
429 |
435 |
430 // Clean the implementors list and method data. |
436 // Clean the implementors list and method data. |
431 if (current->oop_is_instance()) { |
437 if (clean_alive_klasses && current->oop_is_instance()) { |
432 InstanceKlass* ik = InstanceKlass::cast(current); |
438 InstanceKlass* ik = InstanceKlass::cast(current); |
433 ik->clean_implementors_list(is_alive); |
439 ik->clean_implementors_list(is_alive); |
434 ik->clean_method_data(is_alive); |
440 ik->clean_method_data(is_alive); |
435 } |
441 } |
436 } |
442 } |
438 |
444 |
439 void Klass::klass_update_barrier_set(oop v) { |
445 void Klass::klass_update_barrier_set(oop v) { |
440 record_modified_oops(); |
446 record_modified_oops(); |
441 } |
447 } |
442 |
448 |
443 void Klass::klass_update_barrier_set_pre(void* p, oop v) { |
449 // This barrier is used by G1 to remember the old oop values, so |
444 // This barrier used by G1, where it's used remember the old oop values, |
450 // that we don't forget any objects that were live at the snapshot at |
445 // so that we don't forget any objects that were live at the snapshot at |
451 // the beginning. This function is only used when we write oops into Klasses. |
446 // the beginning. This function is only used when we write oops into |
452 void Klass::klass_update_barrier_set_pre(oop* p, oop v) { |
447 // Klasses. Since the Klasses are used as roots in G1, we don't have to |
453 #if INCLUDE_ALL_GCS |
448 // do anything here. |
454 if (UseG1GC) { |
|
455 oop obj = *p; |
|
456 if (obj != NULL) { |
|
457 G1SATBCardTableModRefBS::enqueue(obj); |
|
458 } |
|
459 } |
|
460 #endif |
449 } |
461 } |
450 |
462 |
451 void Klass::klass_oop_store(oop* p, oop v) { |
463 void Klass::klass_oop_store(oop* p, oop v) { |
452 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
464 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
453 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
465 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
454 |
466 |
455 // do the store |
467 // do the store |
456 if (always_do_update_barrier) { |
468 if (always_do_update_barrier) { |
457 klass_oop_store((volatile oop*)p, v); |
469 klass_oop_store((volatile oop*)p, v); |
458 } else { |
470 } else { |
459 klass_update_barrier_set_pre((void*)p, v); |
471 klass_update_barrier_set_pre(p, v); |
460 *p = v; |
472 *p = v; |
461 klass_update_barrier_set(v); |
473 klass_update_barrier_set(v); |
462 } |
474 } |
463 } |
475 } |
464 |
476 |
465 void Klass::klass_oop_store(volatile oop* p, oop v) { |
477 void Klass::klass_oop_store(volatile oop* p, oop v) { |
466 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
478 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); |
467 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
479 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); |
468 |
480 |
469 klass_update_barrier_set_pre((void*)p, v); |
481 klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile. |
470 OrderAccess::release_store_ptr(p, v); |
482 OrderAccess::release_store_ptr(p, v); |
471 klass_update_barrier_set(v); |
483 klass_update_barrier_set(v); |
472 } |
484 } |
473 |
485 |
474 void Klass::oops_do(OopClosure* cl) { |
486 void Klass::oops_do(OopClosure* cl) { |