< prev index next >

src/hotspot/share/oops/access.inline.hpp

Print this page


   1 /*
   2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


 182   template <class GCBarrierType, DecoratorSet decorators>
 183   struct PostRuntimeDispatch<GCBarrierType, BARRIER_ATOMIC_CMPXCHG_AT, decorators>: public AllStatic {
 184     template <typename T>
 185     static T access_barrier(T new_value, oop base, ptrdiff_t offset, T compare_value) {
 186       return GCBarrierType::atomic_cmpxchg_in_heap_at(new_value, base, offset, compare_value);
 187     }
 188 
 189     static oop oop_access_barrier(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
 190       return GCBarrierType::oop_atomic_cmpxchg_in_heap_at(new_value, base, offset, compare_value);
 191     }
 192   };
 193 
 194   template <class GCBarrierType, DecoratorSet decorators>
 195   struct PostRuntimeDispatch<GCBarrierType, BARRIER_CLONE, decorators>: public AllStatic {
 196     static void access_barrier(oop src, oop dst, size_t size) {
 197       GCBarrierType::clone_in_heap(src, dst, size);
 198     }
 199   };
 200 
 201   template <class GCBarrierType, DecoratorSet decorators>







 202   struct PostRuntimeDispatch<GCBarrierType, BARRIER_RESOLVE, decorators>: public AllStatic {
 203     static oop access_barrier(oop obj) {
 204       return GCBarrierType::resolve(obj);
 205     }
 206   };
 207 
 208   // Resolving accessors with barriers from the barrier set happens in two steps.
 209   // 1. Expand paths with runtime-decorators, e.g. is UseCompressedOops on or off.
 210   // 2. Expand paths for each BarrierSet available in the system.
 211   template <DecoratorSet decorators, typename FunctionPointerT, BarrierType barrier_type>
 212   struct BarrierResolver: public AllStatic {
 213     template <DecoratorSet ds>
 214     static typename EnableIf<
 215       HasDecorator<ds, INTERNAL_VALUE_IS_OOP>::value,
 216       FunctionPointerT>::type
 217     resolve_barrier_gc() {
 218       BarrierSet* bs = BarrierSet::barrier_set();
 219       assert(bs != NULL, "GC barriers invoked before BarrierSet is set");
 220       switch (bs->kind()) {
 221 #define BARRIER_SET_RESOLVE_BARRIER_CLOSURE(bs_name)                    \


 334     _atomic_xchg_at_func = function;
 335     return function(new_value, base, offset);
 336   }
 337 
 338   template <DecoratorSet decorators, typename T>
 339   void RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy_init(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
 340                                                                          arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
 341                                                                          size_t length) {
 342     func_t function = BarrierResolver<decorators, func_t, BARRIER_ARRAYCOPY>::resolve_barrier();
 343     _arraycopy_func = function;
 344     function(src_obj, src_offset_in_bytes, src_raw,
 345              dst_obj, dst_offset_in_bytes, dst_raw,
 346              length);
 347   }
 348 
 349   template <DecoratorSet decorators, typename T>
 350   void RuntimeDispatch<decorators, T, BARRIER_CLONE>::clone_init(oop src, oop dst, size_t size) {
 351     func_t function = BarrierResolver<decorators, func_t, BARRIER_CLONE>::resolve_barrier();
 352     _clone_func = function;
 353     function(src, dst, size);







 354   }
 355 
 356   template <DecoratorSet decorators, typename T>
 357   oop RuntimeDispatch<decorators, T, BARRIER_RESOLVE>::resolve_init(oop obj) {
 358     func_t function = BarrierResolver<decorators, func_t, BARRIER_RESOLVE>::resolve_barrier();
 359     _resolve_func = function;
 360     return function(obj);
 361   }
 362 }
 363 
 364 #endif // SHARE_OOPS_ACCESS_INLINE_HPP
   1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


 182   template <class GCBarrierType, DecoratorSet decorators>
 183   struct PostRuntimeDispatch<GCBarrierType, BARRIER_ATOMIC_CMPXCHG_AT, decorators>: public AllStatic {
 184     template <typename T>
 185     static T access_barrier(T new_value, oop base, ptrdiff_t offset, T compare_value) {
 186       return GCBarrierType::atomic_cmpxchg_in_heap_at(new_value, base, offset, compare_value);
 187     }
 188 
 189     static oop oop_access_barrier(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
 190       return GCBarrierType::oop_atomic_cmpxchg_in_heap_at(new_value, base, offset, compare_value);
 191     }
 192   };
 193 
 194   template <class GCBarrierType, DecoratorSet decorators>
 195   struct PostRuntimeDispatch<GCBarrierType, BARRIER_CLONE, decorators>: public AllStatic {
 196     static void access_barrier(oop src, oop dst, size_t size) {
 197       GCBarrierType::clone_in_heap(src, dst, size);
 198     }
 199   };
 200 
 201   template <class GCBarrierType, DecoratorSet decorators>
 202   struct PostRuntimeDispatch<GCBarrierType, BARRIER_VALUE_COPY, decorators>: public AllStatic {
 203     static void access_barrier(void* src, void* dst, ValueKlass* md) {
 204       GCBarrierType::value_copy_in_heap(src, dst, md);
 205     }
 206   };
 207 
 208   template <class GCBarrierType, DecoratorSet decorators>
 209   struct PostRuntimeDispatch<GCBarrierType, BARRIER_RESOLVE, decorators>: public AllStatic {
 210     static oop access_barrier(oop obj) {
 211       return GCBarrierType::resolve(obj);
 212     }
 213   };
 214 
 215   // Resolving accessors with barriers from the barrier set happens in two steps.
 216   // 1. Expand paths with runtime-decorators, e.g. is UseCompressedOops on or off.
 217   // 2. Expand paths for each BarrierSet available in the system.
 218   template <DecoratorSet decorators, typename FunctionPointerT, BarrierType barrier_type>
 219   struct BarrierResolver: public AllStatic {
 220     template <DecoratorSet ds>
 221     static typename EnableIf<
 222       HasDecorator<ds, INTERNAL_VALUE_IS_OOP>::value,
 223       FunctionPointerT>::type
 224     resolve_barrier_gc() {
 225       BarrierSet* bs = BarrierSet::barrier_set();
 226       assert(bs != NULL, "GC barriers invoked before BarrierSet is set");
 227       switch (bs->kind()) {
 228 #define BARRIER_SET_RESOLVE_BARRIER_CLOSURE(bs_name)                    \


 341     _atomic_xchg_at_func = function;
 342     return function(new_value, base, offset);
 343   }
 344 
 345   template <DecoratorSet decorators, typename T>
 346   void RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy_init(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
 347                                                                          arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
 348                                                                          size_t length) {
 349     func_t function = BarrierResolver<decorators, func_t, BARRIER_ARRAYCOPY>::resolve_barrier();
 350     _arraycopy_func = function;
 351     function(src_obj, src_offset_in_bytes, src_raw,
 352              dst_obj, dst_offset_in_bytes, dst_raw,
 353              length);
 354   }
 355 
 356   template <DecoratorSet decorators, typename T>
 357   void RuntimeDispatch<decorators, T, BARRIER_CLONE>::clone_init(oop src, oop dst, size_t size) {
 358     func_t function = BarrierResolver<decorators, func_t, BARRIER_CLONE>::resolve_barrier();
 359     _clone_func = function;
 360     function(src, dst, size);
 361   }
 362 
 363   template <DecoratorSet decorators, typename T>
 364   void RuntimeDispatch<decorators, T, BARRIER_VALUE_COPY>::value_copy_init(void* src, void* dst, ValueKlass* md) {
 365     func_t function = BarrierResolver<decorators, func_t, BARRIER_VALUE_COPY>::resolve_barrier();
 366     _value_copy_func = function;
 367     function(src, dst, md);
 368   }
 369 
 370   template <DecoratorSet decorators, typename T>
 371   oop RuntimeDispatch<decorators, T, BARRIER_RESOLVE>::resolve_init(oop obj) {
 372     func_t function = BarrierResolver<decorators, func_t, BARRIER_RESOLVE>::resolve_barrier();
 373     _resolve_func = function;
 374     return function(obj);
 375   }
 376 }
 377 
 378 #endif // SHARE_OOPS_ACCESS_INLINE_HPP
< prev index next >