src/share/vm/oops/klass.cpp

changeset 6992
2c6ef90f030a
parent 6976
76b588255908
child 7089
6e0cb14ce59b
     1.1 --- a/src/share/vm/oops/klass.cpp	Tue Jul 01 09:03:55 2014 +0200
     1.2 +++ b/src/share/vm/oops/klass.cpp	Mon Jul 07 10:12:40 2014 +0200
     1.3 @@ -42,6 +42,7 @@
     1.4  #include "utilities/stack.hpp"
     1.5  #include "utilities/macros.hpp"
     1.6  #if INCLUDE_ALL_GCS
     1.7 +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
     1.8  #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
     1.9  #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
    1.10  #include "gc_implementation/parallelScavenge/psScavenge.hpp"
    1.11 @@ -159,7 +160,12 @@
    1.12    _primary_supers[0] = k;
    1.13    set_super_check_offset(in_bytes(primary_supers_offset()));
    1.14  
    1.15 -  set_java_mirror(NULL);
    1.16 +  // The constructor is used from init_self_patching_vtbl_list,
    1.17 +  // which doesn't zero out the memory before calling the constructor.
    1.18 +  // Need to set the field explicitly to not hit an assert that the field
    1.19 +  // should be NULL before setting it.
    1.20 +  _java_mirror = NULL;
    1.21 +
    1.22    set_modifier_flags(0);
    1.23    set_layout_helper(Klass::_lh_neutral_value);
    1.24    set_name(NULL);
    1.25 @@ -391,7 +397,7 @@
    1.26    return mirror_alive;
    1.27  }
    1.28  
    1.29 -void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) {
    1.30 +void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses) {
    1.31    if (!ClassUnloading) {
    1.32      return;
    1.33    }
    1.34 @@ -436,7 +442,7 @@
    1.35      }
    1.36  
    1.37      // Clean the implementors list and method data.
    1.38 -    if (current->oop_is_instance()) {
    1.39 +    if (clean_alive_klasses && current->oop_is_instance()) {
    1.40        InstanceKlass* ik = InstanceKlass::cast(current);
    1.41        ik->clean_implementors_list(is_alive);
    1.42        ik->clean_method_data(is_alive);
    1.43 @@ -448,12 +454,18 @@
    1.44    record_modified_oops();
    1.45  }
    1.46  
    1.47 -void Klass::klass_update_barrier_set_pre(void* p, oop v) {
    1.48 -  // This barrier used by G1, where it's used remember the old oop values,
    1.49 -  // so that we don't forget any objects that were live at the snapshot at
    1.50 -  // the beginning. This function is only used when we write oops into
    1.51 -  // Klasses. Since the Klasses are used as roots in G1, we don't have to
    1.52 -  // do anything here.
    1.53 +// This barrier is used by G1 to remember the old oop values, so
    1.54 +// that we don't forget any objects that were live at the snapshot at
    1.55 +// the beginning. This function is only used when we write oops into Klasses.
    1.56 +void Klass::klass_update_barrier_set_pre(oop* p, oop v) {
    1.57 +#if INCLUDE_ALL_GCS
    1.58 +  if (UseG1GC) {
    1.59 +    oop obj = *p;
    1.60 +    if (obj != NULL) {
    1.61 +      G1SATBCardTableModRefBS::enqueue(obj);
    1.62 +    }
    1.63 +  }
    1.64 +#endif
    1.65  }
    1.66  
    1.67  void Klass::klass_oop_store(oop* p, oop v) {
    1.68 @@ -464,7 +476,7 @@
    1.69    if (always_do_update_barrier) {
    1.70      klass_oop_store((volatile oop*)p, v);
    1.71    } else {
    1.72 -    klass_update_barrier_set_pre((void*)p, v);
    1.73 +    klass_update_barrier_set_pre(p, v);
    1.74      *p = v;
    1.75      klass_update_barrier_set(v);
    1.76    }
    1.77 @@ -474,7 +486,7 @@
    1.78    assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
    1.79    assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
    1.80  
    1.81 -  klass_update_barrier_set_pre((void*)p, v);
    1.82 +  klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile.
    1.83    OrderAccess::release_store_ptr(p, v);
    1.84    klass_update_barrier_set(v);
    1.85  }

mercurial