< prev index next >

src/hotspot/share/gc/z/zBarrierSet.inline.hpp

Print this page
*** 26,10 ***
--- 26,11 ---
  
  #include "gc/z/zBarrierSet.hpp"
  
  #include "gc/shared/accessBarrierSupport.inline.hpp"
  #include "gc/z/zBarrier.inline.hpp"
+ #include "oops/inlineKlass.inline.hpp"
  #include "utilities/debug.hpp"
  
  template <DecoratorSet decorators, typename BarrierSetT>
  template <DecoratorSet expected>
  inline void ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::verify_decorators_present() {

*** 173,44 ***
    return ZBarrier::load_barrier_on_oop(o);
  }
  
  template <DecoratorSet decorators, typename BarrierSetT>
  template <typename T>
! inline bool ZBarrierSet::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) {
    T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
    T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
  
!   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
      // No check cast, bulk barrier and bulk copy
      ZBarrier::load_barrier_on_oop_array(src, length);
!     return Raw::oop_arraycopy_in_heap(NULL, 0, src, NULL, 0, dst, length);
    }
  
    // Check cast and copy each elements
    Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();
    for (const T* const end = src + length; src < end; src++, dst++) {
      const oop elem = ZBarrier::load_barrier_on_oop_field(src);
!     if (!oopDesc::is_instanceof_or_null(elem, dst_klass)) {
        // Check cast failed
!       return false;
      }
  
      // Cast is safe, since we know it's never a narrowOop
      *(oop*)dst = elem;
    }
- 
-   return true;
  }
  
  template <DecoratorSet decorators, typename BarrierSetT>
  inline void ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::clone_in_heap(oop src, oop dst, size_t size) {
    ZBarrier::load_barrier_on_oop_fields(src);
    Raw::clone_in_heap(src, dst, size);
  }
  
  //
  // Not in heap
  //
  template <DecoratorSet decorators, typename BarrierSetT>
  template <typename T>
--- 174,67 ---
    return ZBarrier::load_barrier_on_oop(o);
  }
  
  template <DecoratorSet decorators, typename BarrierSetT>
  template <typename T>
! inline void ZBarrierSet::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) {
    T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
    T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
  
!   if ((!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) &&
+       (!HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value)) {
      // No check cast, bulk barrier and bulk copy
      ZBarrier::load_barrier_on_oop_array(src, length);
!     Raw::oop_arraycopy_in_heap(NULL, 0, src, NULL, 0, dst, length);
+     return;
    }
  
    // Check cast and copy each elements
    Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();
    for (const T* const end = src + length; src < end; src++, dst++) {
      const oop elem = ZBarrier::load_barrier_on_oop_field(src);
!     if (HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value && elem == NULL) {
+       throw_array_null_pointer_store_exception(src_obj, dst_obj, JavaThread::current());
+       return;
+     }
+     if (HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value &&
+         (!oopDesc::is_instanceof_or_null(elem, dst_klass))) {
        // Check cast failed
!       throw_array_store_exception(src_obj, dst_obj, JavaThread::current());
+       return;
      }
  
      // Cast is safe, since we know it's never a narrowOop
      *(oop*)dst = elem;
    }
  }
  
  template <DecoratorSet decorators, typename BarrierSetT>
  inline void ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::clone_in_heap(oop src, oop dst, size_t size) {
    ZBarrier::load_barrier_on_oop_fields(src);
    Raw::clone_in_heap(src, dst, size);
  }
  
+ template <DecoratorSet decorators, typename BarrierSetT>
+ inline void ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::value_copy_in_heap(void* src, void* dst, InlineKlass* md) {
+   if (md->contains_oops()) {
+     // src/dst aren't oops, need offset to adjust oop map offset
+     const address src_oop_addr_offset = ((address) src) - md->first_field_offset();
+ 
+     OopMapBlock* map = md->start_of_nonstatic_oop_maps();
+     OopMapBlock* const end = map + md->nonstatic_oop_map_count();
+     while (map != end) {
+       address soop_address = src_oop_addr_offset + map->offset();
+       ZBarrier::load_barrier_on_oop_array((oop*) soop_address, map->count());
+       map++;
+     }
+   }
+   Raw::value_copy_in_heap(src, dst, md);
+ }
+ 
  //
  // Not in heap
  //
  template <DecoratorSet decorators, typename BarrierSetT>
  template <typename T>
< prev index next >