< prev index next >

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

Print this page

 59   markWord mark = obj->mark();
 60   if (mark.is_marked()) {
 61     HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
 62     assert(fwdptr != NULL, "Forwarding pointer is never null here");
 63     return cast_to_oop(fwdptr);
 64   } else {
 65     return obj;
 66   }
 67 }
 68 
 69 inline oop ShenandoahForwarding::get_forwardee(oop obj) {
 70   shenandoah_assert_correct(NULL, obj);
 71   return get_forwardee_raw_unchecked(obj);
 72 }
 73 
 74 inline bool ShenandoahForwarding::is_forwarded(oop obj) {
 75   return obj->mark().is_marked();
 76 }
 77 
 78 inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
 79   markWord old_mark = obj->mark();



 80   if (old_mark.is_marked()) {
 81     return cast_to_oop(old_mark.clear_lock_bits().to_pointer());
 82   }
 83 




 84   markWord new_mark = markWord::encode_pointer_as_mark(update);
 85   markWord prev_mark = obj->cas_set_mark(new_mark, old_mark, memory_order_conservative);
 86   if (prev_mark == old_mark) {
 87     return update;
 88   } else {
 89     return cast_to_oop(prev_mark.clear_lock_bits().to_pointer());







 90   }
 91 }
 92 
 93 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP

 59   markWord mark = obj->mark();
 60   if (mark.is_marked()) {
 61     HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
 62     assert(fwdptr != NULL, "Forwarding pointer is never null here");
 63     return cast_to_oop(fwdptr);
 64   } else {
 65     return obj;
 66   }
 67 }
 68 
 69 inline oop ShenandoahForwarding::get_forwardee(oop obj) {
 70   shenandoah_assert_correct(NULL, obj);
 71   return get_forwardee_raw_unchecked(obj);
 72 }
 73 
 74 inline bool ShenandoahForwarding::is_forwarded(oop obj) {
 75   return obj->mark().is_marked();
 76 }
 77 
 78 inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
 79 
 80   markWord old_mark = ObjectSynchronizer::read_stable_mark(obj);
 81   assert(!old_mark.is_being_inflated(), "must not see INFLATING marker here");
 82 
 83   if (old_mark.is_marked()) {
 84     return cast_to_oop(old_mark.clear_lock_bits().to_pointer());
 85   }
 86 
 87   // Ensure that the copy has the correct mark-word, in case it happened to copy with
 88   // INFLATING marker.
 89   update->set_mark(old_mark);
 90 
 91   markWord new_mark = markWord::encode_pointer_as_mark(update);
 92   while (true) {
 93     markWord prev_mark = obj->cas_set_mark(new_mark, old_mark, memory_order_conservative);
 94     if (prev_mark == old_mark) {
 95       return update;
 96     } else if (prev_mark == markWord::INFLATING()) {
 97       // This happens when we encounter a stack-locked object in from-space.
 98       // Busy-wait for completion.
 99       SpinPause();
100     } else {
101       assert(prev_mark.is_marked(), "must be forwarded");
102       return cast_to_oop(prev_mark.clear_lock_bits().to_pointer());
103     }
104   }
105 }
106 
107 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
< prev index next >