< prev index next >

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

Print this page
*** 74,20 ***
  inline bool ShenandoahForwarding::is_forwarded(oop obj) {
    return obj->mark().is_marked();
  }
  
  inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
!   markWord old_mark = obj->mark();
    if (old_mark.is_marked()) {
      return cast_to_oop(old_mark.clear_lock_bits().to_pointer());
    }
  
    markWord new_mark = markWord::encode_pointer_as_mark(update);
!   markWord prev_mark = obj->cas_set_mark(new_mark, old_mark, memory_order_conservative);
!   if (prev_mark == old_mark) {
!     return update;
!   } else {
!     return cast_to_oop(prev_mark.clear_lock_bits().to_pointer());
    }
  }
  
  #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
--- 74,34 ---
  inline bool ShenandoahForwarding::is_forwarded(oop obj) {
    return obj->mark().is_marked();
  }
  
  inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
! 
+   markWord old_mark = ObjectSynchronizer::read_stable_mark(obj);
+   assert(!old_mark.is_being_inflated(), "must not see INFLATING marker here");
+ 
    if (old_mark.is_marked()) {
      return cast_to_oop(old_mark.clear_lock_bits().to_pointer());
    }
  
+   // Ensure that the copy has the correct mark-word, in case it happened to copy with
+   // INFLATING marker.
+   update->set_mark(old_mark);
+ 
    markWord new_mark = markWord::encode_pointer_as_mark(update);
!   while (true) {
!     markWord prev_mark = obj->cas_set_mark(new_mark, old_mark, memory_order_conservative);
!     if (prev_mark == old_mark) {
!       return update;
!     } else if (prev_mark == markWord::INFLATING()) {
+       // This happens when we encounter a stack-locked object in from-space.
+       // Busy-wait for completion.
+       SpinPause();
+     } else {
+       assert(prev_mark.is_marked(), "must be forwarded");
+       return cast_to_oop(prev_mark.clear_lock_bits().to_pointer());
+     }
    }
  }
  
  #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
< prev index next >