< prev index next >

src/hotspot/share/gc/g1/g1BarrierSet.cpp

8198949_arraycopy

6  * published by the Free Software Foundation.                                                                                        
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 #include "precompiled.hpp"                                                                                                           
25 #include "gc/g1/g1BarrierSet.inline.hpp"                                                                                             
                                                                                                                                     
26 #include "gc/g1/g1CardTable.inline.hpp"                                                                                              
27 #include "gc/g1/g1CollectedHeap.inline.hpp"                                                                                          
28 #include "gc/g1/heapRegion.hpp"                                                                                                      
29 #include "gc/g1/satbMarkQueue.hpp"                                                                                                   
30 #include "logging/log.hpp"                                                                                                           
31 #include "oops/oop.inline.hpp"                                                                                                       
32 #include "runtime/mutexLocker.hpp"                                                                                                   
33 #include "runtime/thread.inline.hpp"                                                                                                 
34 
35 G1BarrierSet::G1BarrierSet(G1CardTable* card_table) :                                                                                
36   CardTableModRefBS(card_table, BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)),                                                     
37   _dcqs(JavaThread::dirty_card_queue_set())                                                                                          
38 { }                                                                                                                                  
39 
40 void G1BarrierSet::enqueue(oop pre_val) {                                                                                            
41   // Nulls should have been already filtered.                                                                                        
42   assert(oopDesc::is_oop(pre_val, true), "Error");                                                                                   
43 
44   if (!JavaThread::satb_mark_queue_set().is_active()) return;                                                                        
45   Thread* thr = Thread::current();                                                                                                   
46   if (thr->is_Java_thread()) {                                                                                                       
47     JavaThread* jt = (JavaThread*)thr;                                                                                               
48     jt->satb_mark_queue().enqueue(pre_val);                                                                                          
49   } else {                                                                                                                           
50     MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);                                                            
51     JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val);                                                         
52   }                                                                                                                                  
53 }                                                                                                                                    
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
54 
55 template <class T> void                                                                                                              
56 G1BarrierSet::write_ref_array_pre_work(T* dst, int count) {                                                                          
57   if (!JavaThread::satb_mark_queue_set().is_active()) return;                                                                        
58   T* elem_ptr = dst;                                                                                                                 
59   for (int i = 0; i < count; i++, elem_ptr++) {                                                                                      
60     T heap_oop = oopDesc::load_heap_oop(elem_ptr);                                                                                   
61     if (!oopDesc::is_null(heap_oop)) {                                                                                               
62       enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));                                                                          
63     }                                                                                                                                
64   }                                                                                                                                  
65 }                                                                                                                                    
66 
67 void G1BarrierSet::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) {                                               
68   if (!dest_uninitialized) {                                                                                                         
69     write_ref_array_pre_work(dst, count);                                                                                            
70   }                                                                                                                                  
71 }                                                                                                                                    
72 

6  * published by the Free Software Foundation.
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 #include "precompiled.hpp"
25 #include "gc/g1/g1BarrierSet.inline.hpp"
26 #include "gc/g1/g1BSCodeGen.hpp"
27 #include "gc/g1/g1CardTable.inline.hpp"
28 #include "gc/g1/g1CollectedHeap.inline.hpp"
29 #include "gc/g1/heapRegion.hpp"
30 #include "gc/g1/satbMarkQueue.hpp"
31 #include "logging/log.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/thread.inline.hpp"
35 
36 G1BarrierSet::G1BarrierSet(G1CardTable* card_table) :
37   CardTableModRefBS(card_table, BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)),
38   _dcqs(JavaThread::dirty_card_queue_set())
39 { }
40 
41 void G1BarrierSet::enqueue(oop pre_val) {
42   // Nulls should have been already filtered.
43   assert(oopDesc::is_oop(pre_val, true), "Error");
44 
45   if (!JavaThread::satb_mark_queue_set().is_active()) return;
46   Thread* thr = Thread::current();
47   if (thr->is_Java_thread()) {
48     JavaThread* jt = (JavaThread*)thr;
49     jt->satb_mark_queue().enqueue(pre_val);
50   } else {
51     MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
52     JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val);
53   }
54 }
55 
56 BarrierSetCodeGen *G1BarrierSet::make_code_gen() {
57   return new G1BSCodeGen();
58 }
59 
60 void G1BarrierSet::write_ref_array_pre_oop_entry(oop* dst, size_t length) {
61   assert(length <= (size_t)max_intx, "count too large");
62   G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
63   bs->G1BarrierSet::write_ref_array_pre(dst, (int)length, false);
64 }
65 
66 void G1BarrierSet::write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length) {
67   assert(length <= (size_t)max_intx, "count too large");
68   G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
69   bs->G1BarrierSet::write_ref_array_pre(dst, (int)length, false);
70 }
71 
72 void G1BarrierSet::write_ref_array_post_entry(HeapWord* dst, size_t length) {
73   G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
74   bs->G1BarrierSet::write_ref_array(dst, (int)length);
75 }
76 
77 
78 template <class T> void
79 G1BarrierSet::write_ref_array_pre_work(T* dst, int count) {
80   if (!JavaThread::satb_mark_queue_set().is_active()) return;
81   T* elem_ptr = dst;
82   for (int i = 0; i < count; i++, elem_ptr++) {
83     T heap_oop = oopDesc::load_heap_oop(elem_ptr);
84     if (!oopDesc::is_null(heap_oop)) {
85       enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));
86     }
87   }
88 }
89 
90 void G1BarrierSet::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) {
91   if (!dest_uninitialized) {
92     write_ref_array_pre_work(dst, count);
93   }
94 }
95 
< prev index next >