< prev index next >

src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp

Print this page




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

  30 #include "oops/klass.inline.hpp"
  31 #include "oops/objArrayOop.hpp"
  32 #include "oops/oop.hpp"
  33 
  34 template <DecoratorSet decorators, typename BarrierSetT>
  35 template <typename T>
  36 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  37 oop_store_in_heap(T* addr, oop value) {
  38   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  39   bs->template write_ref_field_pre<decorators>(addr);
  40   Raw::oop_store(addr, value);
  41   bs->template write_ref_field_post<decorators>(addr, value);
  42 }
  43 
  44 template <DecoratorSet decorators, typename BarrierSetT>
  45 template <typename T>
  46 inline oop ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  47 oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) {
  48   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  49   bs->template write_ref_field_pre<decorators>(addr);


  66 }
  67 
  68 template <DecoratorSet decorators, typename BarrierSetT>
  69 template <typename T>
  70 inline bool ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  71 oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
  72   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  73 
  74   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
  75     // Optimized covariant case
  76     bs->write_ref_array_pre(dst, (int)length,
  77                             HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value);
  78     Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
  79     bs->write_ref_array((HeapWord*)dst, length);
  80   } else {
  81     Klass* bound = objArrayOop(dst_obj)->element_klass();
  82     T* from = src;
  83     T* end = from + length;
  84     for (T* p = dst; from < end; from++, p++) {
  85       T element = *from;
  86       if (bound->is_instanceof_or_null(element)) {
  87         bs->template write_ref_field_pre<decorators>(p);
  88         *p = element;
  89       } else {
  90         // We must do a barrier to cover the partial copy.
  91         const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
  92         // pointer delta is scaled to number of elements (length field in
  93         // objArrayOop) which we assume is 32 bit.
  94         assert(pd == (size_t)(int)pd, "length field overflow");
  95         bs->write_ref_array((HeapWord*)dst, pd);
  96         return false;
  97       }
  98     }
  99     bs->write_ref_array((HeapWord*)dst, length);
 100   }
 101   return true;
 102 }
 103 
 104 template <DecoratorSet decorators, typename BarrierSetT>
 105 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 106 clone_in_heap(oop src, oop dst, size_t size) {


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_MODREFBARRIERSET_INLINE_HPP
  26 #define SHARE_VM_GC_SHARED_MODREFBARRIERSET_INLINE_HPP
  27 
  28 #include "gc/shared/barrierSet.inline.hpp"
  29 #include "gc/shared/modRefBarrierSet.hpp"
  30 #include "oops/compressedOops.inline.hpp"
  31 #include "oops/klass.inline.hpp"
  32 #include "oops/objArrayOop.hpp"
  33 #include "oops/oop.hpp"
  34 
  35 template <DecoratorSet decorators, typename BarrierSetT>
  36 template <typename T>
  37 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  38 oop_store_in_heap(T* addr, oop value) {
  39   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  40   bs->template write_ref_field_pre<decorators>(addr);
  41   Raw::oop_store(addr, value);
  42   bs->template write_ref_field_post<decorators>(addr, value);
  43 }
  44 
  45 template <DecoratorSet decorators, typename BarrierSetT>
  46 template <typename T>
  47 inline oop ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  48 oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) {
  49   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  50   bs->template write_ref_field_pre<decorators>(addr);


  67 }
  68 
  69 template <DecoratorSet decorators, typename BarrierSetT>
  70 template <typename T>
  71 inline bool ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  72 oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
  73   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  74 
  75   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
  76     // Optimized covariant case
  77     bs->write_ref_array_pre(dst, (int)length,
  78                             HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value);
  79     Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
  80     bs->write_ref_array((HeapWord*)dst, length);
  81   } else {
  82     Klass* bound = objArrayOop(dst_obj)->element_klass();
  83     T* from = src;
  84     T* end = from + length;
  85     for (T* p = dst; from < end; from++, p++) {
  86       T element = *from;
  87       if (oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound)) {
  88         bs->template write_ref_field_pre<decorators>(p);
  89         *p = element;
  90       } else {
  91         // We must do a barrier to cover the partial copy.
  92         const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
  93         // pointer delta is scaled to number of elements (length field in
  94         // objArrayOop) which we assume is 32 bit.
  95         assert(pd == (size_t)(int)pd, "length field overflow");
  96         bs->write_ref_array((HeapWord*)dst, pd);
  97         return false;
  98       }
  99     }
 100     bs->write_ref_array((HeapWord*)dst, length);
 101   }
 102   return true;
 103 }
 104 
 105 template <DecoratorSet decorators, typename BarrierSetT>
 106 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 107 clone_in_heap(oop src, oop dst, size_t size) {
< prev index next >