< 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.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 // count is number of array elements being written
  35 void ModRefBarrierSet::write_ref_array(HeapWord* start, size_t count) {
  36   HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize));
  37   // In the case of compressed oops, start and end may potentially be misaligned;
  38   // so we need to conservatively align the first downward (this is not
  39   // strictly necessary for current uses, but a case of good hygiene and,
  40   // if you will, aesthetics) and the second upward (this is essential for
  41   // current uses) to a HeapWord boundary, so we mark all cards overlapping
  42   // this write. If this evolves in the future to calling a
  43   // logging barrier of narrow oop granularity, like the pre-barrier for G1
  44   // (mentioned here merely by way of example), we will need to change this
  45   // interface, so it is "exactly precise" (if i may be allowed the adverbial
  46   // redundancy for emphasis) and does not include narrow oop slots not
  47   // included in the original write interval.
  48   HeapWord* aligned_start = align_down(start, HeapWordSize);
  49   HeapWord* aligned_end   = align_up  (end,   HeapWordSize);


  88 }
  89 
  90 template <DecoratorSet decorators, typename BarrierSetT>
  91 template <typename T>
  92 inline bool ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
  93 oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
  94   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  95 
  96   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
  97     // Optimized covariant case
  98     bs->write_ref_array_pre(dst, length,
  99                             HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value);
 100     Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
 101     bs->write_ref_array((HeapWord*)dst, length);
 102   } else {
 103     Klass* bound = objArrayOop(dst_obj)->element_klass();
 104     T* from = src;
 105     T* end = from + length;
 106     for (T* p = dst; from < end; from++, p++) {
 107       T element = *from;
 108       if (bound->is_instanceof_or_null(element)) {
 109         bs->template write_ref_field_pre<decorators>(p);
 110         *p = element;
 111       } else {
 112         // We must do a barrier to cover the partial copy.
 113         const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
 114         // pointer delta is scaled to number of elements (length field in
 115         // objArrayOop) which we assume is 32 bit.
 116         assert(pd == (size_t)(int)pd, "length field overflow");
 117         bs->write_ref_array((HeapWord*)dst, pd);
 118         return false;
 119       }
 120     }
 121     bs->write_ref_array((HeapWord*)dst, length);
 122   }
 123   return true;
 124 }
 125 
 126 template <DecoratorSet decorators, typename BarrierSetT>
 127 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 128 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.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 // count is number of array elements being written
  36 void ModRefBarrierSet::write_ref_array(HeapWord* start, size_t count) {
  37   HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize));
  38   // In the case of compressed oops, start and end may potentially be misaligned;
  39   // so we need to conservatively align the first downward (this is not
  40   // strictly necessary for current uses, but a case of good hygiene and,
  41   // if you will, aesthetics) and the second upward (this is essential for
  42   // current uses) to a HeapWord boundary, so we mark all cards overlapping
  43   // this write. If this evolves in the future to calling a
  44   // logging barrier of narrow oop granularity, like the pre-barrier for G1
  45   // (mentioned here merely by way of example), we will need to change this
  46   // interface, so it is "exactly precise" (if i may be allowed the adverbial
  47   // redundancy for emphasis) and does not include narrow oop slots not
  48   // included in the original write interval.
  49   HeapWord* aligned_start = align_down(start, HeapWordSize);
  50   HeapWord* aligned_end   = align_up  (end,   HeapWordSize);


  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, arrayOop dst_obj, T* src, T* dst, size_t length) {
  95   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
  96 
  97   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
  98     // Optimized covariant case
  99     bs->write_ref_array_pre(dst, length,
 100                             HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value);
 101     Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
 102     bs->write_ref_array((HeapWord*)dst, length);
 103   } else {
 104     Klass* bound = objArrayOop(dst_obj)->element_klass();
 105     T* from = src;
 106     T* end = from + length;
 107     for (T* p = dst; from < end; from++, p++) {
 108       T element = *from;
 109       if (oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound)) {
 110         bs->template write_ref_field_pre<decorators>(p);
 111         *p = element;
 112       } else {
 113         // We must do a barrier to cover the partial copy.
 114         const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
 115         // pointer delta is scaled to number of elements (length field in
 116         // objArrayOop) which we assume is 32 bit.
 117         assert(pd == (size_t)(int)pd, "length field overflow");
 118         bs->write_ref_array((HeapWord*)dst, pd);
 119         return false;
 120       }
 121     }
 122     bs->write_ref_array((HeapWord*)dst, length);
 123   }
 124   return true;
 125 }
 126 
 127 template <DecoratorSet decorators, typename BarrierSetT>
 128 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 129 clone_in_heap(oop src, oop dst, size_t size) {
< prev index next >