< prev index next >

src/hotspot/share/gc/x/xBarrierSet.inline.hpp

Print this page

 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 #ifndef SHARE_GC_X_XBARRIERSET_INLINE_HPP
 25 #define SHARE_GC_X_XBARRIERSET_INLINE_HPP
 26 
 27 #include "gc/x/xBarrierSet.hpp"
 28 
 29 #include "gc/shared/accessBarrierSupport.inline.hpp"
 30 #include "gc/x/xBarrier.inline.hpp"

 31 #include "utilities/debug.hpp"
 32 
 33 template <DecoratorSet decorators, typename BarrierSetT>
 34 template <DecoratorSet expected>
 35 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::verify_decorators_present() {
 36   if ((decorators & expected) == 0) {
 37     fatal("Using unsupported access decorators");
 38   }
 39 }
 40 
 41 template <DecoratorSet decorators, typename BarrierSetT>
 42 template <DecoratorSet expected>
 43 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::verify_decorators_absent() {
 44   if ((decorators & expected) != 0) {
 45     fatal("Using unsupported access decorators");
 46   }
 47 }
 48 
 49 template <DecoratorSet decorators, typename BarrierSetT>
 50 inline oop* XBarrierSet::AccessBarrier<decorators, BarrierSetT>::field_addr(oop base, ptrdiff_t offset) {

158 template <typename T>
159 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap(T* addr, oop new_value) {
160   verify_decorators_present<ON_STRONG_OOP_REF>();
161   verify_decorators_absent<AS_NO_KEEPALIVE>();
162 
163   const oop o = Raw::oop_atomic_xchg_in_heap(addr, new_value);
164   return XBarrier::load_barrier_on_oop(o);
165 }
166 
167 template <DecoratorSet decorators, typename BarrierSetT>
168 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value) {
169   verify_decorators_present<ON_STRONG_OOP_REF>();
170   verify_decorators_absent<AS_NO_KEEPALIVE>();
171 
172   const oop o = Raw::oop_atomic_xchg_in_heap_at(base, offset, new_value);
173   return XBarrier::load_barrier_on_oop(o);
174 }
175 
176 template <DecoratorSet decorators, typename BarrierSetT>
177 template <typename T>
178 inline bool XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
179                                                                                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
180                                                                                        size_t length) {
181   T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
182   T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
183 
184   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {

185     // No check cast, bulk barrier and bulk copy
186     XBarrier::load_barrier_on_oop_array(src, length);
187     return Raw::oop_arraycopy_in_heap(nullptr, 0, src, nullptr, 0, dst, length);

188   }
189 
190   // Check cast and copy each elements
191   Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();
192   for (const T* const end = src + length; src < end; src++, dst++) {
193     const oop elem = XBarrier::load_barrier_on_oop_field(src);
194     if (!oopDesc::is_instanceof_or_null(elem, dst_klass)) {





195       // Check cast failed
196       return false;

197     }
198 
199     // Cast is safe, since we know it's never a narrowOop
200     *(oop*)dst = elem;
201   }
202 
203   return true;
204 }
205 
206 template <DecoratorSet decorators, typename BarrierSetT>
207 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::clone_in_heap(oop src, oop dst, size_t size) {
208   XBarrier::load_barrier_on_oop_fields(src);
209   Raw::clone_in_heap(src, dst, size);
210 }
211 

















