< prev index next >

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

Print this page

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 #ifndef SHARE_GC_SHARED_BARRIERSET_INLINE_HPP
25 #define SHARE_GC_SHARED_BARRIERSET_INLINE_HPP
26 
27 #include "gc/shared/barrierSet.hpp"
28 
29 #include "oops/accessDecorators.hpp"
30 #include "oops/arrayOop.hpp"
31 #include "oops/compressedOops.inline.hpp"
32 #include "oops/objArrayOop.inline.hpp"
33 #include "oops/oop.hpp"

34 
35 template <DecoratorSet decorators, typename BarrierSetT>
36 template <typename T>
37 inline bool BarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
38                                                                                       arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
39                                                                                       size_t length) {
40   T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
41   T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
42 
43   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {

44     // Covariant, copy without checks
45     return Raw::oop_arraycopy(NULL, 0, src, NULL, 0, dst, length);

46   }
47 
48   // Copy each element with checking casts
49   Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();
50   for (const T* const end = src + length; src < end; src++, dst++) {
51     const T elem = *src;
52     if (!oopDesc::is_instanceof_or_null(CompressedOops::decode(elem), dst_klass)) {
53       return false;






54     }
55     *dst = elem;
56   }
57 
58   return true;
59 }
60 
61 #endif // SHARE_GC_SHARED_BARRIERSET_INLINE_HPP

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 #ifndef SHARE_GC_SHARED_BARRIERSET_INLINE_HPP
25 #define SHARE_GC_SHARED_BARRIERSET_INLINE_HPP
26 
27 #include "gc/shared/barrierSet.hpp"
28 
29 #include "oops/accessDecorators.hpp"
30 #include "oops/arrayOop.hpp"
31 #include "oops/compressedOops.inline.hpp"
32 #include "oops/objArrayOop.inline.hpp"
33 #include "oops/oop.hpp"
34 #include "runtime/thread.hpp"
35 
36 template <DecoratorSet decorators, typename BarrierSetT>
37 template <typename T>
38 inline void BarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
39                                                                                       arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
40                                                                                       size_t length) {
41   T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
42   T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
43 
44   if ((!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) &&
45       (!HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value)) {
46     // Covariant, copy without checks
47     Raw::oop_arraycopy(NULL, 0, src, NULL, 0, dst, length);
48     return;
49   }
50 
51   // Copy each element with checking casts
52   Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();
53   for (const T* const end = src + length; src < end; src++, dst++) {
54     const T elem = *src;
55     if (HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value && CompressedOops::is_null(elem)) {
56       throw_array_null_pointer_store_exception(src_obj, dst_obj, JavaThread::current());
57       return;
58     }
59     if (HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value &&
60         (!oopDesc::is_instanceof_or_null(CompressedOops::decode(elem), dst_klass))) {
61       throw_array_store_exception(src_obj, dst_obj, JavaThread::current());
62       return;
63     }
64     *dst = elem;
65   }


66 }
67 
68 #endif // SHARE_GC_SHARED_BARRIERSET_INLINE_HPP
< prev index next >