Path: blob/master/src/hotspot/share/gc/shared/barrierSet.inline.hpp
40957 views
/*1* Copyright (c) 2019, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#ifndef SHARE_GC_SHARED_BARRIERSET_INLINE_HPP24#define SHARE_GC_SHARED_BARRIERSET_INLINE_HPP2526#include "gc/shared/barrierSet.hpp"2728#include "oops/accessDecorators.hpp"29#include "oops/arrayOop.hpp"30#include "oops/compressedOops.inline.hpp"31#include "oops/objArrayOop.inline.hpp"32#include "oops/oop.hpp"3334template <DecoratorSet decorators, typename BarrierSetT>35template <typename T>36inline bool BarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,37arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,38size_t length) {39T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);40T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);4142if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {43// Covariant, copy without checks44return Raw::oop_arraycopy(NULL, 0, src, NULL, 0, dst, length);45}4647// Copy each element with checking casts48Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();49for (const T* const end = src + length; src < end; src++, dst++) {50const T elem = *src;51if (!oopDesc::is_instanceof_or_null(CompressedOops::decode(elem), dst_klass)) {52return false;53}54*dst = elem;55}5657return true;58}5960#endif // SHARE_GC_SHARED_BARRIERSET_INLINE_HPP616263