212 //
213 // Not in heap
214 //
215 template <DecoratorSet decorators, typename BarrierSetT>
216 template <typename T>
217 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_not_in_heap(T* addr) {
218   verify_decorators_absent<ON_UNKNOWN_OOP_REF>();
219 
220   const oop o = Raw::oop_load_not_in_heap(addr);
221   return load_barrier_on_oop_field_preloaded(addr, o);
222 }
223 
224 template <DecoratorSet decorators, typename BarrierSetT>
225 template <typename T>
226 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value) {
227   verify_decorators_present<ON_STRONG_OOP_REF>();
228   verify_decorators_absent<AS_NO_KEEPALIVE>();
229 
230   return Raw::oop_atomic_cmpxchg_not_in_heap(addr, compare_value, new_value);
231 }

 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 #ifndef SHARE_GC_X_XBARRIERSET_INLINE_HPP
 25 #define SHARE_GC_X_XBARRIERSET_INLINE_HPP
 26 
 27 #include "gc/x/xBarrierSet.hpp"
 28 
 29 #include "gc/shared/accessBarrierSupport.inline.hpp"
 30 #include "gc/x/xBarrier.inline.hpp"
 31 #include "oops/inlineKlass.inline.hpp"
 32 #include "utilities/debug.hpp"
 33 
 34 template <DecoratorSet decorators, typename BarrierSetT>
 35 template <DecoratorSet expected>
 36 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::verify_decorators_present() {
 37   if ((decorators & expected) == 0) {
 38     fatal("Using unsupported access decorators");
 39   }
 40 }
 41 
 42 template <DecoratorSet decorators, typename BarrierSetT>
 43 template <DecoratorSet expected>
 44 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::verify_decorators_absent() {
 45   if ((decorators & expected) != 0) {
 46     fatal("Using unsupported access decorators");
 47   }
 48 }
 49 
 50 template <DecoratorSet decorators, typename BarrierSetT>
 51 inline oop* XBarrierSet::AccessBarrier<decorators, BarrierSetT>::field_addr(oop base, ptrdiff_t offset) {

159 template <typename T>
160 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap(T* addr, oop new_value) {
161   verify_decorators_present<ON_STRONG_OOP_REF>();
162   verify_decorators_absent<AS_NO_KEEPALIVE>();
163 
164   const oop o = Raw::oop_atomic_xchg_in_heap(addr, new_value);
165   return XBarrier::load_barrier_on_oop(o);
166 }
167 
168 template <DecoratorSet decorators, typename BarrierSetT>
169 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value) {
170   verify_decorators_present<ON_STRONG_OOP_REF>();
171   verify_decorators_absent<AS_NO_KEEPALIVE>();
172 
173   const oop o = Raw::oop_atomic_xchg_in_heap_at(base, offset, new_value);
174   return XBarrier::load_barrier_on_oop(o);
175 }
176 
177 template <DecoratorSet decorators, typename BarrierSetT>
178 template <typename T>
179 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
180                                                                                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
181                                                                                        size_t length) {
182   T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
183   T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
184 
185   if ((!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) &&
186       (!HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value)) {
187     // No check cast, bulk barrier and bulk copy
188     XBarrier::load_barrier_on_oop_array(src, length);
189     Raw::oop_arraycopy_in_heap(nullptr, 0, src, nullptr, 0, dst, length);
190     return;
191   }
192 
193   // Check cast and copy each elements
194   Klass* const dst_klass = objArrayOop(dst_obj)->element_klass();
195   for (const T* const end = src + length; src < end; src++, dst++) {
196     const oop elem = XBarrier::load_barrier_on_oop_field(src);
197     if (HasDecorator<decorators, ARRAYCOPY_NOTNULL>::value && elem == nullptr) {
198       throw_array_null_pointer_store_exception(src_obj, dst_obj, JavaThread::current());
199       return;
200     }
201     if (HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value &&
202         (!oopDesc::is_instanceof_or_null(elem, dst_klass))) {
203       // Check cast failed
204       throw_array_store_exception(src_obj, dst_obj, JavaThread::current());
205       return;
206     }
207 
208     // Cast is safe, since we know it's never a narrowOop
209     *(oop*)dst = elem;
210   }


211 }
212 
213 template <DecoratorSet decorators, typename BarrierSetT>
214 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::clone_in_heap(oop src, oop dst, size_t size) {
215   XBarrier::load_barrier_on_oop_fields(src);
216   Raw::clone_in_heap(src, dst, size);
217 }
218 
219 template <DecoratorSet decorators, typename BarrierSetT>
220 inline void XBarrierSet::AccessBarrier<decorators, BarrierSetT>::value_copy_in_heap(void* src, void* dst, InlineKlass* md) {
221   if (md->contains_oops()) {
222     // src/dst aren't oops, need offset to adjust oop map offset
223     const address src_oop_addr_offset = ((address) src) - md->first_field_offset();
224 
225     OopMapBlock* map = md->start_of_nonstatic_oop_maps();
226     OopMapBlock* const end = map + md->nonstatic_oop_map_count();
227     while (map != end) {
228       address soop_address = src_oop_addr_offset + map->offset();
229       XBarrier::load_barrier_on_oop_array((oop*) soop_address, map->count());
230       map++;
231     }
232   }
233   Raw::value_copy_in_heap(src, dst, md);
234 }
235 
236 //
237 // Not in heap
238 //
239 template <DecoratorSet decorators, typename BarrierSetT>
240 template <typename T>
241 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_not_in_heap(T* addr) {
242   verify_decorators_absent<ON_UNKNOWN_OOP_REF>();
243 
244   const oop o = Raw::oop_load_not_in_heap(addr);
245   return load_barrier_on_oop_field_preloaded(addr, o);
246 }
247 
248 template <DecoratorSet decorators, typename BarrierSetT>
249 template <typename T>
250 inline oop XBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value) {
251   verify_decorators_present<ON_STRONG_OOP_REF>();
252   verify_decorators_absent<AS_NO_KEEPALIVE>();
253 
254   return Raw::oop_atomic_cmpxchg_not_in_heap(addr, compare_value, new_value);
255 }
< prev index next >