< prev index next >

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

Print this page




  73   oop result = Raw::oop_atomic_cmpxchg(new_value, addr, compare_value);
  74   if (result == compare_value) {
  75     bs->template write_ref_field_post<decorators>(addr, new_value);
  76   }
  77   return result;
  78 }
  79 
  80 template <DecoratorSet decorators, typename BarrierSetT>
  81 template <typename T>
  82 inline oop ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  83 oop_atomic_xchg_in_heap(oop new_value, T* addr) {
  84   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  85   bs->template write_ref_field_pre<decorators>(addr);
  86   oop result = Raw::oop_atomic_xchg(new_value, addr);
  87   bs->template write_ref_field_post<decorators>(addr, new_value);
  88   return result;
  89 }
  90 
  91 template <DecoratorSet decorators, typename BarrierSetT>
  92 template <typename T>
  93 inline bool ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::











  94 oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
  95                       arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
  96                       size_t length) {
  97   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  98 
  99   src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
 100   dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
 101 
 102   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {

 103     // Optimized covariant case
 104     bs->write_ref_array_pre(dst_raw, length,
 105                             HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value);
 106     Raw::oop_arraycopy(NULL, 0, src_raw, NULL, 0, dst_raw, length);
 107     bs->write_ref_array((HeapWord*)dst_raw, length);
 108   } else {
 109     assert(dst_obj != NULL, "better have an actual oop");
 110     Klass* bound = objArrayOop(dst_obj)->element_klass();
 111     T* from = const_cast<T*>(src_raw);
 112     T* end = from + length;
 113     for (T* p = dst_raw; from < end; from++, p++) {
 114       T element = *from;
 115       if (oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound)) {
 116         bs->template write_ref_field_pre<decorators>(p);
 117         *p = element;
 118       } else {
 119         // We must do a barrier to cover the partial copy.
 120         const size_t pd = pointer_delta(p, dst_raw, (size_t)heapOopSize);
 121         // pointer delta is scaled to number of elements (length field in
 122         // objArrayOop) which we assume is 32 bit.
 123         assert(pd == (size_t)(int)pd, "length field overflow");
 124         bs->write_ref_array((HeapWord*)dst_raw, pd);
 125         return false;
 126       }



 127     }
 128     bs->write_ref_array((HeapWord*)dst_raw, length);
 129   }
 130   return true;
 131 }
 132 
 133 template <DecoratorSet decorators, typename BarrierSetT>
 134 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 135 clone_in_heap(oop src, oop dst, size_t size) {
 136   Raw::clone(src, dst, size);
 137   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
 138   bs->write_region(MemRegion((HeapWord*)(void*)dst, size));
 139 }
 140 
 141 #endif // SHARE_GC_SHARED_MODREFBARRIERSET_INLINE_HPP


  73   oop result = Raw::oop_atomic_cmpxchg(new_value, addr, compare_value);
  74   if (result == compare_value) {
  75     bs->template write_ref_field_post<decorators>(addr, new_value);
  76   }
  77   return result;
  78 }
  79 
  80 template <DecoratorSet decorators, typename BarrierSetT>
  81 template <typename T>
  82 inline oop ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  83 oop_atomic_xchg_in_heap(oop new_value, T* addr) {
  84   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  85   bs->template write_ref_field_pre<decorators>(addr);
  86   oop result = Raw::oop_atomic_xchg(new_value, addr);
  87   bs->template write_ref_field_post<decorators>(addr, new_value);
  88   return result;
  89 }
  90 
  91 template <DecoratorSet decorators, typename BarrierSetT>
  92 template <typename T>
  93 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  94 oop_arraycopy_partial_barrier(BarrierSetT *bs, T* dst_raw, T* p) {
  95   const size_t pd = pointer_delta(p, dst_raw, (size_t)heapOopSize);
  96   // pointer delta is scaled to number of elements (length field in
  97   // objArrayOop) which we assume is 32 bit.
  98   assert(pd == (size_t)(int)pd, "length field overflow");
  99   bs->write_ref_array((HeapWord*)dst_raw, pd);
 100 }
 101 
 102 template <DecoratorSet decorators, typename BarrierSetT>
 103 template <typename T>
 104 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 105 oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
 106                       arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
 107                       size_t length) {
 108   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
 109 
 110   src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
 111   dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
 112 
 113   if ((!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) &&
 114       (!HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value)) {
 115     // Optimized covariant case
 116     bs->write_ref_array_pre(dst_raw, length,
 117                             HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value);
 118     Raw::oop_arraycopy(NULL, 0, src_raw, NULL, 0, dst_raw, length);
 119     bs->write_ref_array((HeapWord*)dst_raw, length);
 120   } else {
 121     assert(dst_obj != NULL, "better have an actual oop");
 122     Klass* bound = objArrayOop(dst_obj)->element_klass();
 123     T* from = const_cast<T*>(src_raw);
 124     T* end = from + length;
 125     for (T* p = dst_raw; from < end; from++, p++) {
 126       T element = *from;
 127       // Apply any required checks
 128       if (HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value && CompressedOops::is_null(element)) {
 129         oop_arraycopy_partial_barrier(bs, dst_raw, p);
 130         throw_array_null_pointer_store_exception(src_obj, dst_obj, Thread::current());
 131         return;
 132       }
 133       if (HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value &&
 134           (!oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound))) {
 135         oop_arraycopy_partial_barrier(bs, dst_raw, p);
 136         throw_array_store_exception(src_obj, dst_obj, Thread::current());
 137         return;
 138       }
 139       // write
 140       bs->template write_ref_field_pre<decorators>(p);
 141       *p = element;
 142     }
 143     bs->write_ref_array((HeapWord*)dst_raw, length);
 144   }

 145 }
 146 
 147 template <DecoratorSet decorators, typename BarrierSetT>
 148 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 149 clone_in_heap(oop src, oop dst, size_t size) {
 150   Raw::clone(src, dst, size);
 151   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
 152   bs->write_region(MemRegion((HeapWord*)(void*)dst, size));
 153 }
 154 
 155 #endif // SHARE_GC_SHARED_MODREFBARRIERSET_INLINE_HPP
< prev index next >