< prev index next >

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

Print this page

        

@@ -88,20 +88,32 @@
   return result;
 }
 
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
-inline bool ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
+inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
+oop_arraycopy_partial_barrier(BarrierSetT *bs, T* dst_raw, T* p) {
+  const size_t pd = pointer_delta(p, dst_raw, (size_t)heapOopSize);
+  // pointer delta is scaled to number of elements (length field in
+  // objArrayOop) which we assume is 32 bit.
+  assert(pd == (size_t)(int)pd, "length field overflow");
+  bs->write_ref_array((HeapWord*)dst_raw, pd);
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
                       arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
                       size_t length) {
   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
 
   src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
   dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
 
-  if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
+  if ((!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) &&
+      (!HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value)) {
     // Optimized covariant case
     bs->write_ref_array_pre(dst_raw, length,
                             HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value);
     Raw::oop_arraycopy(NULL, 0, src_raw, NULL, 0, dst_raw, length);
     bs->write_ref_array((HeapWord*)dst_raw, length);

@@ -110,26 +122,28 @@
     Klass* bound = objArrayOop(dst_obj)->element_klass();
     T* from = const_cast<T*>(src_raw);
     T* end = from + length;
     for (T* p = dst_raw; from < end; from++, p++) {
       T element = *from;
-      if (oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound)) {
+      // Apply any required checks
+      if (HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value && CompressedOops::is_null(element)) {
+        oop_arraycopy_partial_barrier(bs, dst_raw, p);
+        throw_array_null_pointer_store_exception(src_obj, dst_obj, Thread::current());
+        return;
+      }
+      if (HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value &&
+          (!oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound))) {
+        oop_arraycopy_partial_barrier(bs, dst_raw, p);
+        throw_array_store_exception(src_obj, dst_obj, Thread::current());
+        return;
+      }
+      // write
         bs->template write_ref_field_pre<decorators>(p);
         *p = element;
-      } else {
-        // We must do a barrier to cover the partial copy.
-        const size_t pd = pointer_delta(p, dst_raw, (size_t)heapOopSize);
-        // pointer delta is scaled to number of elements (length field in
-        // objArrayOop) which we assume is 32 bit.
-        assert(pd == (size_t)(int)pd, "length field overflow");
-        bs->write_ref_array((HeapWord*)dst_raw, pd);
-        return false;
-      }
     }
     bs->write_ref_array((HeapWord*)dst_raw, length);
   }
-  return true;
 }
 
 template <DecoratorSet decorators, typename BarrierSetT>
 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
 clone_in_heap(oop src, oop dst, size_t size) {
< prev index next >