< prev index next >

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

8198949_arraycopy

7  *                                                                                                                                   
8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 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 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #ifndef SHARE_VM_GC_SHARED_MODREFBARRIERSET_INLINE_HPP                                                                               
25 #define SHARE_VM_GC_SHARED_MODREFBARRIERSET_INLINE_HPP                                                                               
26 
27 #include "gc/shared/barrierSet.inline.hpp"                                                                                           
28 #include "gc/shared/modRefBarrierSet.hpp"                                                                                            
29 #include "oops/klass.inline.hpp"                                                                                                     
30 #include "oops/objArrayOop.hpp"                                                                                                      
31 #include "oops/oop.hpp"                                                                                                              
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
32 
33 template <DecoratorSet decorators, typename BarrierSetT>                                                                             
34 template <typename T>                                                                                                                
35 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::                                                               
36 oop_store_in_heap(T* addr, oop value) {                                                                                              
37   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());                                                                    
38   bs->template write_ref_field_pre<decorators>(addr);                                                                                
39   Raw::oop_store(addr, value);                                                                                                       
40   bs->template write_ref_field_post<decorators>(addr, value);                                                                        
41 }                                                                                                                                    
42 
43 template <DecoratorSet decorators, typename BarrierSetT>                                                                             
44 template <typename T>                                                                                                                
45 inline oop ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::                                                                
46 oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) {                                                              
47   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());                                                                    
48   bs->template write_ref_field_pre<decorators>(addr);                                                                                
49   oop result = Raw::oop_atomic_cmpxchg(new_value, addr, compare_value);                                                              
50   if (result == compare_value) {                                                                                                     

7  *
8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 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 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #ifndef SHARE_VM_GC_SHARED_MODREFBARRIERSET_INLINE_HPP
25 #define SHARE_VM_GC_SHARED_MODREFBARRIERSET_INLINE_HPP
26 
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/modRefBarrierSet.hpp"
29 #include "oops/klass.inline.hpp"
30 #include "oops/objArrayOop.hpp"
31 #include "oops/oop.hpp"
32 
33 // count is number of array elements being written
34 void ModRefBarrierSet::write_ref_array(HeapWord* start, size_t count) {
35   assert(count <= (size_t)max_intx, "count too large");
36   HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize));
37   // In the case of compressed oops, start and end may potentially be misaligned;
38   // so we need to conservatively align the first downward (this is not
39   // strictly necessary for current uses, but a case of good hygiene and,
40   // if you will, aesthetics) and the second upward (this is essential for
41   // current uses) to a HeapWord boundary, so we mark all cards overlapping
42   // this write. If this evolves in the future to calling a
43   // logging barrier of narrow oop granularity, like the pre-barrier for G1
44   // (mentioned here merely by way of example), we will need to change this
45   // interface, so it is "exactly precise" (if i may be allowed the adverbial
46   // redundancy for emphasis) and does not include narrow oop slots not
47   // included in the original write interval.
48   HeapWord* aligned_start = align_down(start, HeapWordSize);
49   HeapWord* aligned_end   = align_up  (end,   HeapWordSize);
50   // If compressed oops were not being used, these should already be aligned
51   assert(UseCompressedOops || (aligned_start == start && aligned_end == end),
52          "Expected heap word alignment of start and end");
53   write_ref_array_work(MemRegion(aligned_start, aligned_end));
54 }
55 
56 template <DecoratorSet decorators, typename BarrierSetT>
57 template <typename T>
58 inline void ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
59 oop_store_in_heap(T* addr, oop value) {
60   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
61   bs->template write_ref_field_pre<decorators>(addr);
62   Raw::oop_store(addr, value);
63   bs->template write_ref_field_post<decorators>(addr, value);
64 }
65 
66 template <DecoratorSet decorators, typename BarrierSetT>
67 template <typename T>
68 inline oop ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
69 oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) {
70   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
71   bs->template write_ref_field_pre<decorators>(addr);
72   oop result = Raw::oop_atomic_cmpxchg(new_value, addr, compare_value);
73   if (result == compare_value) {
< prev index next >