< prev index next >

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

Print this page
rev 55608 : Rename ShenandoahBrooksPointer to ShenandoahForwarding
rev 55609 : Eliminate extra forwarding pointer per object


   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
  26 
  27 #include "gc/shenandoah/shenandoahAsserts.hpp"
  28 #include "gc/shenandoah/shenandoahForwarding.hpp"

  29 #include "runtime/atomic.hpp"
  30 
  31 inline HeapWord** ShenandoahForwarding::forward_ptr_addr(oop obj) {
  32   return (HeapWord**)((HeapWord*) obj + word_offset());
  33 }
  34 
  35 inline void ShenandoahForwarding::initialize(oop obj) {
  36   shenandoah_assert_in_heap(NULL, obj);
  37   *forward_ptr_addr(obj) = (HeapWord*) obj;
  38 }
  39 
  40 inline void ShenandoahForwarding::set_forwardee_raw(oop obj, HeapWord* update) {
  41   shenandoah_assert_in_heap(NULL, obj);
  42   *forward_ptr_addr(obj) = update;
  43 }
  44 
  45 inline HeapWord* ShenandoahForwarding::get_forwardee_raw(oop obj) {
  46   shenandoah_assert_in_heap(NULL, obj);
  47   return *forward_ptr_addr(obj);
  48 }
  49 
  50 inline HeapWord* ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
  51   return *forward_ptr_addr(obj);





  52 }
  53 
  54 inline oop ShenandoahForwarding::get_forwardee(oop obj) {
  55   shenandoah_assert_correct(NULL, obj);
  56   return oop(*forward_ptr_addr(obj));




  57 }
  58 
  59 inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
  60   oop result = (oop) Atomic::cmpxchg(update, (oop*)forward_ptr_addr(obj), obj);
  61   shenandoah_assert_correct_except(NULL, obj, !oopDesc::equals_raw(result, obj));
  62   return result;









  63 }
  64 
  65 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP


   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
  26 
  27 #include "gc/shenandoah/shenandoahAsserts.hpp"
  28 #include "gc/shenandoah/shenandoahForwarding.hpp"
  29 #include "oops/markOop.inline.hpp"
  30 #include "runtime/atomic.hpp"
  31 














  32 inline HeapWord* ShenandoahForwarding::get_forwardee_raw(oop obj) {
  33   shenandoah_assert_in_heap(NULL, obj);
  34   return get_forwardee_raw_unchecked(obj);
  35 }
  36 
  37 inline HeapWord* ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
  38   markOop mark = obj->mark_raw();
  39   if (mark->is_marked()) {
  40     return (HeapWord*) mark->clear_lock_bits();
  41   } else {
  42     return (HeapWord*) obj;
  43   }
  44 }
  45 
  46 inline oop ShenandoahForwarding::get_forwardee(oop obj) {
  47   shenandoah_assert_correct(NULL, obj);
  48   return oop(get_forwardee_raw_unchecked(obj));
  49 }
  50 
  51 inline bool ShenandoahForwarding::is_forwarded(oop obj) {
  52   return obj->mark_raw()->is_marked();
  53 }
  54 
  55 inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
  56   markOop old_mark = obj->mark_raw();
  57   if (old_mark->is_marked()) {
  58     return (oop) old_mark->clear_lock_bits();
  59   }
  60 
  61   markOop new_mark = markOopDesc::encode_pointer_as_mark(update);
  62   markOop prev_mark = obj->cas_set_mark_raw(new_mark, old_mark);
  63   if (prev_mark == old_mark) {
  64     return obj;
  65   } else {
  66     return (oop) prev_mark->clear_lock_bits();
  67   }
  68 }
  69 
  70 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP
< prev index next >