< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp

Print this page
@@ -40,10 +40,11 @@
  #include "gc/shenandoah/shenandoahWorkGroup.hpp"
  #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
  #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
  #include "gc/shenandoah/shenandoahControlThread.hpp"
  #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
+ #include "gc/shenandoah/shenandoahObjectUtils.inline.hpp"
  #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  #include "oops/compressedOops.inline.hpp"
  #include "oops/oop.inline.hpp"
  #include "runtime/atomic.hpp"
  #include "runtime/javaThread.hpp"

@@ -295,11 +296,11 @@
      return ShenandoahBarrierSet::resolve_forwarded(p);
    }
  
    assert(ShenandoahThreadLocalData::is_evac_allowed(thread), "must be enclosed in oom-evac scope");
  
-   size_t size = p->size();
+   size_t size = ShenandoahObjectUtils::size(p);
  
    assert(!heap_region_containing(p)->is_humongous(), "never evacuate humongous objects");
  
    bool alloc_from_gclab = true;
    HeapWord* copy = NULL;

@@ -333,12 +334,17 @@
    // Copy the object:
    Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(p), copy, size);
  
    // Try to install the new forwarding pointer.
    oop copy_val = cast_to_oop(copy);
-   ContinuationGCSupport::relativize_stack_chunk(copy_val);
- 
+   if (!copy_val->mark().is_marked()) {
+     // If we copied a mark-word that indicates 'forwarded' state, then
+     // another thread beat us, and this new copy will never be published.
+     // ContinuationGCSupport would get a corrupt Klass* in that case,
+     // so don't even attempt it.
+     ContinuationGCSupport::relativize_stack_chunk(copy_val);
+   }
    oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val);
    if (result == copy_val) {
      // Successfully evacuated. Our copy is now the public one!
      shenandoah_assert_correct(NULL, copy_val);
      return copy_val;

@@ -514,11 +520,11 @@
      assert (cs >= tams, "only objects past TAMS here: "   PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
      assert (cs < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(limit));
      oop obj = cast_to_oop(cs);
      assert(oopDesc::is_oop(obj), "sanity");
      assert(ctx->is_marked(obj), "object expected to be marked");
-     size_t size = obj->size();
+     size_t size = ShenandoahObjectUtils::size(obj);
      cl->do_object(obj);
      cs += size;
    }
  }
  
< prev index next >