< prev index next >

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Print this page
*** 71,10 ***
--- 71,11 ---
  #include "memory/metaspaceUtils.hpp"
  #include "memory/resourceArea.hpp"
  #include "memory/universe.hpp"
  #include "nmt/memTracker.hpp"
  #include "oops/access.inline.hpp"
+ #include "oops/flatArrayKlass.inline.hpp"
  #include "oops/instanceClassLoaderKlass.inline.hpp"
  #include "oops/instanceKlass.inline.hpp"
  #include "oops/instanceMirrorKlass.inline.hpp"
  #include "oops/methodData.hpp"
  #include "oops/objArrayKlass.inline.hpp"

*** 2398,12 ***
    if (copy_destination() != source()) {
      DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
      assert(source() != destination(), "inv");
      assert(cast_to_oop(source())->is_forwarded(), "inv");
      assert(cast_to_oop(source())->forwardee() == cast_to_oop(destination()), "inv");
      Copy::aligned_conjoint_words(source(), copy_destination(), words);
!     cast_to_oop(copy_destination())->init_mark();
    }
  
    update_state(words);
  }
  
--- 2399,15 ---
    if (copy_destination() != source()) {
      DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
      assert(source() != destination(), "inv");
      assert(cast_to_oop(source())->is_forwarded(), "inv");
      assert(cast_to_oop(source())->forwardee() == cast_to_oop(destination()), "inv");
+     // Read the klass before the copying, since it might destroy the klass (i.e. overlapping copy)
+     // and if partial copy, the destination klass may not be copied yet
+     Klass* klass = cast_to_oop(source())->klass();
      Copy::aligned_conjoint_words(source(), copy_destination(), words);
!     cast_to_oop(copy_destination())->set_mark(Klass::default_prototype_header(klass));
    }
  
    update_state(words);
  }
  
< prev index next >