src/hotspot/share/gc/shenandoah/shenandoahBrooksPointer.inline.hpp
changeset 52925 9c18c9d839d3
child 53244 9807daeb47c4
equal deleted inserted replaced
52924:420ff459906f 52925:9c18c9d839d3
       
     1 /*
       
     2  * Copyright (c) 2015, 2018, Red Hat, Inc. All rights reserved.
       
     3  *
       
     4  * This code is free software; you can redistribute it and/or modify it
       
     5  * under the terms of the GNU General Public License version 2 only, as
       
     6  * published by the Free Software Foundation.
       
     7  *
       
     8  * This code is distributed in the hope that it will be useful, but WITHOUT
       
     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_VM_GC_SHENANDOAH_SHENANDOAHBROOKSPOINTER_INLINE_HPP
       
    25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHBROOKSPOINTER_INLINE_HPP
       
    26 
       
    27 #include "gc/shenandoah/shenandoahAsserts.hpp"
       
    28 #include "gc/shenandoah/shenandoahBrooksPointer.hpp"
       
    29 #include "runtime/atomic.hpp"
       
    30 
       
    31 inline HeapWord** ShenandoahBrooksPointer::brooks_ptr_addr(oop obj) {
       
    32   return (HeapWord**)((HeapWord*) obj + word_offset());
       
    33 }
       
    34 
       
    35 inline void ShenandoahBrooksPointer::initialize(oop obj) {
       
    36   shenandoah_assert_in_heap(NULL, obj);
       
    37   *brooks_ptr_addr(obj) = (HeapWord*) obj;
       
    38 }
       
    39 
       
    40 inline void ShenandoahBrooksPointer::set_raw(oop obj, HeapWord* update) {
       
    41   shenandoah_assert_in_heap(NULL, obj);
       
    42   *brooks_ptr_addr(obj) = update;
       
    43 }
       
    44 
       
    45 inline HeapWord* ShenandoahBrooksPointer::get_raw(oop obj) {
       
    46   shenandoah_assert_in_heap(NULL, obj);
       
    47   return *brooks_ptr_addr(obj);
       
    48 }
       
    49 
       
    50 inline HeapWord* ShenandoahBrooksPointer::get_raw_unchecked(oop obj) {
       
    51   return *brooks_ptr_addr(obj);
       
    52 }
       
    53 
       
    54 inline oop ShenandoahBrooksPointer::forwardee(oop obj) {
       
    55   shenandoah_assert_correct(NULL, obj);
       
    56   return oop(*brooks_ptr_addr(obj));
       
    57 }
       
    58 
       
    59 inline oop ShenandoahBrooksPointer::try_update_forwardee(oop obj, oop update) {
       
    60   oop result = (oop) Atomic::cmpxchg(update, (oop*)brooks_ptr_addr(obj), obj);
       
    61   shenandoah_assert_correct_except(NULL, obj, !oopDesc::equals_raw(result, obj));
       
    62   return result;
       
    63 }
       
    64 
       
    65 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHBROOKSPOINTER_INLINE_HPP